Skip to content

Commit 5951e58

Browse files
committed
Switch enduser_setup back to automatic mode since manual was unstable
1 parent 6d258f6 commit 5951e58

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

ESP Firmware/src/init.lua

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,26 +99,23 @@ end
9999
uart.setup(0, 115200, 8, uart.PARITY_NONE, uart.STOPBITS_1, 0)
100100
uart.on('data', "\n", handle_uart, 0)
101101

102-
-- Create AP for configuration
103-
wifi.ap.config({ssid = 'hackAIR-'..node.chipid(), pwd = 'hackAIR-'..node.chipid()})
104-
105-
-- Manual mode
106-
enduser_setup.manual(true)
107-
enduser_setup.start(
108-
function()
109-
-- WiFi information is stored in wifi.sta.config so we don't have
110-
-- to do anything special here.
111-
112-
-- Print debug info
113-
print('Connected to wifi as:' .. wifi.sta.getip())
114-
tmr.create()::alarm(10000, tmr.ALARM_SINGLE, function()
115-
print('Turning off AP')
116-
enduser_setup.stop()
117-
end)
118-
end,
119-
function(err, str)
120-
print('enduser_setup: Err #' .. err .. ': ' .. str)
121-
end)
102+
ssid, password, bssid_set, bssid = wifi.sta.getconfig()
103+
if ssid == '' then
104+
print('No WiFi configuration stored, going into AP mode')
105+
enduser_setup.start(
106+
function()
107+
-- Print debug info
108+
ssid, password, bssid_set, bssid = wifi.sta.getconfig()
109+
print('Connected to '.. ssid .. ' with password ' .. password .. ' as: ' .. wifi.sta.getip())
110+
end,
111+
function(err, str)
112+
print('enduser_setup: Err #' .. err .. ': ' .. str)
113+
end
114+
)
115+
else
116+
wifi.setmode(wifi.STATION)
117+
wifi.sta.connect()
118+
end
122119

123120
-- Display a warning message to the prompt
124121
print('hackAir ESP Firmware')

0 commit comments

Comments
 (0)