Coder Social home page Coder Social logo

raspberry-wifi-conf's Introduction

raspberry-wifi-conf

A Node application which makes connecting your RaspberryPi to your home wifi easier.

Tested on Stretch and Raspberrt Pi 3

RPI 4 Note:

I realize that a bunch of folks will try this out using the shiny new RaspberryPi v4. I caution you that this is not something I have tried, I believe this was tested on a Pi3 to success. However, if you find that this works on a Pi4, please let me know and I will adjust the readme accordingly. If it does not work, it is probably a few PRs away from success :)

Why?

When unable to connect to a wifi network, this service will turn the RPI into a wireless AP. This allows us to connect to it via a phone or other device and configure our home wifi network (for example).

Once configured, it prompts the PI to reboot with the appropriate wifi credentials. If this process fails, it immediately re-enables the PI as an AP which can be configurable again.

This project broadly follows these instructions in setting up a RaspberryPi as a wireless AP.

Requirements

The NodeJS modules required are pretty much just underscore, async, and express.

The web application requires angular and font-awesome to render correctly. To make the deployment of this easy, one of the other requirements is bower.

If you do not have bower installed already, you can install it globally by running: sudo npm install bower -g.

Install

$git clone https://github.com/sabhiram/raspberry-wifi-conf.git
$cd raspberry-wifi-conf
$npm update
$bower install
$sudo npm run-script provision
$sudo npm start

Setup the app as a service

There is a startup script included to make the server starting and stopping easier. Do remember that the application is assumed to be installed under /home/pi/raspberry-wifi-conf. Feel free to change this in the assets/init.d/raspberry-wifi-conf file.

$sudo cp assets/init.d/raspberry-wifi-conf /etc/init.d/raspberry-wifi-conf 
$sudo chmod +x /etc/init.d/raspberry-wifi-conf  
$sudo update-rc.d raspberry-wifi-conf defaults

Gotchas

hostapd

The hostapd application does not like to behave itself on some wifi adapters (RTL8192CU et al). This link does a good job explaining the issue and the remedy: Edimax Wifi Issues. The gist of what you need to do is as follows:

# run iw to detect if you have a rtl871xdrv or nl80211 driver
$iw list

If the above says nl80211 not found. it means you are running the rtl871xdrv driver and probably need to update the hostapd binary as follows:

$cd raspberry-wifi-conf
$sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.OLD
$sudo mv assets/bin/hostapd.rtl871xdrv /usr/sbin/hostapd
$sudo chmod 755 /usr/sbin/hostapd

Note that the wifi_driver_type config variable is defaulted to the nl80211 driver. However, if iw list fails on the app startup, it will automatically set the driver type of rtl871xdrv. Remember that even though you do not need to update the config / default value - you will need to use the updated hostapd binary bundled with this app.

dhcpcd

Latest versions of raspbian use dhcpcd to manage network interfaces, since we are running our own dhcp server, if you have dhcpcd installed - make sure you deny the wifi interface as described in the installation section.

TODO: Handle this automatically.

Usage

This is approximately what occurs when we run this app:

  1. Check to see if we are connected to a wifi AP
  2. If connected to a wifi, do nothing -> exit
  3. (if not wifi, then) Convert RPI to act as an AP (with a configurable SSID)
  4. Host a lightweight HTTP server which allows for the user to connect and configure the RPIs wifi connection. The interfaces exposed are RESTy so other applications can similarly implement their own UIs around the data returned.
  5. Once the RPI is successfully configured, reset it to act as a wifi device (not AP anymore), and setup it's wifi network based on what the user selected.
  6. At this stage, the RPI is named, and has a valid wifi connection which it is now bound to.

Typically, I have the following line in my /etc/rc.local file:

cd /home/pi/raspberry-wifi-conf
sudo /usr/bin/node server.js

Note that this is run in a blocking fashion, in that this script will have to exit before we can proceed with others defined in rc.local. This way I can guarantee that other services which might rely on wifi will have said connection before being run. If this is not the case for you, and you just want this to run (if needed) in the background, then you can do:

