epidose icon indicating copy to clipboard operation
epidose copied to clipboard

Support Wi-Fi Protected Setup

Open dspinellis opened this issue 5 years ago • 4 comments

Allow the user to initiate it be pressing a button on Epidose.

dspinellis avatar Aug 18 '20 08:08 dspinellis

  • [ ] A separate daemon will wait for the WiFi connect button to be pressed
  • [ ] It then initiates the WPS connection procedure
  • [ ] Daemon must cooperate with the Epidose WiFi on/off locking protocol

dspinellis avatar Sep 23 '20 12:09 dspinellis

Then here we need something to this line to automate this configuration (Ansible)?

    - name: support Wi-Fi Protected Setup
      shell:
        cmd: |
          nohup ./wps_button 0<&- &> /var/log/wps_daemon_log &

where the wps_button does something like this:

#!/bin/bash

# Turn on the amber blinking on the WPS LED
echo timer > /sys/devices/platform/leds-gpio/leds/netgear:orange:wps/trigger

# only run if there's no current wifi connection
if  ! ifconfig wlan0 | grep -q "inet addr:" ; then
       # grab AP's that support WPS, sort by strength and select the strongest 
        wpa_cli scan_results | grep WPS | sort -r -k3 | awk 'END{print $NF}'  >/tmp/wifi
        read ssid < /tmp/wifi
        wpa_cli wps-pbc $ssid
	dhclient wlan0
fi

# Wait for the WPS timeout
sleep 120

# Turn off the amber blinking of the WPS LED
echo none > /sys/devices/platform/leds-gpio/leds/netgear:orange:wps/trigger

If there is more than one device in the network then which network should we connect to? As an initial idea, I have selected the one with the strongest signal.

stefanos1316 avatar Sep 23 '20 16:09 stefanos1316

Seems close. Will the nohup command survive reboots? For the LED you need to use device_io.py. Have you tested it?

dspinellis avatar Sep 23 '20 17:09 dspinellis

Not sure about nohup, but I think we can add the above script inside the /etc/rc.local.

I haven't received the device yet or did you meant that I can check the device_io.py module on my current RPi device?

stefanos1316 avatar Sep 23 '20 17:09 stefanos1316