Assume that you have an IoT device that only has WLAN connectivity. Now this device should operate using a given WLAN connection. Now the task is to configure the device and tell him which SSID and password to use. Now the question is how to achieve this given that WLAN is the only way of communication. I thought I would be smart to create an Android app that starts a hostspot with credentials know to the IoT device. Under this hotspot it would also serve a REST API where the device could read configuration from.
Something like: SSID = "MyIOTConfig", Password = "NotSuperSecret"
The device would look for such a WLAN, connect to it and read the real WLAN credentials. So as a user I would open the app, enter the WIFI credentials click a button and then the Android App would start the config HotSpot and spin up a local web server. The IoT would detect the Hotspot and send a request to the REST endpoint and thereby get the credentials of the WIFI.
No this all sounded great to me until I realized that the methods to create a WIFI hotspot in Android are deprecated and supported for API level >= 26.
For API level >= 26 I can start a hotspot using startLocalOnlyHotspot
but the SSID is hardcoded to something random on the device. So for this purpose this seems completely useless (I generally don't get what purpose it has to start a WIFI with a SSID and password knowbody else knows).
My question now is, what option do I have with Android to do something like this? What is the intention from Google in Android? What is generally the idea to configure the WLAN credentials on an IoT device that can only talk over WLAN?
The only thing coming into my mind would be to start and stop this LocalOnlyHotspot in a pattern to communicate the credentials (e.g. send in Morse code by turing the WIFI on and off for short and long time framews). But that's like broadcasting it to everybody once somebody understands the pattern I use. And it sounds like "SmartConfig" , where we share the credentials plain-text, in best case with a shared secret.
Side question: What is the purpose of LocalOnlyHotspot?
question from:
https://stackoverflow.com/questions/65892186/how-to-configure-wifi-connection-of-iot-device-using-an-android-app 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…