Closed Kite-Smurf closed 3 years ago
I'm seeing an exception and backtrace in the logs.
[17:51:42.296] - [COM4] - [>>] - abort() was called at PC 0x401b7267 on core 1 [17:51:42.303] - [COM4] - [>>] - [17:51:42.303] - [COM4] - [>>] - Backtrace: 0x40091f40:0x3ffcec00 0x40092171:0x3ffcec20 0x401b7267:0x3ffcec40 0x401b72ae:0x3ffcec60 0x401 b61ff:0x3ffcec80 0x401b62f2:0x3ffceca0 0x401b62a9:0x3ffcecc0 0x400d5a2b:0x3ffcece0 0x400d44ce:0x3ffced20 0x400d32d6:0x3ffced40 0x400dc829 :0x3ffcedd0 0x4008e689:0x3ffcedf0
Could you help me by installing the ESP exception decoder in Arduino and running the backtrace through it? (you might have to recompile/upload once the decoder is installed).
Hi Thanks for help!
This is the translation of the backtrace:
Decoding stack results 0x400943b0: invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 155 0x400945e1: abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 170 0x401bae77: cxxabiv1::terminate(void ()()) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc line 47 0x401baebe: std::terminate() at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc line 57 0x401b9e0f: cxxabiv1::cxa_throw(void, std::type_info, void ()(void)) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_throw.cc line 87 0x401b9f02: operator new(unsigned int) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/new_op.cc line 54 0x401b9eb9: operator new[](unsigned int) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/new_opv.cc line 32 0x400d5e5f: WiFiUDP::parsePacket() at C:\Users\otto.elter\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi\src\WiFiUdp.cpp line 210 0x400d4802: ArduinoOTAClass::handle() at C:\Users\otto.elter\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\ArduinoOTA\src\ArduinoOTA.cpp line 367 0x400d358a: loop() at C:\Users\otto.elter\Desktop\am43-client/am43-client.ino line 360 0x400dd5d9: loopTask(void) at C:\Users\otto.elter\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32\main.cpp line 19 0x40090af9: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
I hope this helps.
On Tue, Jun 16, 2020 at 12:02 AM buxtronix notifications@github.com wrote:
I'm seeing an exception and backtrace in the logs.
[17:51:42.296] - [COM4] - [>>] - abort() was called at PC 0x401b7267 on core 1 [17:51:42.303] - [COM4] - [>>] - [17:51:42.303] - [COM4] - [>>] - Backtrace: 0x40091f40:0x3ffcec00 0x40092171:0x3ffcec20 0x401b7267:0x3ffcec40 0x401b72ae:0x3ffcec60 0x401 b61ff:0x3ffcec80 0x401b62f2:0x3ffceca0 0x401b62a9:0x3ffcecc0 0x400d5a2b:0x3ffcece0 0x400d44ce:0x3ffced20 0x400d32d6:0x3ffced40 0x400dc829 :0x3ffcedd0 0x4008e689:0x3ffcedf0
Could you help me by installing the ESP exception decoder in Arduino and running the backtrace through it? (you might have to recompile/upload once the decoder is installed).
https://github.com/me-no-dev/EspExceptionDecoder
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/buxtronix/am43/issues/2#issuecomment-644413208, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOECH4BEBGPGKYLOH463B3LRW2K7BANCNFSM4N6N5NOA .
What I also noticed that the controller crashes at:
and sometimes it is able to reboot automatically:
Attempting to connect to: 02:87:4f:1d:a4:97 ...abort() was called at PC 0x40087969 on core 0
this happens also:
On Tue, Jun 16, 2020 at 12:02 AM buxtronix notifications@github.com wrote:
I'm seeing an exception and backtrace in the logs.
[17:51:42.296] - [COM4] - [>>] - abort() was called at PC 0x401b7267 on core 1 [17:51:42.303] - [COM4] - [>>] - [17:51:42.303] - [COM4] - [>>] - Backtrace: 0x40091f40:0x3ffcec00 0x40092171:0x3ffcec20 0x401b7267:0x3ffcec40 0x401b72ae:0x3ffcec60 0x401 b61ff:0x3ffcec80 0x401b62f2:0x3ffceca0 0x401b62a9:0x3ffcecc0 0x400d5a2b:0x3ffcece0 0x400d44ce:0x3ffced20 0x400d32d6:0x3ffced40 0x400dc829 :0x3ffcedd0 0x4008e689:0x3ffcedf0
Could you help me by installing the ESP exception decoder in Arduino and running the backtrace through it? (you might have to recompile/upload once the decoder is installed).
https://github.com/me-no-dev/EspExceptionDecoder
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/buxtronix/am43/issues/2#issuecomment-644413208, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOECH4BEBGPGKYLOH463B3LRW2K7BANCNFSM4N6N5NOA .
I think this is caused by general instability in the way Arduino has configured the bluetooth stack.
After a lot of debugging, etc, I have managed to make significant improvements in the BLE stack and two different BLE codebases i'm working on are running nearly rock-solid now.
The main fix is just to not have Arduino start the "Bluetooth classic" controller, but only run in BLE mode. Unfortunately most of this change is within the Arduino HAL, so needs to be patched yourself.
Please grab the latest version of this repo, and also see the updated manual patches in the README.
Hi, I'm having a similar issue! I did installed the last version and patch the BLE as suggested in the README. Not much used to Arduino but wanted to give it a try! It work for about a minute and stops! I do have 6 devices that are nearby, I was using another python script but liked the idea to move away from my RPI W to ESP32!!
Attempting to connect to: 02:d1:ce:cd:e7:68 ...ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
This suggests a power supply issue.
Also, the Arduino distribution has a limit of 3 devices it can connect to:
https://github.com/espressif/arduino-esp32/issues/3283
Try testing with one of the motors turned off to see if that is a cause.
Thanks!! I will try to turn off 3 of the 6 and see if it works! I did test connected to my computer and in another USB power supply and same happened, probably it freezes when connecting to the 4th device. Since there is this 3 device limitation I wonder if would be possible to add to the code the devices it connects to instead of search for it, with that I could have 2 ESP32 that would connect to 3 devices each, maybe something around the code where you identify if the device has the service AND its one of the MAC in the list!! I wish my c++ was decent enough to try! :)
Yes, it seems reasonable to add a whitelist of mac addresses or names to connect to. Stay tuned!
I've restructured the repo as a library and also added whitelisting of addresses. Please check the readme for new insructions and give it a go.
Thanks for updating the sketch. The white list seems to be a very good option, however I'm unable to get it working with 3 motors. Leaving the white list empty would make the ESP32 connect to all three motors, but the controllers stops working soon. I do not see any backtrace issues anymore. The controller stops usually at this line:
Using the white list makes the ESP32 to connect properly but only to two motors even if I whitelist 3 MAC addresses.
I'm not sure why, but the MAC in the middle always get disregarded. The log says "not included in the white list" The controller does not produce any disconnecting issues or crashes having only two MAC's in the white list.
A few other questions regarding the Home Assistant side.
1) I found this remark in the sketch: * - am43/
2) the Covers and motor states keep showing offline states. ESP32 restart is needed to update the availability states. Is this caused by the controller or my Home Assistant setup?
3) If the AM43 controller goes offline, none of its related entities go in offline or unavailable state.
4) In case one of the motors go offline, its light and battery entities show online state. If the motor is powered on again, its state and its cover state would not update in Home Assistant as long as the ESP32 is not restarted.
5) Would it be possible to setup the ESP32 sketch so that we can make use of the Auto Discovery function of Home Assistant?
Allowlist should be fixed now, I had a bug in the list parsing code.
rssi is not yet implemented - the BLE library RSSI function seems unstable, I need to look into it further.
The offline states are due to a MQTT limitation of only one LWT topic per client - fixing these would require implementing a separate MQTT client per AM43 connection. May be feasible, I shall look into it.
Auto discovery looks interesting, it's something I can look into for sure.
Also, the persistent offline states are due to message retain settings. Rather than fix that in particular, I'll consider updating to one MQTT connection per AM43.
Please try the code in the 'mqtt-multiclient' branch. This uses a separate MQTT connection per AM43, allowing proper availability.
You can also copy the 'availability_state' from the cover entity over to the battery/light entities to get availability for them.
I've had good stability with this so merged the MQTT changes into master.
I still cannot get it working with three motors, only with max two. Also, with the two I'm having range issues. If the ESP32 is farther than a meter from the motors, the controller stops regularly and needs restarting. I've just ordered a new ESP32 to see if that is causing the issue. I'll keep you updated.
On Tue, Jun 23, 2020 at 9:05 AM buxtronix notifications@github.com wrote:
I've had good stability with this so merged the MQTT changes into master.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/buxtronix/am43/issues/2#issuecomment-647952236, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOECH4EIU6UV6QQLMH7TT6LRYBH37ANCNFSM4N6N5NOA .
I only have 2 devices to test, so don't know why 3 is failing.
As for range, sounds like the antenna might not be connected properly. One of my devices didn't have the antenna selection jumper in the right place and also got only a metre.
I'll do the testing for you with three devices, no problem at all. As soon as I get my new EPS's in, I'll do some more testing as the "not working with three devices" problem might be related to the range issue.
On Tue, Jun 23, 2020 at 9:28 AM buxtronix notifications@github.com wrote:
I only have 2 devices to test, so don't know why 3 is failing.
As for range, sounds like the antenna might not be connected properly. One of my devices didn't have the antenna selection jumper in the right place and also got only a metre.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/buxtronix/am43/issues/2#issuecomment-647962671, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOECH4G5ERN6N3JU2MTI5ZDRYBKQNANCNFSM4N6N5NOA .
Finally, my new EPS's arrived to do some more testing. I setup one with external antenna connected to the ipex, jumper re-positioned accordingly. The connection and the stability got 100 times better then in case of using the on board antenna. According to the documentation the range should be much better than this even with the on board antenna. I came across some post mentioning the option to change the TX power of the BLE. do you think it is possible? https://community.openmqttgateway.com/t/esp32-ble-range/249/11
Please find the logs here: Download link https://we.tl/t-I4ZC6e816K
@Kite-Smurf Can you confirm you've made the changes to BLEClient.cpp per the README? A few of the crashes look similar to what happens without the patch.
BLEClient.cpp is pacthed according to README just as esp32-hal-bt.c . Please check if this is correctly done. Download link https://we.tl/t-mUcYn3mhj1
Please let me know if you need more details.
I think this is at least in part due to a memory leak. I found one cause to this and will upload the fix shortly. You can see the improvement in free memory availability here:
I'll update when I've uploaded the fix.
The fix is submitted, this should hopefully prevent most/all of the freeze you are seeing.
I also experience freezing. I tried the latest code and it didn't help. I was previously using an older build which seemed to work a bit more stable but I suspect the issue has to do with the number of devices.
In short, my set up is 3 motors added to the configs allow list. I also get either an abort() or the chip just freezes. It is highly reproducible in my environment when all 3 sensors are connected. I believe it was also happening with just 1 sensor, but perhaps less often.
For example, a stop might occur:
BLE Advertised Device found: Name: , Address: 02:9c:d3:6b:11:5e, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Attempting to connect to: 02:9c:d3:6b:11:5e ...
Or a restart:
[Bedroom M-R 02:87:42:46:69:88] Unknown reply: 9AA9100000001100000000010000110000000022
abort() was called at PC 0x401b7b1b on core 1
Backtrace: 0x40091f40:0x3ffcee10 0x40092171:0x3ffcee30 0x401b7b1b:0x3ffcee50 0x401b7b62:0x3ffcee70 0x401b69fb:0x3ffcee90 0x401b6aee:0x3ffceeb0 0x401b6aa5:0x3ffceed0 0x400d5273:0x3ffceef0 0x400d3d16:0x3ffcef30 0x400d2ee0:0x3ffcef50 0x400dcf4d:0x3ffcefe0 0x4008e689:0x3ffcf000
Rebooting...
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
Starting Arduino BLE Client application...
@adotagarwal Could you pass the backtrace through the ESP exception decoder and let me know traceback?
Sure here is one exception:
It looks like its crashing after checking if the disconnect callback is null while trying to invoke it.
PC: 0x401d284d: AM43Client::onDisconnect(BLEClient*) at D:\OneDrive\Documents\Arduino\libraries\am43-master\src\AM43Client.cpp line 36
EXCVADDR: 0x00040056
Decoding stack results
0x401d284d: AM43Client::onDisconnect(BLEClient*) at D:\OneDrive\Documents\Arduino\libraries\am43-master\src\AM43Client.cpp line 36
0x400d8a8d: BLEClient::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEClient.cpp line 186
0x400d95d1: BLEDevice::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEDevice.cpp line 167
0x4014ac1a: btc_gattc_cb_handler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c line 31
0x401438d2: btc_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/core/btc_task.c line 110
0x4008e689: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
Another one:
PC: 0x00000000
EXCVADDR: 0x00000000
Decoding stack results
0x400d8a8d: BLEClient::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEClient.cpp line 186
0x400d95d1: BLEDevice::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEDevice.cpp line 167
0x4014ac1a: btc_gattc_cb_handler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c line 31
0x401438d2: btc_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/core/btc_task.c line 110
0x4008e689: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
One more:
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x401d284d PS : 0x00060c30 A0 : 0x800d8a90 A1 : 0x3ffdeaa0
A2 : 0x3fff1764 A3 : 0x3fff1be4 A4 : 0x3fff0d4c A5 : 0x3ffdeb4c
A6 : 0x3fff0d4c A7 : 0x3ffdeb88 A8 : 0x00000000 A9 : 0x3ffdeb00
A10 : 0x3fff1aa8 A11 : 0x3fff1764 A12 : 0x3fff0c84 A13 : 0x3ffdeb4c
A14 : 0x3fff0c84 A15 : 0x3ffdeb88 SAR : 0x00000018 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000018 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
Backtrace: 0x401d284d:0x3ffdeaa0 0x400d8a8d:0x3ffdeac0 0x400d95d1:0x3ffdeb70 0x4014ac1a:0x3ffdebc0 0x401438d2:0x3ffdec10 0x4008e689:0x3ffdec40
Decoded:
PC: 0x401d284d: AM43Client::onDisconnect(BLEClient*) at D:\OneDrive\Documents\Arduino\libraries\am43-master\src\AM43Client.cpp line 36
EXCVADDR: 0x00000018
Decoding stack results
0x401d284d: AM43Client::onDisconnect(BLEClient*) at D:\OneDrive\Documents\Arduino\libraries\am43-master\src\AM43Client.cpp line 36
0x400d8a8d: BLEClient::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEClient.cpp line 186
0x400d95d1: BLEDevice::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEDevice.cpp line 167
0x4014ac1a: btc_gattc_cb_handler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c line 31
0x401438d2: btc_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/core/btc_task.c line 110
0x4008e689: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
Side note: I had forked your repo and I believe that version, without any tweaks to the BLE library, worked pretty well when placed close to the blinds.
This latest version, with the mods, seems to improve the range dramatically but often crashes
So based on what I read about this particular error (LoadProhibited) and the EXCVADDR each time being really close to 0, it seems like perhaps the pointer is NULL and were trying to access a member of a null structure (the offset being close to 0).
Is it possible that some sort of locking is required?
References: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/fatal-errors.html
The last code is running with 3 motors connected, already for a few days continuously, without freezing. This is good news. I'm seeing short disconnections and re-connections with the MQTT server which I did not see before. They are really short like a second or two. For the rest it looks like solid now. However I think it would be worth mentioning that an external antenna is required to get the range better than a meter unless the power can be regulated by the code.
@adotagarwal Did you apply the changes to the BLE library per the readme? These crashes would suggest that it might not have been done.
@buxtronix yes, at line 183 and 238 in bleclient.cpp i inserted the two conditional breaks which check the connection id. also in the hal c file, i changed the mode to ble as suggested (change cfg variable, change the initialize to pass BLE.
I reflashed the chip again this morning, and when the blinds are all busy (ie, connected to my phone) - the chip seems stable.
However, when i disable the bluetooth on my phone and the blinds become available again, the chip attempts to connect but eventually just hangs, in this case it doesn't restart at all. MQTT messages do not result in any activity or serial output:
BLE Advertised Device found: Name: FITNESS, Address: f0:d4:f7:8f:2e:ae, serviceUUID: d973f2e3-b19e-11e2-9e96-f0d4f78f2eae
BLE Advertised Device found: Name: , Address: 0e:fe:8d:99:f8:ef, manufacturer data: 06000109200283a713e996ffac303a32d5c7ff1d56834da4cfc63261b9
BLE Advertised Device found: Name: , Address: 71:c6:56:e7:b4:2e, manufacturer data: 0600010920023c53bf86ffff6378ade0415fecfef207de5729e12c2e98
BLE Advertised Device found: Name: , Address: 40:cb:c0:d8:a1:d0, manufacturer data: 4c0010050d14eab84e, txPower: 12
BLE Advertised Device found: Name: , Address: 34:60:96:9e:ce:a4, manufacturer data: 060001092002cd38ca006c13af8def594e4b0f7dfbf9dfa9b95da59560
BLE Advertised Device found: Name: , Address: 67:8b:5d:02:0a:6f, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb
BLE Advertised Device found: Name: , Address: 17:90:73:17:e4:c0, manufacturer data: 4c00090603330a2a0014
BLE Advertised Device found: Name: , Address: 15:0e:5e:d0:17:21, manufacturer data: 4c00090603300a2a0015
BLE Advertised Device found: Name: , Address: 04:69:f8:99:91:af, manufacturer data: 4c000906030000000000
BLE Advertised Device found: Name: , Address: 5f:10:6a:42:e6:d2, manufacturer data: 4c001005131c33007b, txPower: 12
BLE Advertised Device found: Name: , Address: 40:cb:c0:d9:de:20, manufacturer data: 4c0010050214228291, txPower: 12
BLE Advertised Device found: Name: , Address: 02:9c:d3:6b:11:5e, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Attempting to connect to: 02:9c:d3:6b:11:5e ...[02:9c:d3:6b:11:5e] Connected
- Connected to server
Connect took 824ms
BLE Advertised Device found: Name: , Address: 5f:10:6a:42:e6:d2, manufacturer data: 4c001005131c33007b, txPower: 12
BLE Advertised Device found: Name: , Address: 0e:fe:8d:99:f8:ef, manufacturer data: 06000109200283a713e996ffac303a32d5c7ff1d56834da4cfc63261b9
BLE Advertised Device found: Name: , Address: 40:cb:c0:d8:a1:d0, manufacturer data: 4c0010050d14eab84e, txPower: 12
BLE Advertised Device found: Name: , Address: 67:8b:5d:02:0a:6f, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb
BLE Advertised Device found: Name: , Address: 71:c6:56:e7:b4:2e, manufacturer data: 0600010920023c53bf86ffff6378ade0415fecfef207de5729e12c2e98
BLE Advertised Device found: Name: , Address: 02:37:8d:55:9a:4a, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Attempting to connect to: 02:37:8d:55:9a:4a ...[02:37:8d:55:9a:4a] Connected
- Failed to connect.
BLE Advertised Device found: Name: , Address: 0e:fe:8d:99:f8:ef, manufacturer data: 06000109200283a713e996ffac303a32d5c7ff1d56834da4cfc63261b9
BLE Advertised Device found: Name: , Address: 40:cb:c0:d8:a1:d0, manufacturer data: 4c0010050d14eab84e, txPower: 12
BLE Advertised Device found: Name: , Address: 24:fc:e5:b1:7a:e5, manufacturer data: 7500420401806024fce5b17ae526fce5b17ae401000000000000
BLE Advertised Device found: Name: , Address: 5f:10:6a:42:e6:d2, manufacturer data: 4c001005131c33007b, txPower: 12
BLE Advertised Device found: Name: FITNESS, Address: f0:d4:f7:8f:2e:ae, serviceUUID: d973f2e3-b19e-11e2-9e96-f0d4f78f2eae
BLE Advertised Device found: Name: , Address: 40:cb:c0:d9:de:20, manufacturer data: 4c0010050214228291, txPower: 12
BLE Advertised Device found: Name: , Address: 71:c6:56:e7:b4:2e, manufacturer data: 0600010920023c53bf86ffff6378ade0415fecfef207de5729e12c2e98
BLE Advertised Device found: Name: , Address: 15:0e:5e:d0:17:21, manufacturer data: 4c00090603300a2a0015
BLE Advertised Device found: Name: , Address: 67:8b:5d:02:0a:6f, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb
BLE Advertised Device found: Name: , Address: 04:69:f8:99:91:af, manufacturer data: 4c000906030000000000
BLE Advertised Device found: Name: , Address: 34:60:96:9e:ce:a4, manufacturer data: 060001092002cd38ca006c13af8def594e4b0f7dfbf9dfa9b95da59560
BLE Advertised Device found: Name: , Address: 17:90:73:17:e4:c0, manufacturer data: 4c00090603330a2a0014
[ 02:9c:d3:6b:11:5e] AM43 Send: 00FF00009A170222B815
[ 02:9c:d3:6b:11:5e] Pin ok
BLE Advertised Device found: Name: , Address: 02:87:42:46:69:88, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Attempting to connect to: 02:87:42:46:69:88 ...[02:87:42:46:69:88] Connected
- Failed to connect.
BLE Advertised Device found: Name: FITNESS, Address: f0:d4:f7:8f:2e:ae, serviceUUID: d973f2e3-b19e-11e2-9e96-f0d4f78f2eae
BLE Advertised Device found: Name: , Address: 67:8b:5d:02:0a:6f, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb
BLE Advertised Device found: Name: , Address: 5f:10:6a:42:e6:d2, manufacturer data: 4c001005131c33007b, txPower: 12
BLE Advertised Device found: Name: , Address: 0e:fe:8d:99:f8:ef, manufacturer data: 06000109200283a713e996ffac303a32d5c7ff1d56834da4cfc63261b9
BLE Advertised Device found: Name: , Address: 34:60:96:9e:ce:a4, manufacturer data: 060001092002cd38ca006c13af8def594e4b0f7dfbf9dfa9b95da59560
BLE Advertised Device found: Name: , Address: 17:90:73:17:e4:c0, manufacturer data: 4c00090603330a2a0014
BLE Advertised Device found: Name: , Address: 40:cb:c0:d9:de:20, manufacturer data: 4c0010050214228291, txPower: 12
BLE Advertised Device found: Name: , Address: 24:fc:e5:b1:7a:e5, manufacturer data: 7500420401806024fce5b17ae526fce5b17ae401000000000000
BLE Advertised Device found: Name: , Address: 04:69:f8:99:91:af, manufacturer data: 4c000906030000000000
BLE Advertised Device found: Name: , Address: 02:37:8d:55:9a:4a, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Attempting to connect to: 02:37:8d:55:9a:4a ...
After that last hang, I reset the chip and it almost immediately crashed:
Attempting to connect to: 02:37:8d:55:9a:4a ...ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8
Starting Arduino BLE Client application...
Wifi connecting to: austinsapt ...
[WiFi-event] event: 0
[WiFi-event] event: 2
AllowList contains the following device(s):
Mac: 02:9c:d3:6b:11:5e
Mac: 02:87:42:46:69:88
Mac: 02:37:8d:55:9a:4a
[WiFi-event] event: 4
BLE Advertised Device found: Name: , Address: 78:ad:07:2b:84:c2, manufacturer data: e00000d8ca82956a, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb
BLE Advertised Device found: Name: , Address: 17:90:73:17:e4:c0, manufacturer data: 4c00090603330a2a0014
BLE Advertised Device found: Name: , Address: 18:d6:d8:bb:65:2a, manufacturer data: 0600010920029135cec705616ecd8281250bdf9ea1669fd5da210ffeee
BLE Advertised Device found: Name: , Address: 40:cb:c0:d8:a1:d0, manufacturer data: 4c0010050d14eab84e, txPower: 12
BLE Advertised Device found: Name: FITNESS, Address: f0:d4:f7:8f:2e:ae, serviceUUID: d973f2e3-b19e-11e2-9e96-f0d4f78f2eae
BLE Advertised Device found: Name: , Address: 61:c7:5a:ec:89:b0, manufacturer data: 060001092002a3b212c5b137be43887ca9ff292108748c08abccd39576
BLE Advertised Device found: Name: , Address: 15:0e:5e:d0:17:21, manufacturer data: 4c00090603300a2a0015
BLE Advertised Device found: Name: , Address: 5f:10:6a:42:e6:d2, manufacturer data: 4c001005131c33007b, txPower: 12
BLE Advertised Device found: Name: , Address: 24:fc:e5:b1:7a:e5, manufacturer data: 7500420401806024fce5b17ae526fce5b17ae401000000000000
BLE Advertised Device found: Name: , Address: 40:cb:c0:d9:de:20, manufacturer data: 4c0010050214228291, txPower: 12
[WiFi-event] event: 7
WiFi connected
IP address: 10.42.0.104
Attempting MQTT connection...connected
BLE Advertised Device found: Name: Bedroom M-R, Address: 02:87:42:46:69:88, manufacturer data: 0000, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Attempting to connect to: 02:87:42:46:69:88 ...[02:87:42:46:69:88] Connected
- Failed to connect.
BLE Advertised Device found: Name: , Address: 24:fc:e5:b1:7a:e5, manufacturer data: 7500420401806024fce5b17ae526fce5b17ae401000000000000
BLE Advertised Device found: Name: , Address: 15:0e:5e:d0:17:21, manufacturer data: 4c00090603300a2a0015
BLE Advertised Device found: Name: , Address: 40:cb:c0:d9:de:20, manufacturer data: 4c0010050214228291, txPower: 12
BLE Advertised Device found: Name: FITNESS, Address: f0:d4:f7:8f:2e:ae, serviceUUID: d973f2e3-b19e-11e2-9e96-f0d4f78f2eae
BLE Advertised Device found: Name: , Address: 17:90:73:17:e4:c0, manufacturer data: 4c00090603330a2a0014
BLE Advertised Device found: Name: , Address: 40:cb:c0:d8:a1:d0, manufacturer data: 4c0010050d14eab84e, txPower: 12
BLE Advertised Device found: Name: , Address: 04:69:f8:99:91:af, manufacturer data: 4c000906030000000000
BLE Advertised Device found: Name: , Address: 78:ad:07:2b:84:c2, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb
BLE Advertised Device found: Name: , Address: 5f:10:6a:42:e6:d2, manufacturer data: 4c001005131c33007b, txPower: 12
BLE Advertised Device found: Name: , Address: 18:d6:d8:bb:65:2a, manufacturer data: 0600010920029135cec705616ecd8281250bdf9ea1669fd5da210ffeee
BLE Advertised Device found: Name: Bean, Address: 80:ea:ca:03:07:01, manufacturer data: aaaa80eaca030701, serviceUUID: 00001802-0000-1000-8000-00805f9b34fb
BLE Advertised Device found: Name: , Address: 02:9c:d3:6b:11:5e, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Attempting to connect to: 02:9c:d3:6b:11:5e ...[02:9c:d3:6b:11:5e] Connected
- Connected to server
Connect took 1113ms
BLE Advertised Device found: Name: FITNESS, Address: f0:d4:f7:8f:2e:ae, serviceUUID: d973f2e3-b19e-11e2-9e96-f0d4f78f2eae
BLE Advertised Device found: Name: , Address: 04:69:f8:99:91:af, manufacturer data: 4c000906030000000000
BLE Advertised Device found: Name: , Address: 15:0e:5e:d0:17:21, manufacturer data: 4c00090603300a2a0015
BLE Advertised Device found: Name: , Address: 18:d6:d8:bb:65:2a, manufacturer data: 0600010920029135cec705616ecd8281250bdf9ea1669fd5da210ffeee
BLE Advertised Device found: Name: , Address: 17:90:73:17:e4:c0, manufacturer data: 4c00090603330a2a0014
BLE Advertised Device found: Name: , Address: 61:c7:5a:ec:89:b0, manufacturer data: 060001092002a3b212c5b137be43887ca9ff292108748c08abccd39576
BLE Advertised Device found: Name: , Address: 5f:10:6a:42:e6:d2, manufacturer data: 4c001005131c33007b, txPower: 12
BLE Advertised Device found: Name: , Address: 78:ad:07:2b:84:c2, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb
[ 02:9c:d3:6b:11:5e] AM43 Send: 00FF00009A170222B815
BLE Advertised Device found: Name: , Address: 40:cb:c0:d8:a1:d0, manufacturer data: 4c0010050d14eab84e, txPower: 12
BLE Advertised Device found: Name: , Address: 24:fc:e5:b1:7a:e5, manufacturer data: 7500420401806024fce5b17ae526fce5b17ae401000000000000
BLE Advertised Device found: Name: , Address: 02:37:8d:55:9a:4a, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Attempting to connect to: 02:37:8d:55:9a:4a ...[02:37:8d:55:9a:4a] Connected
- Failed to connect.
BLE Advertised Device found: Name: FITNESS, Address: f0:d4:f7:8f:2e:ae, serviceUUID: d973f2e3-b19e-11e2-9e96-f0d4f78f2eae
BLE Advertised Device found: Name: , Address: 15:0e:5e:d0:17:21, manufacturer data: 4c00090603300a2a0015
BLE Advertised Device found: Name: , Address: 40:cb:c0:d9:de:20, manufacturer data: 4c0010050214228291, txPower: 12
BLE Advertised Device found: Name: , Address: 18:d6:d8:bb:65:2a, manufacturer data: 0600010920029135cec705616ecd8281250bdf9ea1669fd5da210ffeee
BLE Advertised Device found: Name: , Address: 24:fc:e5:b1:7a:e5, manufacturer data: 7500420401806024fce5b17ae526fce5b17ae401000000000000
BLE Advertised Device found: Name: , Address: 5f:10:6a:42:e6:d2, manufacturer data: 4c001005131c33007b, txPower: 12
BLE Advertised Device found: Name: , Address: 62:f6:3e:71:ee:a9, manufacturer data: 4c000c0e084366afaff72174a446c5925cf110067b1eab7ecc6a
BLE Advertised Device found: Name: , Address: 17:90:73:17:e4:c0, manufacturer data: 4c00090603330a2a0014
BLE Advertised Device found: Name: , Address: 02:56:f9:b6:02:3e, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Ignoring device ⸮0⸮?U, not in allow listBLE Advertised Device found: Name: , Address: 04:69:f8:99:91:af, manufacturer data: 4c000906030000000000
BLE Advertised Device found: Name: , Address: 78:ad:07:2b:84:c2, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb
[ 02:9c:d3:6b:11:5e] AM43 Send: 00FF00009A170222B815
BLE Advertised Device found: Name: , Address: 40:cb:c0:d8:a1:d0, manufacturer data: 4c0010050d14eab84e, txPower: 12
BLE Advertised Device found: Name: , Address: 61:c7:5a:ec:89:b0, manufacturer data: 060001092002a3b212c5b137be43887ca9ff292108748c08abccd39576
[ 02:9c:d3:6b:11:5e] AM43 Send: 00FF00009A170222B815
BLE Advertised Device found: Name: , Address: 02:37:8d:55:9a:4a, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Attempting to connect to: 02:37:8d:55:9a:4a ...Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x401d284d PS : 0x00060c30 A0 : 0x800d8a90 A1 : 0x3ffde560
A2 : 0x3fff0ebc A3 : 0x3fff026c A4 : 0x3fff21a8 A5 : 0x3ffde60c
A6 : 0x3fff1c04 A7 : 0x3ffde648 A8 : 0x01000100 A9 : 0x3ffde5c0
A10 : 0x3fff0f10 A11 : 0x3fff0ebc A12 : 0x3ffef894 A13 : 0x3ffde60c
A14 : 0x3ffef894 A15 : 0x3ffde648 SAR : 0x00000018 EXCCAUSE: 0x0000001c
EXCVADDR: 0x01000118 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
Backtrace: 0x401d284d:0x3ffde560 0x400d8a8d:0x3ffde580 0x400d95d1:0x3ffde630 0x4014ac1a:0x3ffde680 0x401438d2:0x3ffde6d0 0x4008e689:0x3ffde700
Rebooting...
ets Jun 8 2016 00:22:57
Same kind of error, this time it did call abort and print the stack:
PC: 0x401d284d: AM43Client::onDisconnect(BLEClient*) at D:\OneDrive\Documents\Arduino\libraries\am43-master\src\AM43Client.cpp line 36
EXCVADDR: 0x01000118
Decoding stack results
0x401d284d: AM43Client::onDisconnect(BLEClient*) at D:\OneDrive\Documents\Arduino\libraries\am43-master\src\AM43Client.cpp line 36
0x400d8a8d: BLEClient::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEClient.cpp line 186
0x400d95d1: BLEDevice::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEDevice.cpp line 167
0x4014ac1a: btc_gattc_cb_handler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c line 31
0x401438d2: btc_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/core/btc_task.c line 110
0x4008e689: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
System is now completely unstable for me also. Constantly restarting in the logs
@MrBigleg which version were you previously on? Did you also update the example code or just the main library code?
I think perhaps theres an issue with the example? @buxtronix are you using the example code in your application?
I noticed that in the callback, many of the serial.printfs are passing toString() and not toString().c_str()
Changing this fixed the debug output, but I still see the same errors with onDisconnect:
Core 0 register dump:
PC : 0x00000000 PS : 0x00060c30 A0 : 0x800d8a90 A1 : 0x3ffde560
A2 : 0x3fff027c A3 : 0x3fff0520 A4 : 0x3fff14dc A5 : 0x3ffde60c
A6 : 0x3ffef3bc A7 : 0x3ffde648 A8 : 0x801d2852 A9 : 0x3ffde5c0
A10 : 0x3fff02d0 A11 : 0x3fff027c A12 : 0x3ffef5c8 A13 : 0x3ffde60c
A14 : 0x3ffef5c8 A15 : 0x3ffde648 SAR : 0x00000018 EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
Backtrace: 0x00000000:0x3ffde560 0x400d8a8d:0x3ffde580 0x400d95d1:0x3ffde630 0x4014ac1a:0x3ffde680 0x401438d2:0x3ffde6d0 0x4008e689:0x3ffde700
PC: 0x00000000
EXCVADDR: 0x00000000
Decoding stack results
0x400d8a8d: BLEClient::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEClient.cpp line 186
0x400d95d1: BLEDevice::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEDevice.cpp line 167
0x4014ac1a: btc_gattc_cb_handler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c line 31
0x401438d2: btc_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/core/btc_task.c line 110
0x4008e689: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
BLE Advertised Device found: Name: Bedroom M-R, Address: 02:87:42:46:69:88, manufacturer data: 0000, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Attempting to connect to: 02:87:42:46:69:88 ...[02:37:8d:55:9a:4a] Disconnected
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0xffffffff PS : 0x00060230 A0 : 0x800d8a90 A1 : 0x3ffde560
A2 : 0x3fff23f0 A3 : 0x3fff2ea0 A4 : 0x3fff02c0 A5 : 0x3ffde60c
A6 : 0x3ffee6f0 A7 : 0x3ffde648 A8 : 0x801d2852 A9 : 0x3ffde5c0
A10 : 0x3fff2c7c A11 : 0x3fff23f0 A12 : 0x3ffefda8 A13 : 0x3ffde60c
A14 : 0x3ffefda8 A15 : 0x3ffde648 SAR : 0x00000018 EXCCAUSE: 0x00000014
EXCVADDR: 0xfffffffc LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
Backtrace: 0x7fffffff:0x3ffde560 0x400d8a8d:0x3ffde580 0x400d95d1:0x3ffde630 0x4014ac1a:0x3ffde680 0x401438d2:0x3ffde6d0 0x4008e689:0x3ffde700
PC: 0xffffffff
EXCVADDR: 0xfffffffc
Decoding stack results
0x400d8a8d: BLEClient::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEClient.cpp line 186
0x400d95d1: BLEDevice::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEDevice.cpp line 167
0x4014ac1a: btc_gattc_cb_handler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c line 31
0x401438d2: btc_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/core/btc_task.c line 110
0x4008e689: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
All of the crashes / reboots seem to occur on disconnect, while it is currently scanning and connecting to devices.
If and when it finally connects to all of the devices it seems to operate fairly stable.
@adotagarwal I have been keeping up to date on each incremental version for the last week, the last version was the memory leak fix.
I had a separate issue where the blind was opening if at position 0 but I think it was my error and a mistake in Node-Red. I have always had disconnect (device unavailable) issues. But have only been using this for about a week
i think you should change the example code so that it correctly prints the two log lines: Serial.printf("Ignoring advertising device %s, already present\r\n", advertisedDevice.toString().c_str());
and
Serial.printf("Ignoring device %s, not in allow list", advertisedDevice.toString().c_str());
with this change, the restarts are much less frequent (i've noticed in other projects too that passing garbage to serial print will often corrupt memory in the esp)
I still get the issue with disconnect, it seems like it sometimes gets stuck and sometimes crashes: It always seems to happen during discovery and while connecting to one device and disconnecting from another
BLE Advertised Device found: Name: Bedroom M-L, Address: 02:56:f9:b6:02:3e, manufacturer data: 0000, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Attempting to connect to: 02:56:f9:b6:02:3e ...Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x401d284d PS : 0x00060c30 A0 : 0x800d8a90 A1 : 0x3ffdeaa0
A2 : 0x3ffeff68 A3 : 0x3fff02c4 A4 : 0x3ffef218 A5 : 0x3ffdeb4c
A6 : 0x3ffef218 A7 : 0x3ffdeb88 A8 : 0x00000000 A9 : 0x3ffdeb00
A10 : 0x3fff06a8 A11 : 0x3ffeff68 A12 : 0x3fff0bbc A13 : 0x3ffdeb4c
A14 : 0x3fff0bbc A15 : 0x3ffdeb88 SAR : 0x00000018 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000018 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000
Backtrace: 0x401d284d:0x3ffdeaa0 0x400d8a8d:0x3ffdeac0 0x400d95d1:0x3ffdeb70 0x4014ac1a:0x3ffdebc0 0x401438d2:0x3ffdec10 0x4008e689:0x3ffdec40
PC: 0x401d284d: AM43Client::onDisconnect(BLEClient*) at D:\OneDrive\Documents\Arduino\libraries\am43-master\src\AM43Client.cpp line 36
EXCVADDR: 0x00000018
Decoding stack results
0x401d284d: AM43Client::onDisconnect(BLEClient*) at D:\OneDrive\Documents\Arduino\libraries\am43-master\src\AM43Client.cpp line 36
0x400d8a8d: BLEClient::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEClient.cpp line 186
0x400d95d1: BLEDevice::gattClientEventHandler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*) at D:\OneDrive\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.4\libraries\BLE\src\BLEDevice.cpp line 167
0x4014ac1a: btc_gattc_cb_handler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c line 31
0x401438d2: btc_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/core/btc_task.c line 110
0x4008e689: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
" I still get the issue with disconnect, it seems like it sometimes gets stuck and sometimes crashes: It always seems to happen during discovery and while connecting to one device and disconnecting from another "
I was experiencing this many times until I attached an external antenna. And it still happens if the controller is moved farther away from the motors.
" I still get the issue with disconnect, it seems like it sometimes gets stuck and sometimes crashes: It always seems to happen during discovery and while connecting to one device and disconnecting from another "
I was experiencing this many times until I attached an external antenna. And it still happens if the controller is moved farther away from the motors.
Thanks - i don't think this has anything to do with the range at all. First, the devices are able to be controlled consistently from the range at which I am debugging with console -- once they finally connect and make it past a discovery cycle. Furthermore, the devices still lock up and freeze when placed within a foot of the windows.
I have a feeling the problem is within the BLE library, not the AM43 code. In fact, after poking around with the code paths with disconnect events, I think I may have discovered the issue.
Within BLEClient.cpp the code calls the following to update a PeerDevice map within BLEDevice:
https://github.com/espressif/arduino-esp32/blob/master/libraries/BLE/src/BLEClient.cpp#L101 BLEDevice::addPeerDevice(this, true, m_appId);
https://github.com/espressif/arduino-esp32/blob/master/libraries/BLE/src/BLEClient.cpp#L191 BLEDevice::removePeerDevice(m_appId, true);
https://github.com/espressif/arduino-esp32/blob/master/libraries/BLE/src/BLEClient.cpp#L237 BLEDevice::updatePeerDevice(this, true, m_gattc_if);
When you look into the implementation of those functions, it's clear that the latter call should have 'm_appId' as the last parameter, not m_gattc_if.
Can you change this and test?
Also, there are some fixes in the latest repo update here, so worth re-fetching.
Let me try and integrate the latest changes, I do see the printfs have been fixed there, and try the patches mentioned above.
@Kite-Smurf i ordered some 32us that have an external antenna and will try with those as well.
Just a short term update from me. I live in Thailand so most likely a different timezone to many here, irrelevant but when I woke up this morning the latest version with the additional BLE edit had just been put up.
It is now the end of the day and I have had no noticeable disconnects or erratic behavior, all day in my HA logs.
I will monitor over the weekend and share my experience.
Have a good weekend...
***Edit I closed the blinds fully shortly after writing this post. The system disconnected and hasn't been able to reconnect since. Around an hour. I have restarted the ESP a couple of times but it refuses to reconnect.
I am getting the following repeating over and over...
Starting Arduino BLE Client application... Wifi connecting to: xxxxxx ... [WiFi-event] event: 0 [WiFi-event] event: 2 AllowList contains the following device(s): Mac: 02:ba:58:19:2c:d3 [WiFi-event] event: 4 [WiFi-event] event: 7 WiFi connected IP address: 192.168.1.150 Attempting MQTT connection...BLE Advertised Device found: Name: , Address: 4f:24:4d:aa:33:c9, manufacturer data: 06000109210a40f70837c6d04d494e492d5043 BLE Advertised Device found: Name: , Address: dc:a2:66:5c:32:22, manufacturer data: 2d01020001105a2e9b0b2afe4f2eb3fe7f775ead6c1874326189a5af BLE Advertised Device found: Name: , Address: 49:a4:d9:82:de:00, manufacturer data: 06000109210aec3271666c6043524149472d4445534b544f50 connected BLE Advertised Device found: Name: , Address: 6c:02:d5:c0:97:35, manufacturer data: e000015cca500b36, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb MQTT [am43/restart]1: 0 Addr: restart Cmd: am43/restart BLE Advertised Device found: Name: , Address: 0d:35:2e:6e:aa:a6, manufacturer data: 4c0009060322c0a80249 BLE Advertised Device found: Name: , Address: 08:66:98:95:49:f5, manufacturer data: 4c000f08c00aca014400400b10020104, txPower: 12 [WiFi-event] event: 3 [WiFi-event] event: 3 ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:1 load:0x3fff0018,len:4 load:0x3fff001c,len:1216 ho 0 tail 12 room 4 load:0x40078000,len:9720 ho 0 tail 12 room 4 load:0x40080400,len:6352 entry 0x400806b8 Starting Arduino BLE Client application...
A few updates: @Kite-Smurf - the esp32u's came and as suspected did not improve the situation at all. I now have some fairly impressive antennas with a little esp attached at the end :)
@buxtronix : as a side note, without this change my system ran well overnight but by this morning had disconnected a few blinds.
I have some new suspicions:
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 100
[02:9c:d3:6b:11:5e] Got battery: 100
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 96
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 100
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 100
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 100
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 96
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 100
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
I am not sure if its a side effect of the change or not, but I did notice that when it locks up connect, it still maintains the callbacks for the bleclient:
BLE Advertised Device found: Name: FITNESS, Address: f0:d4:f7:8f:2e:ae, serviceUUID: d973f2e3-b19e-11e2-9e96-f0d4f78f2eae
BLE Advertised Device found: Name: , Address: 17:90:73:17:e4:c0, manufacturer data: 4c00090603330a2a0014
BLE Advertised Device found: Name: , Address: 04:69:f8:99:91:af, manufacturer data: 4c000906030000000000
BLE Advertised Device found: Name: 5852A704D31333A3E9, Address: e7:e7:a2:71:26:d3, appearance: 0, manufacturer data: a7050311536f6e6f735f696b644a64, serviceUUID: 0000fe07-0000-1000-8000-00805f9b34fb, txPower: 0
BLE Advertised Device found: Name: , Address: 24:fc:e5:b1:7a:e5, manufacturer data: 7500420401806024fce5b17ae526fce5b17ae401000000000000
BLE Advertised Device found: Name: , Address: 40:cb:c0:d9:de:20, manufacturer data: 4c0010050214228291, txPower: 12
BLE Advertised Device found: Name: , Address: 60:78:7a:37:fc:b0, manufacturer data: 4c001005131c0d8167, txPower: 12
[Bedroom Right 02:9c:d3:6b:11:5e] AM43 Send: 00FF00009AA701013D
[02:9c:d3:6b:11:5e] Got position: 4
[Bedroom Right 02:9c:d3:6b:11:5e] Unknown reply: 9AA80F015F7F060001007F120001377F170028
[Bedroom Right 02:9c:d3:6b:11:5e] Unknown reply: 9AA9100000001100000000010000110000000022
BLE Advertised Device found: Name: , Address: 63:9a:19:12:f4:fe, manufacturer data: 06000109200207c9be4ce4ee9446e440c4690e9ab5e824f504581ecb4e
BLE Advertised Device found: Name: Bedroom M-R, Address: 02:87:42:46:69:88, manufacturer data: 0000, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Attempting to connect to: 02:87:42:46:69:88 ... **LONG PAUSE** [02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 96
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 96
[02:9c:d3:6b:11:5e] Got battery: 97
[02:9c:d3:6b:11:5e] Got battery: 97
** APP UNRESPONSIVE, MQTT callbacks not firing**
That change didnt result in any difference in behavior as far as I could tell. It may have made it a bit less stable.
Given the program just stops executing sometimes, could it be that there are momentarily more than 3 devices attempting to be connected to, despite having three in the allow list? Perhaps a duplicate ( I do see it trying the same sensor a few times in the same scan, despite updating BLEScan.cpp) I believe I read that the behavior is to stop executing.
Perhaps there is a way to ensure it both a) keeps its own connection count and b) stops scanning if all three connections are in use
Separately, I think there is an issue where the blinds get into a state where you need to open simply open the BlindEngine app to "reset" them.
@MrBigleg I see the following in the log:
MQTT [am43/restart]1: 0
Something is sending a restart/reboot command over mqtt it seems.
Also your device doesnt seem to show up in the scan..is something else connected, eg Blinds Engine app? The device doesnt send out advertisement packets while connected to a client.
@adotagarwal The issue with freezing during connect whilst still responding to BLE callbacks, it seems that something in BLEClient::connect is never returning. Maybe due to more than 3 trying to be connected to? Many of the bugs I've encountered so far have been within the BLE library, this could be another.
I can look at applying a patch to count connections and not attempt > 3, this may improve things. I'll do that over the weekend. I had the battery message spamming issue at times, seems mostly when the power supply is plugged in and the battery is full.
I've just committed the change limiting connections to three.
So I woke up this moning an it appears the blind has been coonected almost without issue all night just one short 5min disconnect.
I'm also see strange things in the serial monitor...
BLE scan complete. [Blind 02:ba:58:19:2c:d3] AM43 Send: 00FF00009AA2010138 [02ba58192cd3] Got battery: 100 [Blind 02:ba:58:19:2c:d3] AM43 Send: 00FF00009AA701013D [02ba58192cd3] Got position: 0 [Blind 02:ba:58:19:2c:d3] Unknown reply: 9AA80032 [Blind 02:ba:58:19:2c:d3] Unknown reply: 9AA9100000001100000000010000110000000022 BLE Advertised Device found: Name: , Address: 64:41:ca:7b:73:77, manufacturer data: 06000109210a40f70837c6d04d494e492d5043 BLE Advertised Device found: Name: , Address: 7d:27:32:ed:59:b3, manufacturer data: 06000109210aec3271666c6043524149472d4445534b544f50 BLE Advertised Device found: Name: , Address: 71:03:1a:db:84:61, manufacturer data: e000015cca500b36, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb BLE Advertised Device found: Name: , Address: dc:a2:66:5c:32:22, serviceUUID: cbbfe0e1-f7f3-4206-84e0-84cbb3d09dfc BLE Advertised Device found: Name: MJ_HT_V1, Address: 58:2d:34:32:d7:1f, serviceUUID: 0000180f-0000-1000-8000-00805f9b34fb BLE Advertised Device found: Name: Flower care, Address: c4:7c:8d:6a:5b:5c, serviceUUID: 0000fe95-0000-1000-8000-00805f9b34fb BLE Advertised Device found: Name: , Address: 74:19:1c:9f:20:4f, manufacturer data: 4c0010050918b50925, txPower: 12 BLE Advertised Device found: Name: Flower care, Address: c4:7c:8d:6a:51:5a, serviceUUID: 0000fe95-0000-1000-8000-00805f9b34fb BLE scan complete. [Blind 02:ba:58:19:2c:d3] AM43 Send: 00FF00009AAA010130 [02ba58192cd3] Got light: 50 [Blind 02:ba:58:19:2c:d3] AM43 Send: 00FF00009AA2010138 [02ba58192cd3] Got battery: 100 BLE Advertised Device found: Name: , Address: 64:41:ca:7b:73:77, manufacturer data: 06000109210a40f70837c6d04d494e492d5043 BLE Advertised Device found: Name: , Address: dc:a2:66:5c:32:22, serviceUUID: cbbfe0e1-f7f3-4206-84e0-84cbb3d09dfc BLE Advertised Device found: Name: , Address: 7d:27:32:ed:59:b3, manufacturer data: 06000109210aec3271666c6043524149472d4445534b544f50 BLE Advertised Device found: Name: , Address: 71:03:1a:db:84:61, manufacturer data: e000015cca500b36, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb BLE Advertised Device found: Name: Flower care, Address: c4:7c:8d:6a:51:5a, serviceUUID: 0000fe95-0000-1000-8000-00805f9b34fb BLE Advertised Device found: Name: , Address: 74:19:1c:9f:20:4f, manufacturer data: 4c0010050918b50925, txPower: 12 BLE Advertised Device found: Name: Flower care, Address: c4:7c:8d:6a:5b:5c, serviceUUID: 0000fe95-0000-1000-8000-00805f9b34fb BLE Advertised Device found: Name: MJ_HT_V1, Address: 58:2d:34:32:d7:1f, serviceUUID: 0000180f-0000-1000-8000-00805f9b34fb BLE scan complete. [Blind 02:ba:58:19:2c:d3] AM43 Send: 00FF00009AA701013D [02ba58192cd3] Got position: 0 [Blind 02:ba:58:19:2c:d3] Unknown reply: 9AA80032 [Blind 02:ba:58:19:2c:d3] Unknown reply: 9AA9100000001100000000010000110000000022
am43/restart
Very strange, this was an inject node that I set up when I was first testing it, it shouldn't trigger on its own. I've now disabled it. Similar to my other 'issue' that I closed. Very odd that Node-Red was triggering these without input.
[Blind 02:ba:58:19:2c:d3] Unknown reply: 9AA80032
[Blind 02:ba:58:19:2c:d3] Unknown reply: 9AA9100000001100000000010000110000000022
This is fine, when the code requests position from the device, it returns two other packets containing the config. These are ignore now but expected.
@buxtronix so I picked up that change and it doesn't seem related to the cls size, however, i did more digging and here's what I found.
I turned on info level core logging, and noticed that it always gets stuck after this log line (To which ive added the current cls size):
BLE Advertised Device found: Name: Bedroom Right, Address: 02:9c:d3:6b:11:5e, manufacturer data: 0000, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb
Trying to connect to Name: Bedroom Right, Address: 02:9c:d3:6b:11:5e, manufacturer data: 0000, serviceUUID: 0000fe50-0000-1000-8000-00805f9b34fb [1 devices used]
Attempting to connect to: 02:9c:d3:6b:11:5e ...[I][BLEDevice.cpp:593] addPeerDevice(): add conn_id: 3, GATT role: client
When I look in the code, I see that in BLEClient, it is waiting for a semaphore to be available:
bool BLEClient::connect(BLEAddress address, esp_ble_addr_type_t type) {
log_v(">> connect(%s)", address.toString().c_str());
// We need the connection handle that we get from registering the application. We register the app
// and then block on its completion. When the event has arrived, we will have the handle.
m_appId = BLEDevice::m_appId++;
BLEDevice::addPeerDevice(this, true, m_appId);
m_semaphoreRegEvt.take("connect");
// clearServices(); // we dont need to delete services since every client is unique?
esp_err_t errRc = ::esp_ble_gattc_app_register(m_appId);
if (errRc != ESP_OK) {
log_e("esp_ble_gattc_app_register: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
return false;
}
m_semaphoreRegEvt.wait("connect");
When i search for other usages of that semaphore, i see that it is signaled on register and theres a take and wait in the connect function. What is the difference between take and wait?
Im guessing that either the register event is never fired or is fired before the semaphore waits?
Since I don't have as much knowledge of the BLE stack as you do, are you able to extrapolate anything from this?
The line of code is: BLEClient.cpp:102
AM43 controller keeps stopping when multiple clients are in range. (three at this time) log files available here: Download link