whitecatboard / Lua-RTOS-ESP32

Lua RTOS for ESP32
Other
1.2k stars 221 forks source link

APSTA not well supported? #332

Closed guo652917087 closed 4 years ago

guo652917087 commented 4 years ago

HI, The functions implemented in APSTA mode are not well supported. Can't I set the SSID of the AP separately? net.wf.setup (net.wf.mode.APSTA, config.net.wifi.ssid, config.net.wifi.pass, net.wf.powersave.NONE, 0, false)
This interface has no AP SSID and password Set up.

the0ne commented 4 years ago

Try to call this before net.wf.setup(net.wf.mode.STA, ssid, password, [ip, mask, gw, dns1, dns2, powersave, channel, hidden]) then call net.wf.setup(net.wf.mode.APSTA, ssid, password, [powersave, channel, hidden])

guo652917087 commented 4 years ago

Hi, STA mode is working, but AP hotspot does not find "esp32-0001".

The network startup script is as follows:

if (config.wifi) then config.net.wifi = config.data.wifi end

if (config.ethernet) then config.net.ethernet = config.data.ethernet end

-- Network setup if (config.wifi) then print("Starting wifi ...")

net.wf.setup( net.wf.mode.AP, "esp32-0001", "88888888" )

net.wf.setup(
    net.wf.mode.APSTA, config.net.wifi.ssid, config.net.wifi.pass, net.wf.powersave.NONE,0,false    
)

net.wf.start()

end

if (config.ethernet) then print("Starting ethernet ...") net.en.setup( config.net.ethernet.ip, config.net.ethernet.mask, config.net.ethernet.gw, config.net.ethernet.dns1, config.net.ethernet.dns2 ) net.en.start() end

the0ne commented 4 years ago

Note: corrected order in my comment above

the0ne commented 4 years ago

I verified to be able to enter APSTA mode as follows:

net.wf.setup(net.wf.mode.STA, config.net.wifi.ssid, config.net.wifi.pass, net.wf.powersave.MODEM)
net.wf.setup(net.wf.mode.APSTA, "esp32-0001", "88888888", net.wf.powersave.MODEM)

Reason for the order is that the STA implicitly defines the required wifi channel so it must be done first.

guo652917087 commented 4 years ago

Haha, according to your modification, APSTA mode works. thank you