Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wifi monitor doesnt start if called by anything on startup #3669

Open
freeman1216 opened this issue Dec 8, 2024 · 2 comments
Open

Wifi monitor doesnt start if called by anything on startup #3669

freeman1216 opened this issue Dec 8, 2024 · 2 comments

Comments

@freeman1216
Copy link

freeman1216 commented Dec 8, 2024

Expected behavior

If called on startup should execute callback funtion accordingly

Actual behavior

The file gets executed but the callback never called
If called using serial works fine

Test code

init.lua

uart.setup(0,9600,8,uart.PARITY_NONE,uart.STOPBITS_1,1)

tmr.create():alarm(1000,tmr.ALARM_SINGLE,function ()
  dofile("wifi.lua")
end)

wifi.lua

Wifi_table = {}
wifi.monitor.start(13, 0x80,function (pkt)
    if not Wifi_table[pkt.bssid_hex] then
        if  pkt[0] ~= nil then
          Wifi_table[pkt.bssid_hex] = pkt[0]
          uart.write(0,pkt.bssid_hex .. "," .. pkt[0].."\r\n")
        else
          Wifi_table[pkt.bssid_hex]="blank"
          uart.write(0,pkt.bssid_hex .. "," .. "blank".."\r\n")
        end
    end
end
)


local cleartimer = tmr.create()
cleartimer:alarm(4000000, tmr.ALARM_AUTO,function ()
  Wifi_table = {}
end)

NodeMCU startup banner

NodeMCU 3.0.0.0
branch: release
commit: 36cbf9f
release: 3.0.0-release_20211229 +25
release DTS: 202402250804
SSL: false
build 2024-12-07 03:17 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)
build type: float
LFS: 0x0 bytes total capacity
modules: bit,file,gpio,node,ow,tmr,uart,wifi,wifi_monitor

Hardware

ESP8266 Nodemcu v2

@freeman1216
Copy link
Author

freeman1216 commented Dec 8, 2024

Found a workaround
You need to set wifi mode to station first
init.lua

uart.setup(0,9600,8,uart.PARITY_NONE,uart.STOPBITS_1,1)

wifi.setmode(wifi.STATION)

tmr.create():alarm(1000,tmr.ALARM_SINGLE,function ()
  dofile("wifi.lua")
end)

Same thing happens if wifi.sta.getap() is called during startup but at least it fails with SOFT_AP mode error, found workaround this way
Guess this means wifi.monitor.start() just fails without an error which is bad

@marcelstoer
Copy link
Member

@pjsg What's your take on this? Is documenting that the WiFi mode should be set first good enough?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants