SlimeVR / SlimeVR-Tracker-ESP

SlimeVR tracker firmware for ESP32/ESP8266 and different IMUs
Apache License 2.0
868 stars 298 forks source link

Add `GET WIFISCAN` and base64 WiFi credential commands #262

Closed nekomona closed 1 year ago

nekomona commented 1 year ago

This PR add GET WIFISCAN command to initiate a blocking scan, retrieving what hotspot could be seen by the trackers during provisioning. Could avoid connecting to a 5G hotspot, misspelling, and might help future fancy provisioning.

The result would be printed in the format below:

[INFO ] [SerialCommands] [WSCAN] Scanning for WiFi networks...
[INFO ] [SerialCommands] [WSCAN] Found <Count> networks:
[INFO ] [SerialCommands] [WSCAN] 0:\t<SSID0 Length>\t<SSID0>\t(<RSSI0>)\t<OPEN/PASS>
[INFO ] [SerialCommands] [WSCAN] 1:\t<SSID1 Length>\t<SSID1>\t(<RSSI1>)\t<OPEN/PASS>

In addition, since CmdParser couldn't deal with double quotes in SSID / Password, a base64 version for serial provisioning is added (SET BWIFI <B64SSID> <B64PASS>). Everything is the same except encoded in base64 to avoid double quote in the command.

Currently blocked by #256

ImUrX commented 1 year ago

btw is it necessary for it to be blocking? I have no idea if you can just print it when you get the scan data

nekomona commented 1 year ago

I've tried the non-blocking one during the first commit, but it always returns as failed. There should be somewhere buggy but can't locate them. The blocking scan will timeout server connection but reconnects once finished, and it won't break WiFi connection. Since we only need to scan during provisioning, imo the blocking one would be enough.