I thought I would share this as it may be useful to some. I have had many problems in the past with configuring wifi settings whilst the unit is in AP mode. I have experienced very sluggish behaviour of the AP web interface and also the unit reconnecting to a pre-configured network without warning, all this making configuring a new wifi network a real PITA. I have tried many different builds and all seem to behave similar.
All the units I have have a fixed IP address whilst on the wifi network and this seems to be the cause of the problems whist in AP mode. Here are the rules im now using on an SONOFF POW to overcome the problem. I can manually enter AP mode with a long press of the button.
It would also be nice to have the following in future Mega builds
1. An on the fly method to turn off SOME Tasks/devices before entering AP mode as this also increases the AP web interface response time.
2. An event to signify the unit is in AP or STN mode.
Code: Select all
//***On Boot SONOFF POW***
On System#Boot do
GPIO,12,1 //Turn on Red LED
timerSet,2,0 //Disable timer 2 (pulse LED)
endon
//***WiFi Connected***
on WiFi#Connected do
GPIO,15,1 //Turn on Blue LED
GPIO,12,1 //Turn on Red LED
timerSet,2,0 //Disable timer 2 (pulse LED)
endon
//***WiFi Disconnected***
on WiFi#Disconnected do
GPIO,15,0 //Turn off Blue LED
endon
//***Set to AP mode with a 5 second key press***
on switch#switch=10 do
//Long press from state 1-->0
wifiSSID A //Change Primary SSID
ip 0.0.0.0 //Change static IP
WifiAPMode //Force into AP mode
GPIO,15,0 //Turn off Blue LED
GPIO,12,1 //Turn on Red LED
timerSet,2,2 //Timer 2 (pulse LED)
save //Save settings to flash
endon
//Toggle red LED to signify AP mode:
On Rules#Timer=2 do
Pulse,12,1,700 //Pulse red LED on pin 12
timerSet,2,2 //Repeat after 1 seconds
endon