logo elektroda
logo elektroda
X
logo elektroda

[Solved] WiFiState Command States and Short Beep Automation in OpenBK7231 Autoexec Script

150219v8 369 15
ADVERTISEMENT
  • #1 21571285
    150219v8
    Level 2  
    Hi all,
    1.
    I found anywhere (But not in obk documentation) the useful autoexec/script command
    waitFor WiFiState 4
    Why is there no documentation about wifistate command? Or did I search in the wrong place?
    What are the other States 0 1 2 3 and others?

    2. I connected a buzzer to a port.
    I want to listen to a short beep (about 100ms) when wifi is connected.
    But I could solve it only 1sek long.
    I did this to autoexec:
    addChangeHandler Channel1 == 1 addRepeatingEvent 1 1 setChannel 1 0
    waitFor WiFiState 4
    Power2 1

    Is that beep shorter possible?


    .
  • ADVERTISEMENT
  • #2 21579771
    max4elektroda
    Level 20  
    For the short beep, you might try something like

    alias buzz backlog <set buzzer on>; delay_ms 100; <set buzzer off>

    then calling "buzz" to hear a 100 ms buzzer

    <set ...> needs to be something like

    setPinRole X AlwaysHigh
    setPinRole X AlwaysLow
  • Helpful post
    #3 21580165
    p.kaczmarek2
    Moderator Smart Home
    Sorry, WiFi state is indeed not documented yet, but it corresponds to:
    Code: C / C++
    Log in, to see the code



    max4elektroda wrote:

    alias buzz backlog <set buzzer on>; delay_ms 100; <set buzzer off>

    Sadly this will not work at the moment, but it should work in the future. We don't have delay_s in the backlog yet. We usually do delay with addRepeatingEvent
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
    Helpful post? Buy me a coffee.
  • #4 21583096
    max4elektroda
    Level 20  
    p.kaczmarek2 wrote:

    Sadly this will not work at the moment, but it should work in the future.


    @150219v8 Which device do you use?
    I tried to implement this micro second delay "delay_ms".

    I limited it to 500ms, not knowing, if this "waiting" might have side effects.

    If you have an git account, you can try to download the "artifact" for your device here:
    https://github.com/MaxineMuster/OpenBK7231T_App/actions/runs/15739205979

    Else I can upload the version for you so you can test.

    For now I only tested this on an ESP32:

    alias buzz backlog setPinRole 15 AlwaysHigh; delay_ms 100; setPinRole 15 AlwaysLow


    Then command "buzz" looks promising:


    WiFiState Command States and Short Beep Automation in OpenBK7231 Autoexec Script
  • ADVERTISEMENT
  • #5 21583119
    p.kaczmarek2
    Moderator Smart Home
    Hmm, interesting hack:
    WiFiState Command States and Short Beep Automation in OpenBK7231 Autoexec Script
    I would personally just clamp the number to 500 instead of skipping...
    Well, it can certainly work, however... when ran from, for example, a repeating event or change handler, doesn't it break whole main thread for 500ms?
    Helpful post? Buy me a coffee.
  • #6 21583154
    max4elektroda
    Level 20  
    p.kaczmarek2 wrote:
    doesn't it break whole main thread for 500ms?
    That's my fear, too, therefore the limit as a quick hack.
    A better way might be to put command execution into a separate thread, so this could be "pausing" for as long as it might want (even seconds) without affecting the main thread...
    But I have no clue if this is possible at all.
  • #7 21583157
    p.kaczmarek2
    Moderator Smart Home
    Correct solution is to create OBK script "thread" (not a real RTOS thread) and do execution mechanism for backlog there once again from scratch.
    Helpful post? Buy me a coffee.
  • #8 21583170
    max4elektroda
    Level 20  
    If there is a faster loop (quick ticks??) we might also store a ticks value for "now + <X> ms" and "suspend" command, checking value from time to time and "resume" command, if value is reached.
    But I'm not so deep into this part of OBK, so I took the easy way ...

    Added after 1 [minutes]:

    Too late ...

    Added after 1 [hours] 3 [minutes]:

    Just tried to see if if blocks main loop - set limit to 5.000 ms - no problem on RTL with 5 seconds:

    alias buzz5k backlog setPinRole 18 AlwaysHigh; delay_ms 5000; setPinRole 18 AlwaysLow


    Info:MAIN:Time 342, idle 0/s, free 4287368, MQTT 0(21), bWifi 1, secondsWithNoPing 272, socks 2/21 
    Info:MAIN:Time 343, idle 0/s, free 4287832, MQTT 0(21), bWifi 1, secondsWithNoPing 273, socks 2/21 
    Info:MAIN:Time 344, idle 0/s, free 4287832, MQTT 0(21), bWifi 1, secondsWithNoPing 274, socks 2/21 
    Debug:API:POST to api/cmnd
    Debug:CMD:cmd [buzz5k]
    Debug:CMD:cmd [backlog setPinRole 18 AlwaysHigh; delay_ms 5000; setPinRole 18 AlwaysLow]
    Debug:CMD:backlog [setPinRole 18 AlwaysHigh; delay_ms 5000; setPinRole 18 AlwaysLow]
    Debug:CMD:cmd [setPinRole 18 AlwaysHigh]
    Debug:CMD:cmd [delay_ms 5000]
    Debug:CMD:CMD_Delay_ms: CMD delay 5000 ms
    Debug:CFG:CFG_CalcChecksum: header size 4, total size 3584, rem size 3580
    Info:MAIN:Time 345, idle 0/s, free 4274800, MQTT 0(21), bWifi 1, secondsWithNoPing 275, socks 3/21 
    Info:MAIN:Time 346, idle 0/s, free 4274464, MQTT 0(21), bWifi 1, secondsWithNoPing 276, socks 3/21 
    Info:MAIN:Time 347, idle 0/s, free 4274800, MQTT 0(21), bWifi 1, secondsWithNoPing 277, socks 3/21 
    Info:MAIN:Time 348, idle 0/s, free 4274800, MQTT 0(21), bWifi 1, secondsWithNoPing 278, socks 3/21 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 349, idle 0/s, free 4274800, MQTT 0(22), bWifi 1, secondsWithNoPing 279, socks 3/21 
    Debug:CMD:cmd [setPinRole 18 AlwaysLow]
    Debug:CMD:backlog executed 3
    Info:CMD:[WebApp Cmd 'buzz5k' Result] OK
    Debug:CFG:CFG_CalcChecksum: header size 4, total size 3584, rem size 3580
    Info:MAIN:Time 350, idle 0/s, free 4287664, MQTT 0(22), bWifi 1, secondsWithNoPing 280, socks 2/21 
    Info:MAIN:Time 351, idle 0/s, free 4287496, MQTT 0(22), bWifi 1, secondsWithNoPing 281, socks 2/21 
    Info:MAIN:Time 352, idle 0/s, free 4285608, MQTT 0(22), bWifi 1, secondsWithNoPing 282, socks 3/21 
    Info:MAIN:Time 353, idle 0/s, free 4285608, MQTT 0(22), bWifi 1, secondsWithNoPing 283, socks 3/21


    Didn't check levels, but 344 to 349 seems o.k. for setting the output after 5000 ms.

    Same on ESP32:

    alias buzz5k backlog setPinRole 15 AlwaysHigh; delay_ms 5000; setPinRole 15 AlwaysLow


    Info:MAIN:Time 120, idle 0/s, free 195060, MQTT 0(7), bWifi 1, secondsWithNoPing 54, socks 0/0 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 121, idle 0/s, free 194340, MQTT 0(8), bWifi 1, secondsWithNoPing 55, socks 0/0 
    Debug:API:POST to api/cmnd
    Debug:CMD:cmd [buzz5k]
    Debug:CMD:cmd [backlog setPinRole 15 AlwaysHigh; delay_ms 5000; setPinRole 15 AlwaysLow]
    Debug:CMD:backlog [setPinRole 15 AlwaysHigh; delay_ms 5000; setPinRole 15 AlwaysLow]
    Debug:CMD:cmd [setPinRole 15 AlwaysHigh]
    Debug:CMD:cmd [delay_ms 5000]
    Debug:CMD:CMD_Delay_ms: CMD delay 5000 ms
    Debug:CFG:CFG_CalcChecksum: header size 4, total size 3584, rem size 3580
    Info:MAIN:Time 122, idle 0/s, free 182936, MQTT 0(8), bWifi 1, secondsWithNoPing 56, socks 0/0 
    Info:MAIN:Time 123, idle 0/s, free 182592, MQTT 0(8), bWifi 1, secondsWithNoPing 57, socks 0/0 
    Info:MAIN:Time 124, idle 0/s, free 181996, MQTT 0(8), bWifi 1, secondsWithNoPing 58, socks 0/0 
    Info:MAIN:Time 125, idle 0/s, free 182956, MQTT 0(8), bWifi 1, secondsWithNoPing 59, socks 0/0 
    Info:MAIN:Time 126, idle 0/s, free 182784, MQTT 0(8), bWifi 1, secondsWithNoPing 60, socks 0/0 
    Debug:CMD:cmd [setPinRole 15 AlwaysLow]
    Debug:CMD:backlog executed 3
    Info:CMD:[WebApp Cmd 'buzz5k' Result] OK
    Debug:CFG:CFG_CalcChecksum: header size 4, total size 3584, rem size 3580
    Info:MAIN:Time 127, idle 0/s, free 195080, MQTT 0(8), bWifi 1, secondsWithNoPing 61, socks 0/0 
    Info:MAIN:Time 128, idle 0/s, free 194908, MQTT 0(8), bWifi 1, secondsWithNoPing 62, socks 0/0 
    
    
  • #9 21583254
    p.kaczmarek2
    Moderator Smart Home
    I am testing another idea. Maybe we could just convert backlog string to script file (scriptFile_t) by replacing ; with newlines.

    WiFiState Command States and Short Beep Automation in OpenBK7231 Autoexec Script
    Helpful post? Buy me a coffee.
  • #10 21583271
    max4elektroda
    Level 20  
    Completely removed limit, seems to work without problems with the devices I have at hand.

    ESP32 with 15.000ms:

    Info:MAIN:Time 58, idle 0/s, free 194856, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 0/0 
    Info:MAIN:Time 59, idle 0/s, free 194684, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 0/0 
    Debug:API:POST to api/cmnd
    Debug:CMD:cmd [buzz15k]
    Debug:CMD:cmd [backlog setPinRole 18 AlwaysHigh; delay_ms 15000; setPinRole 18 AlwaysLow]
    Debug:CMD:backlog [setPinRole 18 AlwaysHigh; delay_ms 15000; setPinRole 18 AlwaysLow]
    Debug:CMD:cmd [setPinRole 18 AlwaysHigh]
    Debug:CMD:cmd [delay_ms 15000]
    Debug:CMD:CMD_Delay_ms: CMD delay 15000 ms
    Debug:CFG:CFG_CalcChecksum: header size 4, total size 3584, rem size 3580
    Info:MAIN:Time 60, idle 0/s, free 182596, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 0/0 
    Info:MAIN:Time 61, idle 0/s, free 182596, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 0/0 
    Info:MAIN:Time 62, idle 0/s, free 182424, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 0/0 
    Info:MAIN:Time 63, idle 0/s, free 182596, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 0/0 
    Info:MAIN:Time 64, idle 0/s, free 182768, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 0/0 
    Info:MAIN:Time 65, idle 0/s, free 182400, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 0/0 
    Info:MAIN:Time 66, idle 0/s, free 182596, MQTT 0(4), bWifi 1, secondsWithNoPing -1, socks 0/0 
    Info:MAIN:Time 67, idle 0/s, free 182464, MQTT 0(4), bWifi 1, secondsWithNoPing 1, socks 0/0 
    Info:MAIN:Time 68, idle 0/s, free 182940, MQTT 0(4), bWifi 1, secondsWithNoPing 2, socks 0/0 
    Info:MAIN:Time 69, idle 0/s, free 183112, MQTT 0(4), bWifi 1, secondsWithNoPing 3, socks 0/0 
    Info:MAIN:Time 70, idle 0/s, free 182940, MQTT 0(4), bWifi 1, secondsWithNoPing 4, socks 0/0 
    Info:MAIN:Time 71, idle 0/s, free 182768, MQTT 0(4), bWifi 1, secondsWithNoPing 5, socks 0/0 
    Info:MAIN:Time 72, idle 0/s, free 182424, MQTT 0(4), bWifi 1, secondsWithNoPing 6, socks 0/0 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 73, idle 0/s, free 182596, MQTT 0(5), bWifi 1, secondsWithNoPing 7, socks 0/0 
    Info:MAIN:Time 74, idle 0/s, free 182596, MQTT 0(5), bWifi 1, secondsWithNoPing 8, socks 0/0 
    Debug:CMD:cmd [setPinRole 18 AlwaysLow]
    Debug:CMD:backlog executed 3
    Info:CMD:[WebApp Cmd 'buzz15k' Result] OK
    Debug:CFG:CFG_CalcChecksum: header size 4, total size 3584, rem size 3580
    Info:MAIN:Time 75, idle 0/s, free 194724, MQTT 0(5), bWifi 1, secondsWithNoPing 9, socks 0/0 
    Info:MAIN:Time 76, idle 0/s, free 194604, MQTT 0(5), bWifi 1, secondsWithNoPing 10, socks 0/0 


    Same on RTL87X0C:

    Info:MAIN:Time 33, idle 0/s, free 4288072, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 2/21 
    Info:MAIN:Time 34, idle 0/s, free 4288072, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 2/21 
    Debug:API:POST to api/cmnd
    Debug:CMD:cmd [buzz15k]
    Debug:CMD:cmd [backlog setPinRole 18 AlwaysHigh; delay_ms 15000; setPinRole 18 AlwaysLow]
    Debug:CMD:backlog [setPinRole 18 AlwaysHigh; delay_ms 15000; setPinRole 18 AlwaysLow]
    Debug:CMD:cmd [setPinRole 18 AlwaysHigh]
    Debug:CMD:cmd [delay_ms 15000]
    Debug:CMD:CMD_Delay_ms: CMD delay 15000 ms
    Debug:CFG:CFG_CalcChecksum: header size 4, total size 3584, rem size 3580
    Info:MAIN:Time 35, idle 0/s, free 4274904, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Info:MAIN:Time 36, idle 0/s, free 4274904, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Info:MAIN:Time 37, idle 0/s, free 4274904, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Info:MAIN:Time 38, idle 0/s, free 4274736, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Info:MAIN:Time 39, idle 0/s, free 4274904, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Info:MAIN:Time 40, idle 0/s, free 4273016, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 4/21 
    Info:MAIN:Time 41, idle 0/s, free 4274904, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Info:MAIN:Time 42, idle 0/s, free 4275072, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Info:MAIN:Time 43, idle 0/s, free 4274904, MQTT 0(2), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 44, idle 0/s, free 4274904, MQTT 0(3), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Info:MAIN:Time 45, idle 0/s, free 4275072, MQTT 0(3), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Info:MAIN:Time 46, idle 0/s, free 4274904, MQTT 0(3), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Info:MAIN:Time 47, idle 0/s, free 4274736, MQTT 0(3), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Info:MAIN:Time 48, idle 0/s, free 4273000, MQTT 0(3), bWifi 1, secondsWithNoPing -1, socks 4/21 
    Info:MAIN:Time 49, idle 0/s, free 4275072, MQTT 0(3), bWifi 1, secondsWithNoPing -1, socks 3/21 
    Debug:CMD:cmd [setPinRole 18 AlwaysLow]
    Debug:CMD:backlog executed 3
    Info:CMD:[WebApp Cmd 'buzz15k' Result] OK
    Debug:CFG:CFG_CalcChecksum: header size 4, total size 3584, rem size 3580
    Info:MAIN:Time 50, idle 0/s, free 4287936, MQTT 0(3), bWifi 1, secondsWithNoPing -1, socks 2/21 
    Info:MAIN:Time 51, idle 0/s, free 4287936, MQTT 0(3), bWifi 1, secondsWithNoPing -1, socks 2/21 
    Info:MAIN:Time 52, idle 0/s, free 4287936, MQTT 0(3), bWifi 1, secondsWithNoPing -1, socks 2/21 
    Info:MAIN:Time 53, idle 0/s, free 4287768, MQTT 0(3), bWifi 1, secondsWithNoPing -1, socks 2/21 


    Added after 6 [minutes]:

    p.kaczmarek2 wrote:
    Maybe we could just convert backlog string to script file (scriptFile_t) by replacing ; with newlines.

    Will this work with an "alias", too?

    While thinking about this, I only tested alias use, not in command only.
    But why should anyone do a "delay" outside an alias or "backlog"??

    O.k., let's try:

    Info:MAIN:Time 520, idle 0/s, free 4287600, MQTT 0(32), bWifi 1, secondsWithNoPing 451, socks 2/21 
    Info:MAIN:Time 521, idle 0/s, free 4287768, MQTT 0(32), bWifi 1, secondsWithNoPing 452, socks 2/21 
    Debug:API:POST to api/cmnd
    Debug:CMD:cmd [delay_ms 15000]
    Debug:CMD:CMD_Delay_ms: CMD delay 15000 ms
    Info:MAIN:Time 522, idle 0/s, free 4275072, MQTT 0(32), bWifi 1, secondsWithNoPing 453, socks 3/21 
    Info:MAIN:Time 523, idle 0/s, free 4275072, MQTT 0(32), bWifi 1, secondsWithNoPing 454, socks 3/21 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 524, idle 0/s, free 4274904, MQTT 0(33), bWifi 1, secondsWithNoPing 455, socks 3/21 
    Info:MAIN:Time 525, idle 0/s, free 4275072, MQTT 0(33), bWifi 1, secondsWithNoPing 456, socks 3/21 
    Info:MAIN:Time 526, idle 0/s, free 4274904, MQTT 0(33), bWifi 1, secondsWithNoPing 457, socks 3/21 
    Info:MAIN:Time 527, idle 0/s, free 4274904, MQTT 0(33), bWifi 1, secondsWithNoPing 458, socks 3/21 
    Info:MAIN:Time 528, idle 0/s, free 4275072, MQTT 0(33), bWifi 1, secondsWithNoPing 459, socks 3/21 
    Info:MAIN:Time 529, idle 0/s, free 4275072, MQTT 0(33), bWifi 1, secondsWithNoPing 460, socks 3/21 
    Info:MAIN:Time 530, idle 0/s, free 4274904, MQTT 0(33), bWifi 1, secondsWithNoPing 461, socks 3/21 
    Info:MAIN:Time 531, idle 0/s, free 4275240, MQTT 0(33), bWifi 1, secondsWithNoPing 462, socks 3/21 
    Info:MAIN:Time 532, idle 0/s, free 4274904, MQTT 0(33), bWifi 1, secondsWithNoPing 463, socks 3/21 
    Info:MAIN:Time 533, idle 0/s, free 4263968, MQTT 0(33), bWifi 1, secondsWithNoPing 464, socks 3/21 
    Info:MAIN:Time 534, idle 0/s, free 4274904, MQTT 0(33), bWifi 1, secondsWithNoPing 465, socks 3/21 
    Info:MAIN:Time 535, idle 0/s, free 4265856, MQTT 0(33), bWifi 1, secondsWithNoPing 466, socks 3/21 
    Info:MAIN:Time 536, idle 0/s, free 4275072, MQTT 0(33), bWifi 1, secondsWithNoPing 467, socks 3/21 
    Info:CMD:[WebApp Cmd 'delay_ms 15000' Result] OK
    Info:MAIN:Time 537, idle 0/s, free 4287768, MQTT 0(33), bWifi 1, secondsWithNoPing 468, socks 2/21 
    Info:MAIN:Time 538, idle 0/s, free 4287768, MQTT 0(33), bWifi 1, secondsWithNoPing 469, socks 2/21 
    Info:MAIN:Time 539, idle 0/s, free 4287768, MQTT 0(33), bWifi 1, secondsWithNoPing 470, socks 2/21 
    Info:MQTT:mqtt_host empty, not starting mqtt
    Info:MAIN:Time 540, idle 0/s, free 4287768, MQTT 0(34), bWifi 1, secondsWithNoPing 471, socks 2/21


    Added after 7 [minutes]:

    Maybe brave and fearless @divadiow can do some more tests on other platforms with the images from here?

    https://github.com/MaxineMuster/OpenBK7231T_App/actions/runs/15741915313

    Just check if a long "delay_ms" will work as expected (since we test with "long" intervals, the result in seconds between start and end should be ok):
    So maybe 5.000 and 15.000 - if we don't run into a watchdog and "Info" is still printed, the main thread should work?
    Or are there other test to check @p.kaczmarek2 ?
  • ADVERTISEMENT
  • Helpful post
    #11 21583288
    p.kaczmarek2
    Moderator Smart Home
    I think we have separate "every second" thread, separate "quick tick" thread, and we also have separate threads calling change handlers, and they all can contain delay_ms in backlog...

    Added after 1 [hours] 30 [minutes]:

    backlog delay support has been added to relaese, however it's a very hacky way:
    https://github.com/openshwprojects/OpenBK7231...mmit/716cd7b87cdd81727f58dd7f1cbb671606236106
    I just check backlog string for delay_s /delay_ms, and if found, i treat it as script (replace ; with newlines)

    If you want, you can check this out, but it should work good enough, as I covered it with Windows self tests.

    @max4elektroda @divadiow

    Added after 8 [minutes]:

    This is also solved now:
    https://github.com/openshwprojects/OpenBK7231T_App/issues/1514
    Helpful post? Buy me a coffee.
  • #12 21583492
    150219v8
    Level 2  
    >>21583288
    Thanks, now my short beep less than one second works properly.

    How could RepeatingEvent also work less than 1sec.
    (AddRepeatingEvent 1 1)
    ?
  • ADVERTISEMENT
  • #13 21584205
    p.kaczmarek2
    Moderator Smart Home
    Interval can be lower than 1. Here's related code snippet:
    WiFiState Command States and Short Beep Automation in OpenBK7231 Autoexec Script
    Helpful post? Buy me a coffee.
  • #14 21584498
    150219v8
    Level 2  
    Ok, you show me the description how a cow produces milk. But how can I get it out? 😂😂😂
    How is the syntax for repeat 50ms?
  • Helpful post
    #15 21584579
    p.kaczmarek2
    Moderator Smart Home
    Well, I've checked the code to make sure that fractional parts are enabled. It seems they are, so if 1 second works, then try 0.05 for 50ms.
    Helpful post? Buy me a coffee.
  • #16 21584670
    150219v8
    Level 2  
    I checked it, and it works.

    addChangeHandler Channel1 == 1 addRepeatingEvent 0.05 1 setChannel 1 0
    This released the port after 50ms when it has turned on.

    Thanks

Topic summary

The discussion addresses two main points regarding OpenBK7231 autoexec scripting: the undocumented "waitFor WiFiState" command and achieving a short buzzer beep on WiFi connection. The WiFiState command corresponds to an internal enum HALWifiStatus with states such as WIFI_UNDEFINED (0), WIFI_STA_CONNECTING (1), WIFI_STA_DISCONNECTED (2), WIFI_STA_AUTH_FAILED (3), WIFI_STA_CONNECTED (4), WIFI_AP_CONNECTED, and WIFI_AP_FAILED, but it is currently undocumented and partially unsupported. For generating a short buzzer beep (~100ms), users implemented an alias using backlog commands with setPinRole to toggle the buzzer pin high and low, combined with a newly introduced delay_ms command to create precise millisecond delays. The delay_ms command was initially limited but later fully enabled, allowing delays up to 15 seconds without blocking the main thread due to a hacky script parsing method that converts backlog strings into script files. Additionally, addRepeatingEvent supports fractional intervals, enabling repeat events with intervals as low as 50ms, demonstrated by the syntax: addRepeatingEvent 0.05 1 setChannel 1 0, which releases the port after 50ms. These scripting enhancements improve automation capabilities for OpenBK7231 devices, including ESP32 testing, facilitating precise timing control for hardware actions like buzzer beeps on WiFi connection events.
Summary generated by the language model.
ADVERTISEMENT