Abort on BLEAddress tostring
Posted: Thu Dec 15, 2022 7:00 pm
I am scanning for BLE devices. When I check to see if it is a device that I am looking for, I print a message to the serial log. Every now and then, the ESP32 reboots because of an abort. The backtrace shows the problem is with the tostring function on BLEAddress. Any ideas?
Here is my decode of the trace:
Code: Select all
#include <BLEDevice.h>
#define allowed_devices "ff:ff:20:00:26:53,ff:ff:80:02:13:f9,e9:99:8d:f2:65:ce,f9:54:a9:22:48:0d"
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
void onResult(BLEAdvertisedDevice advertisedDevice) {
if (strstr(allowed_devices,advertisedDevice.getAddress().toString().c_str()) != NULL) {
ble_found = true;
if (!ble_connected) {
ble_device = String(advertisedDevice.getName().c_str());
char strBuf[100];
sprintf(strBuf, "Device authorized %s(%s) %i", advertisedDevice.getName().c_str(),advertisedDevice.getAddress().toString().c_str(),rssi);
PRINTLN(strBuf);
ble_connected = true;
}
} // onResult
}; // MyAdvertisedDeviceCallbacks
// When scanning complete, start all over again looking for a device
void ScanCompleteCB(BLEScanResults scanResults) {
if (!ble_found and ble_connected) {
ble_connected = false;
}
start_scan = true;
} // scanCompleteCB
void setup() {
pBLEScan = BLEDevice::getScan();
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true);
}
// Main processing loop
void loop() {
if (start_scan) {
ble_found = false;
pBLEScan->start(5, ScanCompleteCB, false);
// PRINTLN("Starting BLE scan");
// wifi_send(t_state,"Starting BLE scan");
start_scan = false;
0x4008f670: invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 156
0x4008f8ed: abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c line 171
0x401ccbff: __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc line 47
0x401ccc46: std::terminate() at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_terminate.cc line 57
0x401cc56d: __cxxabiv1::__cxa_allocate_exception(std::size_t) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/eh_alloc.cc line 268
0x401cc648: operator new(unsigned int) at /builds/idf/crosstool-NG/.build/src/gcc-5.2.0/libstdc++-v3/libsupc++/new_op.cc line 54
0x401cdab5: std::__cxx11::basic_string, std::allocator >::_M_create(unsigned int&, unsigned int) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/ext/new_allocator.h line 104
0x401cdd03: std::__cxx11::basic_string, std::allocator >::reserve(unsigned int) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/bits/basic_string.tcc line 297
0x401daa46: std::__cxx11::basic_stringbuf, std::allocator >::overflow(int) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/bits/sstream.tcc line 114
0x401cd2aa: std::basic_streambuf >::xsputn(char const*, int) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/bits/streambuf.tcc line 98
0x401f60d5: std::basic_streambuf >::sputn(char const*, int) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/streambuf line 451
0x401d5d61: std::__write(std::ostreambuf_iterator >, char const*, int) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/bits/streambuf_iterator.h line 282
0x401d6613: std::num_put > >::_M_insert_int(std::ostreambuf_iterator >, std::ios_base&, char, long) const at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/bits/locale_facets.tcc line 933
0x401d6647: std::num_put > >::do_put(std::ostreambuf_iterator >, std::ios_base&, char, long) const at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/bits/locale_facets.h line 2510
0x401f6ba1: std::num_put > >::put(std::ostreambuf_iterator >, std::ios_base&, char, long) const at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/bits/locale_facets.h line 2371
0x401ce5f9: std::ostream::_M_insert(long) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/bits/ostream.tcc line 73
0x401ce69d: std::ostream::operator(int) at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/build/build-cc-gcc-final/xtensa-esp32-elf/libstdc++-v3/include/bits/ostream.tcc line 112
0x400d4b06: BLEAddress::toString[abi:cxx11]() at D:\Documents\Arduino\libraries\ESP32_BLE_Arduino\src\BLEAddress.cpp line 87
0x400d713f: BLEScan::handleGAPEvent(esp_gap_ble_cb_event_t, esp_ble_gap_cb_param_t*) at D:\Documents\Arduino\libraries\ESP32_BLE_Arduino\src\BLEScan.cpp line 101
0x400d605a: BLEDevice::gapEventHandler(esp_gap_ble_cb_event_t, esp_ble_gap_cb_param_t*) at D:\Documents\Arduino\libraries\ESP32_BLE_Arduino\src\BLEDevice.cpp line 272
0x40124c7d: btc_gap_ble_cb_handler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c line 54
0x4011e642: btc_task at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/bt/common/btc/core/btc_task.c line 163
0x40090962: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143