-
Notifications
You must be signed in to change notification settings - Fork 342
Feature Request - Better WiFi Management #1643
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
Comments
I can add those things to scripting, but keep in mind that we also have Berry support now: https://www.elektroda.com/rtvforum/topic4117238.html Apart from that, I'm suprised about what you say about restart. Restart (reboot) is a fresh boot, no variables are kept. Any ways to reproduce the problem? Also pinging @NonPIayerCharacter @divadiow Maybe could you provide an UART log showing what is printed when you do software reboot and it does not connect to WiFi? |
@openshwprojects Now, about restart: yes, the command executes, but every single time I use it, WiFi dies - no exceptions. The device reboots into a state where it never reconnects. Not once has it recovered from a software restart. Only manual power-cycling fixes it, and even that’s not always reliable on the first try. So while restart works in a mechanical sense, it guarantees a non-functional network state afterward. That makes it useless in scripts meant for recovery. Also, Berry isn’t a solution here. It’s promising, and I’ve started exploring it, but it’s still experimental, not fully documented, and doesn’t replace OBK core logic. Critical operations like startup, recovery, connection handling still depend on OBK. So unless Berry eventually replaces OBK at the base level, it can’t fix the current reliability problems. At best, it’s something to use after the device is stable. As long as OBK scripting is what boots the device, restores function after failure, handles offline conditions, and keeps automation, that must be the focus - to make it reliable. Let me know if you'd like help testing anything without UART. But I’ll be focusing on black-box behavior and scripting edge cases - not low-level output I can’t access for now (yeah, I cheapened on an Aliexpress UART adaptor). P.S. |
How many devices do you have and how many devices have this problem? I have devices used everyday and they always seem to connect... What kind of info is missing for berry, what can I add? We can start with most basic things, and I'll add them to berry as requested. |
@openshwprojects And while this controller may be on the finnicky side, the issues I’m facing are not edge cases. Basic WiFi recovery, stable boot, and reliable state detection should be considered core functionality. Right now, they're not dependable. About Berry My plan was this:
In practice though, boot times vary wildly - from ~5s to 30s+ - and at least half of the times when I get Your reliable device Core Issues That Still Need Solving
Helping That said, I can absolutely help in other areas. Whether it's:
|
You are correct that scripting system is not mature, and I will do my best to improve it for you, but you are most likely somewhat wrong in regard to the WiFi/restart, or, to be precise, your issue does not seem to be common one. My devices are mostly stock and they reboot reliably. I literally flashed hundreds of devices: https://openbekeniot.github.io/webapp/devicesList.html and I don't recognize "reboot not cleaning" problem. Or maybe you have this flag enabled and it has some instability? 37 | [WiFi] Quick connect to WiFi on reboot (TODO: check if it works for you and report on github -- | --You don't need C knowledge to help, your suggestions are already helpful, we can go through scripting issues together later, but first we need to sort out that WiFi thing because it's certainly not standard. They may be some bug or issue, but it's not by design... |
First of all - welcome to the world of open source :) On the connection issues - BK7231 based devices are extremely cheap and are known to be of poor quality, it just may be a case you've gotten a bad chip/module in your device. OBK has a signal strength indicator on it's landing/home page, what is your signal reading there? I've got 50+ devices running at any given time, some of them for more than 100 days without any problems as they are reporting to HA for monitoring and testing purposes. Try a different device/module and see if the problem persists. Scripting is never a beginner friendly activity in any type of environment, especially in some thing like OBK as it has rapid development process and super platform heavy adoption/porting rate. We are constantly trying to improve the scripting documentation and examples and actively participate in elektroda forum community to resolve such issues. Again have in mind that this is an open source project, wide spread (many platforms) and with very rapid development so barging in with negative attitude will not make things any better. Some of your suggestions are spot-on, we have internally discussed some of them, but this is a small team of enthusiasts trying our best to make something work. Stick around and give it a chance, the team will help you to the best of our ability. Some of you initial comments are out of place. You confirmed that you programing skills are lacking but still demand immediate changes to something that is not to your liking. You have also jumped way ahead of your self by trying to script something without understanding it first nor knowing how any of the processes work (like reboot or wifi connect ie). You are mentioning boot racing conditions being problematic for wifi connectivity - which ones?? What have you noticed/confirmed is in racing condition?? Again, welcome to the project, we will help you out as much as possible, lower your expectations to your skill level and try to be more precise with your problems and we will get involved to solve them if possible. Thank you. |
@openshwprojects Flags
Boot speed tests
Could it be RF Partition? - Definitely a possibility. But given that it's module-locked, all I can do is rely on my initial backup. I doubt I can cannibalise it from a different module. |
"restart" should really work, unless it isn't executed. A good substitution for it is "deepsleep 1", since it's instant. WiFiState == 4 is triggered when we receive IP, or when connected to AP if static IP is configured. On BK7231 it's triggered only in one place: https://github.com/openshwprojects/OpenBK7231T_App/blob/master/src/hal/bk7231/hal_wifi_bk7231.c#L294, so it should be very reliable. As a test i would also suggest to reboot your router. I remember that i had a problem once with BK7231T device, and that it would never connect on the first try. Router reboot helped with that. (AX3600 Openwrt 24.10). What happens if you configure ping watchdog in device web page? I use it on several non-beken devices and it works fine for me. Boot times are strange, UART logs would be really helpful. You can enter command 'logPort 1' to print OpenBeken logs to UART1, but the downside is that only OpenBeken logs are printed, logs from SDK will still print to UART2. |
Thank you for the welcome and apologies if I left that impression to you - that wasn't my intention. Regarding Programming Skills - I may not be able to program in C, but I have experience with other programming and scripting languages. I am not new to system-level troubleshooting, scripting logic, hw diagnosis, automation.
I inferred from device behaviour:
I understand where you're coming from, and I made sure to address it first thing in this reply. I care about this project enough to engage with it despite the full stack of frustrations that hit me from day one. I can see the work that has been put on it from functional standpoint and I understand that refinements may not be on the first list of priorities (yet) - hence I offered myself to help with making at least some of the documentation user-friendly. I'm battling my own health issues and limited energy, but despite that I had to speak up, not as criticism to the team, but to show that users who may want to join OBK are often deterred by this kind of hard to pinpoint behaviour of OBK and cheap HW. |
Just to repeat, welcome 😃 any help is highly appreciated. But we can cross that bridge once we burn it 😄 Would you mind if we delve into some basics first? I will ask couple of super basic questions to determine what is it you can do so we can do better to help you out.
I believe we can move from here and determine what your issue is, ok? |
@NonPIayerCharacter
|
Boot Log:
|
IP 0.0.0.0 at 10 sec is normal, since you have yet to connect. At 20 sec everything looks ok. It logs every ten seconds, so if you would've connected at 19 sec, then log at 20 sec would've showed your ip, gw, etc. Got IP callback was present in earlier versions, but it was fixed. (there were 2 WIFI_STA_CONNECTED events, one for connection, the other for IP). |
@NonPIayerCharacter Despite the static config, the IP, gateway, and netmask were all reported as 0.0.0.0 until Time 20, and the device was not reachable via ping or browser before that - so there’s clearly a delay somewhere between internal WiFi stack readiness and full network usability, even in static IP mode. Also worth noting: Takeaway |
@derei , just to be sure, can you please check with no scripts in littlefs? you have some autoexec.bat or be (berry) and maybe, just maybe, it is slow to execute or something and causes instability? Just to be sure. Make a backup first. Remove all scripts, do full power off and on, and check, is WiFi still slow and problematic? |
On a side note, @derei , apart from WIFi issues (which are specific to your device mostly, not a generic problem), can you tell me which features, scripts, would you suggest as most important for next Berry tutorial? So I can help you setting up your automations with Berry? |
@openshwprojects So, cleaner than that it's not possible. |
@openshwprojects I believe the errors simply shows it tried to run an autoexec.bat file, but the file wasn’t found. I see berry tried to init and threw an So yes: it was a clean state. No .bat, no .be. |
Ah, I see. You may be right here. It's just message cause of missing import. |
Talking about connectivity issue - I've seen somewhat similar situation with a static IP set being in conflict with another device on the network. Can you try to go DHCP for that device and see if that will resolve the connectivity issue? There is nothing unusual in the log provided... 🤔 To do that set all addresses to 0.0.0.0 in IP settings and reboot . Also for completes, just so we can eliminate more things try to flash your device with standard (not BERRY) version and see if the connectivity issue remains, not that it should matter but we can try a deductive method to get to the bottom of the issue. |
@DeDaMrAzR I know all my devices. Plus, if it were ip conflict it wouldn't connect at all. |
Any reports on DHCP test or connectivity improvements? Did you try to flash it with standard binary (non BERRY)? Can you try any other similar device? |
I have seen this happen with MAC conflict. In BK OBK, you can change MAC |
I can't see that in your logs. Network state including IP is displayed every 10 seconds. The last point is totally valid, though not necessarily an OBK issue. A last point to accept is that there is a somewhat limited possibility what to do or see with regard to the WiFi driver. We always rely on a library from the sdk to implement the functions properly. We call something like "reset wifi" and can not tell, if the results are exactly like a fresh rebooted wifi. |
worth seeing if the new SDK libs are any different perhaps? |
So, I did some tests. I reflashed stock fw, collected uart logs, then did the same on a fresh OpenBK7231N_QIO_1.18.109_berry. Below are extracts from UART logs, for comparison: Stock FW (configured and used with Gosund app):
Total boot to full cloud/BLE readiness: ~3–4 seconds OpenBK7231N_QIO_1.18.109_berry (DNS 1.1.1.1)
OpenBK7231N_QIO_1.18.109_berry (DNS 192.168.xxx.xxx)
The ~30+ second delay before Wi-Fi connection in OBK is not caused by MQTT config (I'm running the device alone, no HA yet) or observable DNS resolution behavior. While I tested both Cloudflare DNS (1.1.1.1) and local router DNS (192.168.xxx.xxx), the logs show no evidence of DNS queries. Instead, the delay stems from repeated Wi-Fi authentication failures ( |
Wasn't there a "quick connect" for Beken devices? |
@MaxineMuster I tried it before and it caused connection issues. Possibly there were some artifacts remaining from previous flashing, and now it's gone - I did an Erase All at 9600 baud before flashing obk, that may have helped. Regardless, the fact the connection keeps dropping and retrying during boot (if 37+51 not enabled), still points out towards unoptimised network protocol. Worth looking into it - something is definitely not working as it should, and coverig it up is not the way. |
@openshwprojects
Issue: Lack of Granular WiFi Recovery and Monitoring in OBK Scripts
Device: RGBW LED Controller iH001 with CB3S (BK7231N)
Problem Summary
During my learning and testing with OBK scripting, I ran into repeated problems related to unreliable WiFi handling:
WiFiState == 4
is not a trustworthy indicator of actual connectivity. In many cases, it was4
but the device still failed to communicate or respond over network.restart
command appears ineffective in restoring WiFi connectivity. It does not seem to reinitiate the WiFi subsystem.Script Context
I built a full WiFi state indicator script using OBK scripting and
PingHost
watchdog. However, even with visual indicators and ping tests, the device behavior remains unreliable when WiFi fails.Suggestions / Feature Requests
Reliable WiFi Reconnect Command
A new command such as
wifi_reset
that properly shuts down and reinitializes the WiFi subsystem (as if it were freshly booted) would be extremely helpful.restart
doesn’t serve this purpose.WiFi Connection Health Variable
We need a more truthful state than
WiFiState == 4
. A$WiFiAlive
or$HasIP
constant could help scripts verify actual operability (e.g. successful DHCP, ping responsiveness, etc.).Expose
$noPingTime
toif
conditions, not justwaitFor
Currently,
$noPingTime
appears to be usable only insidewaitFor
blocks. This limits scripting flexibility. It would give much more control over wifi state actions if real timeif ... then
logic could apply to it.Built-in WiFi Watchdog
Extend
PingHost
or create a nativeWiFiWatchdog
command that can:WiFiState
and ping successExpose Reconnect Failure Count or Attempts
Exposing how many connection attempts failed in a boot cycle would help scripts decide when to escalate (e.g. trigger external power relay).
Boot process is hindered by racing conditions
Not just WiFi, but various parts of the boot process are affected by race conditions, leading to unpredictable start-up behaviour and scripting failures.
P.S.
OBK scripting feels extremely unintuitive - full of exceptions, selectively applied conditions, and arbitrary restrictions. Many things that should logically work simply don’t, with no clear reason. This makes the system frustrating and error-prone, especially for a project that aims to promote privacy, decentralization, and empowerment through open technology.
Right now, OBK feels accessible only to a very narrow group of technically obsessive users. Anyone with less experience or patience is likely to give up - pushed away not by the complexity of the hardware, but by the unpredictability of the scripting environment itself.
After spending several days wrestling with this LED controller, I’m convinced that building a system from scratch (e.g. ESP32 with ArduinoIDE or PlatformIO) would produce something far cleaner, more predictable, and more sustainable. It’s not the hardware that’s the barrier - it’s the inconsistent behaviour and lack of scriptability that drains time and motivation.
The text was updated successfully, but these errors were encountered: