Skip to content
This repository has been archived by the owner on Oct 19, 2019. It is now read-only.

Improved WiFi setup #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Improved WiFi setup #5

wants to merge 4 commits into from

Conversation

zehnm
Copy link
Member

@zehnm zehnm commented Oct 14, 2019

This should fix, or at least improve, the initial WiFi setup.

  • SSIDs containing spaces are handled correctly and don't corrupt the configuration files
    • Shell script calls from PHP are properly escaped
  • Replaced wpa_supplicant scanning with iw for reliable network scanning
    • The output parsing is more complex with awk. The patterns are defined in an external progfile.

The issues with wpa_cli scan & wpa_cli scan_results were manifold:

  • Initial network configuration failed due to missing /etc/wpa_supplicant directory

  • Initial network scan at first boot never worked for me due to invalid wpa_supplicant state.
    Error: Failed to connect to non-global ctrl_ifname: (nil) error: No such file or directory
    This was triggered from:

      systemctl status wpa_supplicant.service
      ● wpa_supplicant.service - WPA supplicant
        Loaded: bad-setting (Reason: Unit wpa_supplicant.service has a bad unit file setting.)
        Active: inactive (dead)
      systemd[1]: /usr/lib/systemd/system/wpa_supplicant.service:7: Invalid bus name, ignoring:
      systemd[1]: wpa_supplicant.service: Service is of type D-Bus but no D-Bus service name has been specified. Refusing.
    
  • Subsequent scanning after a WiFi connection has been established was still unstable.
    Sometimes the wrong interface p2p-dev-wlan0 was used.

  • Scan results were not always available, or only a few networks were retrieved

I wasn't able to fix everything and the proposed fixes for the Failed to connect to non-global ctrl_ifname error varied greatly. Therefore I decided to replace it with iw wlan0 scan.

Cosmetic changes:

  • Fixed typos in web pages
  • Suppress error messages in delete commands

@martonborzak @nklerk could you please test the setup and WiFi scanning on your hardware (I'm not sure who else has one)?
I don't want to make things worse since I don't have the real thing to test with...

- attempted fixes for 'network scan failed' errors:
  - make sure directory exists to create wpa_supplicant-wlan0.conf
  - force wlan0 interface in network scan
  - wait 3s after initiating network scan before retrieving result
- make sure directories /mnt/boot exist for wifi-copy-config to work
- suppress error messages when trying to delete inexistent files
- use tab delimiter to parse wpa_cli scan_results
- properly escape wifi_network_setup.sh call from php
- `wpa_cli -i wlan0 scan` didn't work at initial boot
- `iw wlan0 scan` always works
@martonborzak
Copy link
Member

Thanks @zehnm!
I'll test the setup (probably in a couple of days) and will report back.

@martonborzak martonborzak self-assigned this Oct 14, 2019
@martonborzak
Copy link
Member

Create dedicated project for webserver & shell scripts.

We have a separate repository for the web things, could you move the files there @zehnm ?
https://github.com/YIO-Remote/web-configurator

@zehnm
Copy link
Member Author

zehnm commented Oct 14, 2019

Sure, I will get in contact with @nklerk once we are both online to coordinate.
We should probably also discuss a few things on how to proceed with 'system services' (currently mostly shell scripts).
It would be great to have the remote app running as non-root and take special care about all services requiring root access with a well defined API. I have an itch trying out Go ;-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants