Giter Site home page Giter Site logo

webthingsio / gateway-wifi-setup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mozilla/vaani.setup

23.0 5.0 26.0 6.6 MB

An express server that runs on the WebThings Gateway device to handle initial wifi setup

License: Mozilla Public License 2.0

JavaScript 60.59% HTML 34.95% Shell 0.99% Python 3.47%

gateway-wifi-setup's Introduction

gateway-wifi-setup

This repo is an Express server that runs on the Moz Gateway device and handles the first-time setup required to get the device working:

  • since the device is not on the local wifi network when it is first turned on, the device broadcasts its own wifi access point and runs the server on that. The user then connects their phone or laptop to that wifi network and uses a web browser (not a native app!) to connect to the device at the URL gateway.local. The user can select then their home wifi network and enter the password on a web page and transfer it to the web server running on the device. At this point, the device can turn off its private network and connect to the internet using the credentials the user provided.

The code is Linux-specific, depends on systemd, and has so far only been tested on a Raspberry Pi 3. It requires hostapd and dnsmasq to be installed and properly configured. Here are the steps I followed to configure and run this server. Note that the steps include instructions for Raspberry Pi and Edison, but that I have not yet been able to successfully run on Edison.

If you intend to modify this code and need to test your changes in a real device, please refer to: https://github.com/mozilla-iot/gateway-wifi-setup/wiki/Testing-on-WoT-Base-Image

Step 0: clone and install

First, clone this repo and download its dependencies from npm:

$ git clone https://github.com/mozilla-iot/gateway-wifi-setup
$ cd gateway-wifi-setup
$ npm install

Step 1: Edison specific setup

If you're running this software on an Intel Edison instead of a Raspberry Pi, you'll probably need to modify the default yocto Linux build, as follows:

If you don't already have node 4.4, update your node and npm with commands like these:

# curl https://nodejs.org/dist/v4.4.7/node-v4.4.7-linux-x86.tar.xz | zcat | tar xf - -C /usr/local
# cat <<EOF >> ~/.profile
export PATH=/usr/local/node-v4.4.7-linux-x86/bin:$PATH
EOF
# source ~/.profile
# node --version
v4.4.7

If your Edison is running mdnsd, you'll probably need to disable that and install avahi instead. These software packages are both supposed to do mdns aka zeroconf aka bonjour so that you can refer to your device by the name 'hostname.local'. But the mdns package doesn't work on my Edison, so I've swapped it out for avahi, which is what Raspberry pi uses. Commands like these should work:

# systemctl disable mdns
# systemctl stop mdns
# opkg install avahi
# reboot

By default, my Edison was already running an HTTP server on port 80, so this server was not able to run. I disabled the edison_config server like this:

# systemctl disable edison_config
# systemctl stop edison_config

Step 2: AP mode setup

Install software we need to host an access point, but make sure it does not run by default each time we boot. For Raspberry Pi, we need to do:

$ sudo apt-get install hostapd
$ sudo apt-get install dnsmasq
$ sudo systemctl disable hostapd
$ sudo systemctl disable dnsmasq

Step 3: configuration files

Next, configure the software:

  • On Raspberry Pi, edit /etc/default/hostapd to add the line:
DAEMON_CONF="/etc/hostapd/hostapd.conf"

this step is not necessary on Edison.

  • Copy config/hostapd.conf to /etc/hostapd/hostapd.conf. This config file defines the access point name "WebThings Gateway". Edit it if you want to use a different name. On Edison /etc/hostapd/hostapd.conf alread exists. You may want to rename the existing file rather than overwriting it.

  • On Edison (but not Raspberry Pi) edit the file /lib/systemd/system/udhcpd-for-hostapd.service and modify this line:

ExecStartPre=/sbin/ifconfig wlan0 192.168.42.1 up

changing 192.168.42.1 to 192.168.220.1. This is necessary because config/dnsmasq.conf and wifi.js use 192.168.220.1 as the local IP address when we're broadcasting an access point. This ip should match the one set on platforms/default.js at variable ap_ip.

  • On Raspberry Pi, copy config/dnsmasq.conf to /etc/dnsmasq.conf.

Step 4: run the server

If you have a keyboard and monitor hooked up to your device, or have a serial connection to the device, then you can try out the server at this point:

sudo node index.js

If you want to run the server on a device that has no network connection and no keyboard or monitor, you probably want to set it up to run automatically when the device boots up. To do this, copy config/mozilla-gateway-wifi-setup.service to /lib/systemd/system, edit it to set the correct paths for node and for the server code, and then enable the service with systemd:

$ sudo cp config/mozilla-gateway-wifi-setup.service /lib/systemd/system
$ sudo vi /lib/systemd/system/mozilla-gateway-wifi-setup.service # edit paths as needed
$ sudo systemctl enable mozilla-gateway-wifi-setup

At this point, the server will run each time you reboot. If you want to run it manually without rebooting, do this:

$ sudo systemctl start mozilla-gateway-wifi-setup

Any output from the server is sent to the systemd journal, and you can review it with:

$ sudo journalctl -u mozilla-gateway-wifi-setup

Add the -b option to the line above if you just want to view output from the current boot. Add -f if you want to watch the output live as you interact with the server.

If you want these journals to persist across reboots (you probably do) then ensure that the /var/log/journal/ directory exists:

$ sudo mkdir /var/log/journal

gateway-wifi-setup's People

Contributors

andrenatal avatar benfrancis avatar iamporus avatar kdavis-mozilla avatar mrstegeman avatar tilmankamp 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

Watchers

 avatar  avatar  avatar  avatar  avatar

gateway-wifi-setup's Issues

Captive portal doesn't respond to 'Go' key on keyboard

When connecting to a wireless network and I'm entering the password (on my iOS device), there is a button at the bottom right corner of the keyboard, I think it was called 'Go'. If I press that button, then it just dumps me back to the SSID list and doesn't connect. I have to press the 'Connect' button otherwise it doesn't connect.

Pressing 'Go' (or whatever it was called) should behave the same as pressing 'Connect'

Rpi Zero W wifi does not start

Hi there :)

Thanks a lot for this library!

I'm trying to run this on Raspberry Pi Zero W and the wifi doesn't want to startup:

When running:

sudo systemctl start mozilla-gateway-wifi-setup

and then

sudo journalctl -u mozilla-gateway-wifi-setup

This is the output:

Jun 25 19:28:09 raspberrypi run.sh[16862]: /home/pi/gateway-wifi-setup/run.sh: line 17: cd: /root/gateway-wifi-setup: No such file or directory

When I go to node directory and run:

sudo node index.js

Then I get this:

starting the wifi server
Running command: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}'
HTTP server listening
Running command: wpa_cli -iwlan0 list_networks
List Networks command executed: network id / ssid / bssid / flags
0	myWIFI	any	[CURRENT]
check 1
Running command: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}'
COMPLETED
WiFi connection found. resolving
resolved
start the gateway
Running command: systemctl start mozilla-iot-gateway
stop wifi setup
Running command: systemctl stop mozilla-gateway-wifi-setup
Error running command: { [Error: Command failed: /bin/sh -c systemctl start mozilla-iot-gateway
Failed to start mozilla-iot-gateway.service: Unit mozilla-iot-gateway.service not found.
]
  killed: false,
  code: 5,
  signal: null,
  cmd: '/bin/sh -c systemctl start mozilla-iot-gateway' }
Error starting Gateway: { [Error: Command failed: /bin/sh -c systemctl start mozilla-iot-gateway
Failed to start mozilla-iot-gateway.service: Unit mozilla-iot-gateway.service not found.
]
  killed: false,
  code: 5,
  signal: null,
  cmd: '/bin/sh -c systemctl start mozilla-iot-gateway' }
VWifi service stopped

I'm not sure why it is not taking on?

Any suggestions for troubleshoot would be appreciated.

Kind Regards :)

If no wifi adapter is available, then the setup fails

I tried to run our image on my Raspberry Pi 2 which doesn't have Wifi (but did have hard wired ethernet). I checked the gateway-wifi-setup-app.log file and it contained the following:

nvm version
0.33.1
node version
v7.10.1
npm version
4.2.0
Starting wifi service  ...

> [email protected] start /root/gateway-wifi-setup
> node index.js

starting the wifi server
check 1
Running command: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}'
HTTP server listening
Command wrote to stderr, assuming failure: Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

Error checking wifi on attempt 1 : Error: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}' output to stderr: Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

    at /root/gateway-wifi-setup/run.js:23:16
    at ChildProcess.exithandler (child_process.js:197:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:194:7)
    at maybeClose (internal/child_process.js:899:16)
    at Socket.<anonymous> (internal/child_process.js:342:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at Pipe._handle.close [as _onclose] (net.js:511:12)
check 2
Running command: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}'
Command wrote to stderr, assuming failure: Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

Error checking wifi on attempt 2 : Error: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}' output to stderr: Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

    at /root/gateway-wifi-setup/run.js:23:16
    at ChildProcess.exithandler (child_process.js:197:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:194:7)
    at maybeClose (internal/child_process.js:899:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
check 3
Running command: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}'
Command wrote to stderr, assuming failure: Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

After about 20 repeats, it then started to give:

check 20
Running command: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//
/;p;q}'
Command wrote to stderr, assuming failure: Failed to connect to non-global ctrl__
ifname: wlan0  error: No such file or directory

Error checking wifi on attempt 20 : Error: wpa_cli -iwlan0 status | sed -n -e '//
^wpa_state=/{s/wpa_state=//;p;q}' output to stderr: Failed to connect to non-gloo
bal ctrl_ifname: wlan0  error: No such file or directory

    at /root/gateway-wifi-setup/run.js:23:16
    at ChildProcess.exithandler (child_process.js:197:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:194:7)
    at maybeClose (internal/child_process.js:899:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
Giving up. No wifi available.
error starting wifi: undefined
startAP
Running command: iwlist wlan0 scan |sed -n -e '
  /Quality=/,/ESSID:/H
  /ESSID:/{
    g
    s/^.*Quality=\([0-9]\+\).*Encryption key:\([a-z]\+\).*ESSID:"\([^"]*\)".*$/\1 \2  \3/
    p
    s/.*//
    x
  }' |sort -nr
Command wrote to stderr, assuming failure: wlan0     Interface doesn't support scanning.


Scan attempt 1 failed: iwlist wlan0 scan |sed -n -e '
  /Quality=/,/ESSID:/H
  /ESSID:/{
    g
    s/^.*Quality=\([0-9]\+\).*Encryption key:\([a-z]\+\).*ESSID:"\([^"]*\)".*$/\1 \2  \3/
    p
    s/.*//
    x
  }' |sort -nr output to stderr: wlan0     Interface doesn't support scanning.


Will try again in 3 seconds.

that eventually gave up and then we get this:

Giving up. No scan results available.
Running command: ifconfig wlan0 10.0.0.1 && systemctl start hostapd && systemctl start dnsmasq
Error running command: { Error: Command failed: ifconfig wlan0 10.0.0.1 && systemctl start hostapd && systemctl start dnsmasq
SIOCSIFADDR: No such device
wlan0: ERROR while getting interface flags: No such device

    at ChildProcess.exithandler (child_process.js:205:12)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:194:7)
    at maybeClose (internal/child_process.js:899:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
  killed: false,
  code: 255,
  signal: null,
  cmd: 'ifconfig wlan0 10.0.0.1 && systemctl start hostapd && systemctl start dnsmasq' }
(node:779) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Command failed: ifconfig wlan0 10.0.0.1 && systemctl start hostapd && systemctl start dnsmasq
SIOCSIFADDR: No such device
wlan0: ERROR while getting interface flags: No such device

(node:779) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
handleCaptive /
skipping.
Running command: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}'
Command wrote to stderr, assuming failure: Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

Error: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}' output to stderr: Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

    at /root/gateway-wifi-setup/run.js:23:16
    at ChildProcess.exithandler (child_process.js:197:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:194:7)
    at maybeClose (internal/child_process.js:899:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Attermpting to connect to http://gateway.local then gave this output

handleCaptive /
skipping.
Running command: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}'
Command wrote to stderr, assuming failure: Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

Error: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}' output to stderr: Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

    at /root/gateway-wifi-setup/run.js:23:16
    at ChildProcess.exithandler (child_process.js:197:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:194:7)
    at maybeClose (internal/child_process.js:899:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

and the browser just spins.
Attempting to attach to gateway.local

Make "gateway.local" message a link

During first time setup there's a message which tells you to type gateway.local into your browser. It would be nice if this was a link so I don't have to type it in!

Would need testing in the captive portal UI to check it opens in a separate browser window (target=blank?).

Raspberry stretch error

I followed al the steps in the readme. Finally , I succeded in running the programm . It enters in the AP mode("No WiFi found , entering AP mode") , but no wifi appears.. then I manually configure the WiFi credentials , but I am not able to have internet connection until I reboot the pi. Can anyone help me ? Thanks.

If I press skip, it shouldn't leave the wlan0 interface setup

If I'm plugged in via hard wired ethernet, and I press SKIP in the Wifi setup, then it should leave the wlan0 interface unconfigured (i.e. no IP address). If I do ifconfig, I see this:

root@gateway:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.79  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 2001:569:fc60:8e00:bbaf:2cd5:1ba5:6aff  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::635e:a3c8:b0dc:df4c  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:cb:a2:c2  txqueuelen 1000  (Ethernet)
        RX packets 22478  bytes 1643969 (1.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 134  bytes 13384 (13.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 84  bytes 5728 (5.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84  bytes 5728 (5.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 10.0.0.1  netmask 255.0.0.0  broadcast 10.255.255.255
        ether b8:27:eb:9e:f7:97  txqueuelen 1000  (Ethernet)
        RX packets 775  bytes 117281 (114.5 KiB)
        RX errors 0  dropped 13  overruns 0  frame 0
        TX packets 297  bytes 77826 (76.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

and if I ping www.yahoo.com, then I see:

root@gateway:~# ping www.yahoo.com
PING www.yahoo.com (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1 (10.0.0.1): icmp_seq=1 ttl=64 time=0.063 ms
64 bytes from 10.0.0.1 (10.0.0.1): icmp_seq=2 ttl=64 time=0.067 ms
64 bytes from 10.0.0.1 (10.0.0.1): icmp_seq=3 ttl=64 time=0.045 ms
^C

which tells me that it's sending the packets to wlan0 rather than eth0. Due to the ping times, it tells me that it's not actually getting to network. Trying to add an add-on also fails.

Doing a wget to retrieve the list of addons fails:

pi@gateway:~$ wget https://raw.githubusercontent.com/mozilla-iot/addon-list/master/list.json
--2017-12-06 21:34:56--  https://raw.githubusercontent.com/mozilla-iot/addon-list/master/list.json
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 10.0.0.1
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|10.0.0.1|:443... failed: Connection refused.

route shows:

root@gateway:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.1.254   0.0.0.0         UG    202    0        0 eth0
10.0.0.0        0.0.0.0         255.0.0.0       U     0      0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0

If I do a reboot, then things seem to work properly.

Refused to Connect when trying to visit the ip address 192.168.220.1

I've followed every step in this document but I can't get it to display the wifi-setup page. I see my gateway network and I'm able to connect to it, but when I try to access the page to setup the wifi it says "192.168.220.1 refused to connect.".

Does anybody know what am I missing?

Thanks for your help.

Eddie.

Is this WiFi GW code used?

Hi,

I tested Gateway version 0.7 and the Gateway-0.7 does NOT match code in this repo.

I want to create a WiFi AP + Gateway and want to try / modify this code .

I know that router support is coming as part of GW release. If there is a development branch of Gateway that I can use then please advice. I would rather use main-stream design and contribute if possible.

Thanks

Running gateway.local issue

After connecting the raspberry pi 3 to the new network created and then going to a web browser and typing in "gateway.local", nothing seems to load.

General UI issues

Excerpted from here:

  • The font of the "Welcome" heading should be Zilla Slab and all other text Open Sans, to match the rest of first time setup
  • The list items showing WiFi network names should be less spaced out (gaps of about 10px) to match other lists in the UI
  • WiFi network names and input fields like the WiFi password field should be left aligned as per the mockup
  • Border radius of menu items and buttons should be 0.5rem (5px). (Note the rest of the gateway UI uses 10px as a base font size on body and rem for sizes everywhere else to make it possible to scale for different pixel densities).
  • The password entry UI should be vertically center aligned as per other similar UI, not just part way down the page.
  • The Mozilla IoT wordmark should ideally be removed from the enter password screen because it can overlap the input field when a keyboard comes up on mobile
  • The background-color of input fields should not match the background-color of buttons because that's confusing, it should be #c7d0d6 as per the mockup with #666666 for the placeholder text
  • The :hover and :active style on input fields etc. with a CSS transition is cute but it's inconsistent with the rest of the first time setup so I suggest removing it
  • The default tick box is very small to use on mobile, it would be better if the "Show password" tick box matched the ones in Settings, as per the mockups. Note this is implemented with a sprite (a bit of hack but necessary for touch interfaces)
  • I like the addition of the message which tells the user to re-connect to their own WiFi network. Can we make that 1.6rem (16px), Open Sans, and horizontally and vertically center aligned to match other similar messages in the UI? I've added a mockup (slide 7) to show this, with a new message (note that we can't assume that setup is taking place via the built-in access point):
  • Small nit: the /wifiSetup path of the setup URL is in camelCase which we're not using anywhere else. /wifi-setup might be better for consistency.
  • Add wifi icon next to hotspot name in password page
  • Add a proper message when user press skip

Remove old references to vaani, obsolete code and files

Excerpted from here:

A quick grep reveals some mentions of vaani still remaining:
/platforms/default.js
/templates/oauthSetup.hbs
/templates/status.hbs
/README.md
/package.json
/platform.js

There still seems to be some redundant code like the un-used audio code in EdisonYocto.js and default.js and some of the template files like status.hbs and oauthSetup.hbs. connecting.hbs seems to >point to a missing stylesheet style.css ? .gitignore mentions lots of files which have presumably been >removed.

No connected route for wifi network in AP mode

I am using Raspbian 10 on a Raspberry pi nano.

When platforms/default.js starts the AP, wlan0 initially has an autoconfig IP address (169.x). A few seconds later it gets changed to 192.168.220.1, but for some reason a "connected" route is not added to the routing table (for 192.168.220.0/24) meaning that devices on the wifi network cannot connect to the webserver. There is a connected route for the original autoconfig address.

I can get it to work correctly by modifying platforms/default.js as follows:

replace line: 'ifconfig wlan0 $IP; systemctl start hostapd; systemctl start dnsmasq',

with: 'ifconfig wlan0 $IP; systemctl start hostapd; systemctl start dnsmasq; route add -net 192.168.220.0/24 dev wlan0',

We shouldn't use a hard-coded IP address

I noticed that 10.0.0.1 is hard-coded throughout the codebase. This should be extracted into a constant.

I also think that 10.0.0.1 is a bad choice. Many organizations use 10.x.x.x networks and we could be causing conflicts if ethernet were plugged in with the same IP range.

I think that we should use a non-typical 192.168.x.x network, avoiding the low number ranges. Perhaps something like 192.168.200.0. 192.168.0.0 and 192.168.1.0 are common for APs.

My NetGear extender device uses 192.168.16.0

Generate ssid for AP dynamically

The server invokes hostapd service for starting the AP, which reads the ssid and other configurations from the hostapd.conf file (/etc/hostapd/hostapd.conf on Raspberry Pi).
This results in the same ssid for every AP running on multiple devices at my end.

One solution I came across is at WebThings Gateway implementation. The ssid generated there is WebThings_Gateway_XXXX, where WebThings_Gateway is just the prefix and XXXX being a fragment of the device's mac address. This seems to be implemented in the WebThings Gateway source but not here in this repo. Any concerning developer can help shed some light on this. If the support is already added somewhere (in a different repo), please provide a link or reference to the same. I'm more than willing to take up the task myself to add the feature in this repo.

If not implemented anywhere, here's how I'd go about implementing it.

  1. startAP() inside index.js would see a parameter named ssid_prefix.
  2. Inside wifi.js, where the implementation of startAP() is present, first create a file named hostapd.conf at /etc/hostapd/ with the content being standard parameters required for AP and the ssid created using the provided prefix and device mac_address.
  3. The actual creation of AP by invoking the system call.

For Edison, there would be a different approach.
Please let me know your suggestions on the implementation part. Any pointers in the right direction are much appreciated.

Blue screen after choosing sub domain

Im following the getting started guide
After part 5 "chose the sub domain" i got redirected successfully to the new sub domain.
Then i got stuck on a blue screen .
debugging i can see that there is 2 errors.

Uncaught SyntaxError: Unexpected token (

Standardize the iwlist scan regardless of driver/adapter

The result of iwlist scan can vary if one is using an external usb wifi adapter instead the internal wifi module from the rpi for example, and that can break the way the list is shown.

For example, when using a TP/Link wifi adapter, iwlist scan driver can return:
Quality=70/70 Signal level=-40/100 while the internal RPi Realtek driver returns Quality=70/70 Signal level=-40 dBm.

This difference affects the mechanism to order the list by the network which has the best signal, consequently breaking it.

TypeError: skip is not a function

When you click the skip button there's an error message in the console:

TypeError: skip is not a function
[Learn More]
wifi-setup:1:1
onclick
http://gateway.local/wifi-setup:1:1

It still seems to work though.

Wifi setup later?

If I skip the wifi setup initially, how can I set it up later? I can't find that option in the menu structure.

setup fails when there is no wifi adapter

If I try to boot the latest wifi setup code on a Raspberry Pi 2 which has no wifi adapter, then I get the following error:

nvm version
0.33.1
node version
v7.10.1
npm version
4.2.0
Starting wifi service  ...

> [email protected] start /root/gateway-wifi-setup
> node index.js

starting the wifi server
Running command: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}'
HTTP server listening
Command wrote to stderr, assuming failure: Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

Error checking wifi adapter presence. Start the gateway and then shutdown the wifi service.. Error: wpa_cli -iwlan0 status | sed -n -e '/^wpa_state=/{s/wpa_state=//;p;q}' output to stderr: Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

    at /root/gateway-wifi-setup/run.js:23:16
    at ChildProcess.exithandler (child_process.js:197:7)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:194:7)
    at maybeClose (internal/child_process.js:899:16)
    at Socket.<anonymous> (internal/child_process.js:342:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
    at Pipe._handle.close [as _onclose] (net.js:511:12)
start the gateway
Running command: systemctl start mozilla-iot-gateway
stop wifi setup
Running command: systemctl stop mozilla-gateway-wifi-setup

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.