cd /home/pi/raspberry-wifi-conf
sudo /usr/bin/node server.js < /dev/null &

User Interface

In my config file, I have set up the static ip for my PI when in AP mode to 192.168.44.1 and the AP's broadcast SSID to rpi-config-ap. These are images captured from my osx dev box.

Step 1: Power on Pi which runs this app on startup (assume it is not configured for a wifi connection). Once it boots up, you will see rpi-config-ap among the wifi connections. The password is configured in config.json.

Step 2: Join the above network, and navigate to the static IP and port we set in config.json (http://192.168.44.1:88), you will see:

Step 3: Select your home (or whatever) network, punch in the wifi passcode if any, and click Submit. You are done! Your Pi is now on your home wifi!!

Testing

raspberry-wifi-conf's People

Contributors

sabhiram avatar stefangordon avatar stzoran1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raspberry-wifi-conf's Issues

Ralink RT5370 and hostapd

Hello,

I'm using a Ralink RT5370 chipset on my rapsberry, I get the following message : ... AP Enable Success!

but I don't see the rpi-config-ap hotspot in the wifi list.

Any idea on how to solve this issue please ?

when I try to start it via the terminal :

#hostapd /etc/hostapd/hostapd.conf                                                                                                                 
Configuration file: /etc/hostapd/hostapd.conf                                                                                                                                 
nl80211: Could not configure driver mode                                                                                                                                      
nl80211 driver initialization failed.                                                                                                                                         
hostapd_free_hapd_data: Interface wlan0 wasn't started      

Error after AP mode

I am also getting an error when I try to run it on a pi 3:

`pi@raspberrypi:~/raspberry-wifi-conf $ sudo npm start

[email protected] start /home/pi/raspberry-wifi-conf
node server.js

Wifi is not enabled, Enabling AP for self-configure

Force reconfigure enabled - reset AP
ifdown wlan0 successful...
ifup wlan0 successful...
... dhcp server restarted!
... hostapd restarted!
... AP Enable Success!

events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1042:14)
at listen (net.js:1064:10)
at Server.listen (net.js:1138:5)
at EventEmitter.app.listen (/home/pi/raspberry-wifi-conf/node_modules/express/lib/application.js:559:24)
at module.exports (/home/pi/raspberry-wifi-conf/app/api.js:76:9)
at start_http_server (/home/pi/raspberry-wifi-conf/server.js:64:32)
at /home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:607:21
at /home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:246:17
at iterate (/home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:146:13)

npm ERR! [email protected] start: node server.js
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is most likely a problem with the raspberry-wifi-conf package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node server.js
npm ERR! You can get their info via:
npm ERR! npm owner ls raspberry-wifi-conf
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 4.1.19-v7+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! cwd /home/pi/raspberry-wifi-conf
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/pi/raspberry-wifi-conf/npm-debug.log
npm ERR! not ok code 0
pi@raspberrypi:~/raspberry-wifi-conf $ `

Connects to IP 192.168.44.1 and no wireless interfaces found

Everything ran fine on RPi3 until I "Submitted" the new ssid/pwd on mobile. At that point, the i[ address was assigned as 192.168.44.1 . If I run the node app again it shows wifi enabled and IP 192.168.44.1 .

Upon rebooting, "no wireless conection" and eth0: Link is down.

Tried resetting all networking files but missing something.

Thoughts?

Stuck at "sudo npm run-script provision"

Thank you for building this thing! I am following your instructions and I've gotten to the stage of installation where I'm supposed to do...

sudo npm run-script provision

When I do, though, I get permission denied as follows...

$> sudo npm run-script provision

[email protected] provision
apt-get update -y && apt-get install dnsmasq hostapd iw -y

Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)

And then I'm not allowed to go any further to start the thing or anything. Any help MUCH appreciated!

Crash when start

node server.js

/home/pi/raspberry-wifi-conf/app/wifi_manager.js:136
            info["hw_addr"].toLowerCase() == info["ap_addr"].toLowerCase() &&
                                                             ^
TypeError: Cannot call method 'toLowerCase' of undefined
    at _is_ap_enabled_sync (/home/pi/raspberry-wifi-conf/app/wifi_manager.js:136:62)
    at _is_wifi_enabled_sync (/home/pi/raspberry-wifi-conf/app/wifi_manager.js:115:28)
    at /home/pi/raspberry-wifi-conf/app/wifi_manager.js:126:35
    at /home/pi/raspberry-wifi-conf/app/wifi_manager.js:90:20
    at /home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:251:17
    at /home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:154:25
    at /home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:248:21
    at /home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:612:34
    at /home/pi/raspberry-wifi-conf/app/wifi_manager.js:76:17
    at ChildProcess.exithandler (child_process.js:645:7)

Add new wifi to wpa_supplicant instead of replace

Hi,

i wonder if you can help me with a "special feature". Although it works great so far i need to be able to save seperate wifi's in the wpa_supplicant instead of only one.

At the moment when teaching a new wifi via HTTP Server the older one which isn't in use currently will be deleted and instead the new credentials will be pasted.

I wish the older credentials would be saved and the new ones simply added below. So the raspi will look at the available credentials after start and check if any of them gives him a internet connection.
If not, it opens the hotspot.

Maybe, after some time the wpa_supplicant will be full of "old" credentials nobody needs for, but that shouldnt be a huge problem, does it?

Not able to access the HTTP server

HI,

I have made all the steps to install and run the solution. At this point the raspberry is working as a AP and I can connect my PC to it. But when I try to access the server typing http://192.168.44.1:88 on google Chromo it tells me that he is not able to connect to the address for some reason (proxy and etc..).
How can I check if my server is running on the raspberry pi?

Thanks.

Can see the Network but I can not connect to 192.168.44.1:88

So I am running RPI 3 on the newest raspbian stretch and I can click on the network that the RPI is giving off but I can not connect to the website to to enter my credentials. Now I have no internet and I do not know how to revert. Does anyone know how to refresh my network files back to normal or know how to fix this issue. Thanks!

wireless problems: how to revert?

so, this is what happens to me:

  • everything works, but when i connect to the AP, i don't get any webpage (at the address with port 88)
  • when i go to localhost:88 on the pi itself, i get the webpage, but don't see any APs
  • now my WiFi is hosed -- i can't seem to reconfigure back into normal wifi mode.

question: how do i undo everything that this program has done? is there a flag i can use? maybe some uninstall instructions are in order in case the whole installation fails.

Can't connect to ip address 192.168.44.1:88

I'm stucked at
Step 2: Join the above network, and navigate to the static IP and port we set in config.json (http://192.168.44.1:88), you will
I can't connect it from my pc, but I can open it on rpi. How do I fix this?

Also how do I implement this functionality in an electronjs app, can you give some tips?

Pi thinks it's connect to Wifi but doesn't an have internet connection.

Fist awesome job on this! This is the only repo that I found that actually does this.
Here is the problem I'm running into:
I got it to send out the AP, connected to it with my iPhone. Went to the IP:88 and was able to choose a network and login and connect fine. Once I got it connected, the UI freezes (not sure if that is supposed to happen), then I realized I had my ethernet cable still connected. So I rebooted the RPi and tried the process again. However, when I start the server and it still thinks it's connected to wifi, but has no internet connection, and I haven't been able to connect to the server from my phone or computer since then.

  1. Is there a way to clear the memory of previous wifi networks?
  2. How can I make the Node server always appear in case I need to change the Wifi config again?

AP SSID not showing up

Hi,

I did follow correctly your tutorial. First time I tried, I could see from my iPhone the rpi SSID in wifi list. Once I added the line "denyinterfaces wlan0", I could not make it work. The script goes well but I can't see the rpi in wifi list... don't know what I did wrong ...

Now my pi has 192.168.44.1 address but it does not show up and I can't get my pi to connect to a wifi. Any idea ?

Thank you very much !

After Password entered it binds immediately

After submitting the password for my AP, it appears to be locked up but in fact it binds and activates on network without a reset.

Is there a way to make this tell the user to reset and not make changes active until reset?

Thanks

PI starts in AP mode after entering the wifi credentials

@marko8904

I have installed marko8904's fork. It is possible to enter the wifi credentials and my pi connects successfully to my wifi network at home:

pi@raspberrypi:~/raspberry-wifi-conf $ sudo npm start

[email protected] start /home/pi/raspberry-wifi-conf
node server.js

Wifi is not enabled, Enabling AP for self-configure

Force reconfigure enabled - reset AP
ifdown wlan0 successful...
ifup wlan0 successful...
... dhcp server restarted!
... hostapd restarted!
... AP Enable Success!
Server got /rescan_wifi
Found new interface: wlan0
... dhcp server stopped!
ifdown wlan0 successful...
ifup wlan0 successful...
Wifi Enabled! - Exiting

pi@raspberrypi:~/raspberry-wifi-conf $ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr b8:27:eb:6c:ec:ac
*inet addr:192.168.178.35 * Bcast:192.168.178.255 Mask:255.255.255.0
inet6 addr: fe80::a473:5731:9a51:f2dd/64 Scope:Link
inet6 addr: fe80::9f22:eef2:ccc7:a6fb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:475 errors:0 dropped:8 overruns:0 frame:0
TX packets:652 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:82719 (80.7 KiB) TX bytes:298114 (291.1 KiB)

After rebooting my pi starts in the AP mode again and does not connect to the wifi network:

pi@raspberrypi:~ $ ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr b8:27:eb:6c:ec:ac
* inet addr:192.168.44.1* Bcast:192.168.44.255 Mask:255.255.255.0
inet6 addr: fe80::9f22:eef2:ccc7:a6fb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:46 errors:0 dropped:5 overruns:0 frame:0
TX packets:86 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8588 (8.3 KiB) TX bytes:16187 (15.8 KiB)

Why does the pi start in AP mode again and why does it not connect to my wifi network although I have entered the credentials via smartphone?

Many thanks in advance for any help. I would really like to get this working :-)

Is it possible to use two wifi adapters and make the configuration easier?

I have a Raspberry PI3 equipped with a wifi module.But I still plug a wifi adapter(MT7601U) into it.So I wander whether there is a solution to use one of those two interfaces as an AP while the other connects to a wifi network.
What I want to achieve is that every time I turn on PI's power,it can create an AP automatically so that I can connect to it using a phone and connect the PI to any new wifi network through ssh.For now I can create an AP using inside wifi interface and share the other's network thanks to create_ap.But every time I do so,both adapters will remember the ssid and password and connect to it automatically next time start up so that the create_ap won't work as an interface cannot be an AP and a wifi connecter at the same time.
I hope there's a solution to achieve my goal using two adapters and raspberry-wifi-conf so that there's no need to reboot during the whole configuration.

TypeError: Cannot read property 'toLowerCase' of undefined

hi @sabhiram
I was running this projec over raspberry pi 3 which is installed raspbian jessie.
I installed nodejs v7.7.1
When all prepare work has been done, I tried to run 'node server.js' but get an error,log is here :
/home/pi/raspberry-wifi-conf/app/wifi_manager.js:136
info["hw_addr"].toLowerCase() == info["ap_addr"].toLowerCase() &&
^

TypeError: Cannot read property 'toLowerCase' of undefined
at _is_ap_enabled_sync (/home/pi/raspberry-wifi-conf/app/wifi_manager.js:136:61)
at _is_wifi_enabled_sync (/home/pi/raspberry-wifi-conf/app/wifi_manager.js:115:28)
at /home/pi/raspberry-wifi-conf/app/wifi_manager.js:126:35
at /home/pi/raspberry-wifi-conf/app/wifi_manager.js:90:20
at /home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:251:17
at /home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:154:25
at /home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:248:21
at /home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:612:34
at /home/pi/raspberry-wifi-conf/app/wifi_manager.js:76:17
at ChildProcess.exithandler (child_process.js:201:7)

do you have any idea about how to deal with this?
thank you

Implement DNS resolver within AP so that named routes can reach the temporary server

UPDATE: I got it to work and it's awesome! I think the issue I had was that the service wasn't starting up at boot. Manually starting it worked just fine. I'll have to sort that part out. One small request: is it possible to use a name (config-wifi) rather than IP address to connect to the config?

Thanks for the great work, but I can't get it to work for me. I am a bit confused also about the documentation. I was able to get an AP configured from the link you provided http://www.maketecheasier.com/set-up-raspberry-pi-as-wireless-access-point/ but can't get yours to work.

Are we supposed to follow the steps of that other AP tutorial and then your instructions? Or just follow yours? Perhaps a bit more documentation will help? I am not getting any errors, but I'm also not getting any results. Any help appreciated. Thanks

No rpi-config-ap on network list

Hi, Thanks lot for the great wifi conf. I have followed all the steps/instructions and installed the raspberry-wifi-conf on my Raspberry pi 2 Model 2 (with Raspbian Jessie fresh copy). But I can't see the rpi-config-ap on my wifi network list. I'm using EDUP wifi dongle (EP-N8553). I have attached an screenshot. This is what I'm getting on the terminal. Could you please help me guys?

terminal

Stuck at $sudo npm start, dhcp server fail? Raspberry Pi 3 Model B

So I have tried installing this several times but I am getting stuck at the last step. I freshly installed the newest version of raspbian stretch and I follow the installation steps but when I get to $sudo npm start my terminal says this

pi@raspberrypi:~/raspberry-wifi-conf $ sudo npm start
 
> [email protected] start /home/pi/raspberry-wifi-conf
> node server.js
 
 
Wifi is not enabled, Enabling AP for self-configure
 
Force reconfigure enabled - reset AP
... dhcp server failed! -
ifdown wlan0 successful...
ifup wlan0 successful...
... hostapd restarted!
... AP Enable Success!
 
HTTP server running...

Why is this happening? I would post my full terminal but I thought it was too long so if you need to see my full terminal with how everything installed it can be found here https://pastebin.com/BZNDsfhn .

Now since it gets stuck at that command I am forced to restart my terminal since I cant type anymore and if I re-enter the command $sudo npm start I get this

pi@raspberrypi:~ $ cd raspberry-wifi-conf
pi@raspberrypi:~/raspberry-wifi-conf $ sudo npm start
 
> [email protected] start /home/pi/raspberry-wifi-conf
> node server.js
 
 
Wifi is not enabled, Enabling AP for self-configure
 
Force reconfigure enabled - reset AP
... dhcp server restarted!
ifdown wlan0 successful...
ifup wlan0 successful...
... hostapd restarted!
... AP Enable Success!
 
HTTP server running...
events.js:163
      throw er; // Unhandled 'error' event
      ^
 
Error: listen EADDRINUSE :::88
    at Object.exports._errnoException (util.js:1050:11)
    at exports._exceptionWithHostPort (util.js:1073:20)
    at Server.setupListenHandle [as _listen2] (net.js:1259:14)
    at listenInCluster (net.js:1307:12)
    at Server.listen (net.js:1406:7)
    at Function.app.listen (/home/pi/raspberry-wifi-conf/node_modules/express/lib/application.js:559:24)
    at module.exports (/home/pi/raspberry-wifi-conf/app/api.js:76:9)
    at start_http_server (/home/pi/raspberry-wifi-conf/server.js:70:32)
    at /home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:607:21
    at /home/pi/raspberry-wifi-conf/node_modules/async/lib/async.js:246:17
 
npm ERR! Linux 4.9.41-v7+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v7.10.1
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the raspberry-wifi-conf package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs raspberry-wifi-conf
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls raspberry-wifi-conf
npm ERR! There is likely additional logging output above.
 
npm ERR! Please include the following file with any support request:
npm ERR!     /root/.npm/_logs/2017-09-27T06_10_58_899Z-debug.log
pi@raspberrypi:~/raspberry-wifi-conf $

I assume that is probably happening because the first start did not work but maybe it has some information in it that can help you determine the issue. Looking at the first code I posted at the top could it be something to do with my dhcp server failing? How do I fix this? Thank you for any help!!

how to change wifi once connected

i saw in one other post a user mentioned the ability to change wifi, how is that possible if http server gets shutdown if wifi is enabled?

pi 3 error after ap mode

I successfully installed raspberry-wifi-conf on RPi 3 with raspbian-jessie according to manual, AP is started, I connected to AP, typed 192.168.44.1:88 to browser. I choose my ssid from list, typed my wifi password to dialog. When i press submit button, i got error from node side. Rpi3 didnt connect my network. Also after that i cant access to 192.168.44.1:88. AP mode is open. When i try to sudo npm start, i am getting this error everytime. Any help?

sudo npm start

[email protected] start /home/pi/Desktop/raspberry-wifi-conf
node server.js

/home/pi/Desktop/raspberry-wifi-conf/app/wifi_manager.js:136
info["hw_addr"].toLowerCase() == info["ap_addr"].toLowerCase() &&
^

TypeError: Cannot read property 'toLowerCase' of undefined
at _is_ap_enabled_sync (/home/pi/Desktop/raspberry-wifi-conf/app/wifi_manage r.js:136:61)
at _is_wifi_enabled_sync (/home/pi/Desktop/raspberry-wifi-conf/app/wifi_mana ger.js:115:28)
at /home/pi/Desktop/raspberry-wifi-conf/app/wifi_manager.js:126:35
at /home/pi/Desktop/raspberry-wifi-conf/app/wifi_manager.js:90:20
at /home/pi/Desktop/raspberry-wifi-conf/node_modules/async/lib/async.js:251: 17
at /home/pi/Desktop/raspberry-wifi-conf/node_modules/async/lib/async.js:154: 25
at /home/pi/Desktop/raspberry-wifi-conf/node_modules/async/lib/async.js:248: 21
at /home/pi/Desktop/raspberry-wifi-conf/node_modules/async/lib/async.js:612: 34
at /home/pi/Desktop/raspberry-wifi-conf/app/wifi_manager.js:76:17
at ChildProcess.exithandler (child_process.js:204:7)

[email protected] start /home/pi/Desktop/raspberry-wifi-conf
node server.js

/home/pi/Desktop/raspberry-wifi-conf/app/wifi_manager.js:136
info["hw_addr"].toLowerCase() == info["ap_addr"].toLowerCase() &&
^

TypeError: Cannot read property 'toLowerCase' of undefined
at _is_ap_enabled_sync (/home/pi/Desktop/raspberry-wifi-conf/app/wifi_manager.js:136:61)
at _is_wifi_enabled_sync (/home/pi/Desktop/raspberry-wifi-conf/app/wifi_manager.js:115:28)
at /home/pi/Desktop/raspberry-wifi-conf/app/wifi_manager.js:126:35
at /home/pi/Desktop/raspberry-wifi-conf/app/wifi_manager.js:90:20
at /home/pi/Desktop/raspberry-wifi-conf/node_modules/async/lib/async.js:251:17
at /home/pi/Desktop/raspberry-wifi-conf/node_modules/async/lib/async.js:154:25
at /home/pi/Desktop/raspberry-wifi-conf/node_modules/async/lib/async.js:248:21
at /home/pi/Desktop/raspberry-wifi-conf/node_modules/async/lib/async.js:612:34
at /home/pi/Desktop/raspberry-wifi-conf/app/wifi_manager.js:76:17
at ChildProcess.exithandler (child_process.js:204:7)

npm ERR! Linux 4.1.18-v7+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.3.1
npm ERR! npm v2.14.12
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: node server.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'node server.js'.
npm ERR! This is most likely a problem with the raspberry-wifi-conf package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node server.js
npm ERR! You can get their info via:
npm ERR! npm owner ls raspberry-wifi-conf
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/pi/Desktop/raspberry-wifi-conf/npm-debug.log

Cannot find module 'async'

I installed the async module but it seems it's not enough:

$ sudo npm install async -g
/usr/lib
`-- [email protected]

$ node server.js
module.js:440
throw err;
^

Error: Cannot find module 'async'
at Function.Module._resolveFilename (module.js:438:15)
at Function.Module._load (module.js:386:25)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object. (/opt/utils/raspberry-wifi-conf/server.js:1:89)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)

What am I missing?

Unable to get it to work on rpi4

The installation and server seems to start fine but I do not see the access point. I am using the default config that's noted in the git repo. Below is what I see when I start the server:

node server.js

Wifi is not enabled, Enabling AP for self-configure

AP is not enabled yet... enabling...
... dhcpcd server restarted!
ifconfig wlan0 down successful...
... dnsmasq server restarted!
... AP Enable Success!

RPi4 Troubleshooting

@sabhiram @stzoran1 - figured I would drop this here and include stzoran1 since it looks like you were the last one to add to this repository as well.

I'm running an RPi4 and things seem to be generally working. Currently not running as a service yet, but I can run the node server and get all the way through setting up the access point, connecting via the access point, entering credentials, and then connecting to my home wifi. The only issue is that after running the server, although I register as "connected", I can't seem to ping anything going out, or ssh into the Pi. I can see that I am connected on my router as well, so I'm not sure where the break down might be?

Here's the output of a few files/commands in case they are helpful:

cat /etc/network/interfaces
source-directory / etc/network/interfaces.d

allow-hotplug wlan0
iface wlan- inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface

0.0.0.0 192.168.1.254 0.0.0.0 UG 0 303 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 303 0 wlan0

ifconfig
wlan0: flags -4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.215 netmask 255.255.255.0 broadcast 192.168.1.255
.....

/etc/resolv.conf
domain attlocal.net
nameserver 192.168.1.254

Update:
I can get set credentials for the hotspot on my phone and it does appear to work end to end. So maybe connecting to my LAN is an issue with my router? Is there anything that jumps out at you from the above details?

server fails to start if node.js is not at /usr/bin/node

The assets/init.d/raspberry-wifi-conf file assumes that node.js is installed at /usr/bin/node. This will not be the case if it was installed via nvm or other non-repo install. see line 19:
sudo /usr/bin/node server.js &

The solution is to either look for node.js on PATH or require the user to create a symlink, for example:
sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/node" "/usr/bin/node"
or, add a #! for node.js to server.js and just run server.js directly, line 19:
sudo server.js &

Enable dual wifi interfaces, one as an AP - one as the wifi

Opened to continue this reddit discussion.

Would be a pretty simple addition, although some of the code will just assume that wlan0 is the device for configuring.

Ideally we would expose these config options in the config.json file:

   "access_point": {
        "force_reconfigure": false,
        "wifi_interface":    "wlan0",
        "ssid":              "rpi-config-ap",
        "passphrase":        "zzzzzzzz",
        "domain":            "rpi.config",
        "ip_addr":           "192.168.44.1",
        "netmask":           "255.255.255.0",
        "subnet_ip":         "192.168.44.0",
        "broadcast_address": "192.168.44.255",
        "subnet_range": {
            "start":         "192.168.44.10",
            "end":           "192.168.44.50"
        }
    },

    /* New AP fields */
    "ap_interface": "wlan1",
       ... 

    },

    ... other non AP config stuff

I am thinking the server.js file can just check to see how many interfaces are supported as part of the wifi_manager's export function opening. This way any-time wifi_manager is required, we will setup the number of interfaces available.

Then, in the code which enables the AP / Wifi, we would have to check to see if we are in dual mode or single mode. Based on this mode, we would need to reconfigure the interface (or just re-enable it if we have used both interfaces before).

Thoughts?

No WiFi networks found

I have successfully installed raspberry-wifi-conf on RPi with raspbian-jessie according to manual, started node with server.js, AP is started, I connect to AP go to 192.168.44.1:88, and no WiFi networks are found, I click Rescan, see on node.js console that rescan wifi was requested, but nothing happens, where should I search for the problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.