-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
[FEATURE] Enable BLE presence detection #18
Comments
Compiling with
versus:
So, 33.6% of the flash memory is taken by the BLE code. |
I started investigating the esp32_ble_tracker code, to see what I could Underlying APIesp-idf API used: GAP BLE Sempaphore useThe code uses 2 semaphores for code syncing.
Function: register_listener(ESPBTDeviceListener)
Function: setup()
Function: start_scan(bool first), first = true when called from setup
Function: loop()
Function: gap_scan_result() - called by GAP API on new result
That's all folksThe rest of the code is all about parsing scan results. |
I've restructured the code for On the console, I find the following:
|
The OTA updates are simply conflicting with the tracker, because of the shared access to the single physical radio, and lower level abstractions do not have any handling in place for handling this. I'm now trying to come with a way to fix this. My envisioned way of handling this is to add some triggers and actions, so we can add something like this in the YAML configuration: ota:
on_begin:
then:
- esp32_ble_tracker.suspend: my_ble_tracker
on_error:
then:
- esp32_ble_tracker.resume: my_ble_tracker
esp32_ble_tracker:
id: my_ble_tracker Having this automatically taken care of would be very nice too, but it doesn't really match the idea of having all these loosely coupled components, that are glued together in the YAML config. Another way of work would be to introduce somethink like an But before going there, I first will investigate if the idea works with the simpler setup as mentioned above. |
I filed a pull request for extending the OTA component with some automation triggers: |
I'm working on disabling the bluetooth during OTA upgrades, but so far I've had no luck with this.
I'm trying really hard to shutdown the bluetooth, but I do get wdt reboots. I added some more debugging output in the ota component, and from that you can see in the above log that the 'read features' step fails. This is part of the OTA processing code that uses the wifi. Maybe the bluetooth handling is still competing for the radio? Or maybe disabling the bluetooth has masked some incoming wifi packets? In the latter case, things might get fishy, because we can't really predict when an OTA upgrade is going to happen. We can only act upon one as soon as one has just started. One thing I found in a discussion about combining wifi and ble:
Maybe this is something I can persue. |
Found another issue |
Looked at the esp-idf 4.2 release. That has some changelog items on wifi coexistence. Also found a faq entry Does ESP32 support coexistence between Bluetooth® and Wi-Fi? Yes, but time-sharing control is required for ESP32’s coexistence between Wi-Fi and Bluetooth. Please go to menuconfig to enable the Wi-Fi/Bluetooth coexistence, shown as follows:
|
Another interesting thing: switching to nimble All in all, my conclusion is that doing BLE tracking currently is not an option. When using BLE, the WiFi stack is broken for OTA. Disabling the Bluetooth doesn't help here. Future releases of esp-idf (v4 branch), might bring some goodness in this respect, along with making use of the Nimble component. This is likely not a short term solution, because it requires changes in multiple stacks, and we'll have to wait for a stable v4 release of esp-idf. Closing this ticket for now. |
The ESP32-WROOM-32D that is in the lamp does support BLE.
It would be a cool feature to make that work for presence detection.
I already tried to implement this, but have failed so far.
One issue was that the platform package repo that we use did not yet contain the correct library files. That was fixed.
A bigger problem, unsolved as of yet, is that the
ble_32_tracker
module makes the device very unstable. The device performs a lot of spontaneous reboots. The console logs show that this is because the device loop is taking up too much time (according to the WDT).Possibly, this is an issue for this specific chip, given that this is a single core chip and not a dual core one.
Changes are likely to be done in the
loop()
function of theble_32_tracker
module.The text was updated successfully, but these errors were encountered: