-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Fix JK BMS connection restart when bluetooth fails. #941
Fix JK BMS connection restart when bluetooth fails. #941
Conversation
This fix installs a new thread to monitor the state of the original scraping thread. If scraping thread dies, it verifies that it did not because the scraping was intentionally stopped by calling stop_scrapping. When restarting the scrapper, it first calls the bluetooth reset lambda function that was passed in the class contructor, such that bluetooth is ready to make a proper connection.
Thank you very much for contributing! Did you already test it? A warning message when the treat crashed would be useful :-) |
Thank you for contributing the project ! 😄
I have force tested it by causing an explicit exit from the thread. It did reboot the thread properly in that case.
The original code already prints a message for both normal and exception thread exits. |
You think it would be possible to integrate your fix globally that it works for all BLE drivers? |
Very likely, I did only debug the problem in the context of the JK BMS. However, if other BLE implementations have similar designs it is likely they somehow suffer from the same problem. |
Best would be, if we add a thread here dbus-serialbattery/etc/dbus-serialbattery/dbus-serialbattery.py Lines 226 to 229 in 5e025e6
that works similar as this function, if no data is fetched dbus-serialbattery/etc/dbus-serialbattery/dbushelper.py Lines 626 to 691 in 5e025e6
|
I am working on a general approach to better control driver monitoring for the drivers that contains threads etc. What do you think ? |
What if the driver if the bms is stuck and therefore can't update Is_active to false? This is what the current issue is. Therefore we need only a monitoring for the non polling drivers, since for the polling drivers there is already a check. |
Actually I was referring to the thread to be created within the Battery code, and any subclass of Battery (such as Jkbms_Ble) would implement the specifics of this monitoring. The is_active idea was already dropped. The solution would be something similar to what was done in my patch but generic, by extending Battery class instead. I almost have it done. It takes me a while since I do not have a testing environment, would need to test it in production. 😞 I would appreciate if you can give me some pointers on how to implement it on some sort of simulated environment. |
This fix installs a new thread to monitor the state of the original scraping thread.
If scraping thread dies, it verifies that it did not because the scraping was intentionally stopped by calling stop_scrapping. When restarting the scrapper, it first calls the bluetooth reset lambda function that was passed in the class contructor, such that bluetooth is ready to make a proper connection.
This problem was reported by me in issue #915 which got closed since it was a duplicate of #720.
Looking forward to your comments !