Description
My heap is slowly getting eaten up over time. This is ultimately causing a reboot of the device over time. I get the following issues.
Backtrace: 0x40083845:0x3fff1d70 0x400940b1:0x3fff1d90 0x40099cd1:0x3fff1db0 0x4017a3fb:0x3fff1e30 0x4017a442:0x3fff1e50 0x4017b1b1:0x3fff1e70 0x4017a568:0x3fff1e90 0x4018abe1:0x3fff1eb0 0x4018f41e:0x3fff1ef0 0x4018f83c:0x3fff1f60 0x40194f26:0x3fff1f80 0x40194d0a:0x3fff1fc0 0x40195144:0x3fff1fe0 0x4019376d:0x3fff2000 0x40090a46:0x3fff2020 0x40188f2a:0x3fff2040
#0 0x40083845:0x3fff1d70 in panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:408
#1 0x400940b1:0x3fff1d90 in esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:137
#2 0x40099cd1:0x3fff1db0 in abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/abort.c:46
#3 0x4017a3fb:0x3fff1e30 in pbus_rx_dco_cal_1step at /home/cff/gittree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7_cal.c:729
#4 0x4017a442:0x3fff1e50 in pbus_rx_dco_cal_1step at /home/cff/gittree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7_cal.c:738
#5 0x4017b1b1:0x3fff1e70 in ram_rfcal_pwrctrl at /home/cff/gittree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7_cal.c:1685
#6 0x4017a568:0x3fff1e90 in pbus_rx_dco_cal_1step at /home/cff/gittree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7_cal.c:769 (discriminator 1)
#7 0x4018abe1:0x3fff1eb0 in NimBLEDevice::setSecurityAuth(unsigned char) at .pio/libdeps/adafruit_feather_esp32_v2/NimBLE-Arduino/src/NimBLEDevice.cpp:1021
#8 0x4018f41e:0x3fff1ef0 in ble_att_svr_fill_type_value at .pio/libdeps/adafruit_feather_esp32_v2/NimBLE-Arduino/src/nimble/nimble/host/src/ble_att_svr.c:1159
#9 0x4018f83c:0x3fff1f60 in ble_att_svr_prev_handle at .pio/libdeps/adafruit_feather_esp32_v2/NimBLE-Arduino/src/nimble/nimble/host/src/ble_att_svr.c:143
#10 0x40194f26:0x3fff1f80 in ble_gatts_count_cfg at .pio/libdeps/adafruit_feather_esp32_v2/NimBLE-Arduino/src/nimble/nimble/host/src/ble_gatts.c:2161
#11 0x40194d0a:0x3fff1fc0 in ble_gatts_chr_updated at .pio/libdeps/adafruit_feather_esp32_v2/NimBLE-Arduino/src/nimble/nimble/host/src/ble_gatts.c:1612
#12 0x40195144:0x3fff1fe0 in ble_hs_timer_sched at .pio/libdeps/adafruit_feather_esp32_v2/NimBLE-Arduino/src/nimble/nimble/host/src/ble_hs.c:482
#13 0x4019376d:0x3fff2000 in ble_gattc_disc_chr_uuid_rx_adata at .pio/libdeps/adafruit_feather_esp32_v2/NimBLE-Arduino/src/nimble/nimble/host/src/ble_gattc.c:2487
#14 0x40090a46:0x3fff2020 in ble_npl_event_run at .pio/libdeps/adafruit_feather_esp32_v2/NimBLE-Arduino/src/nimble/porting/npl/freertos/include/nimble/nimble_npl_os.h:526
(inlined by) nimble_port_run at .pio/libdeps/adafruit_feather_esp32_v2/NimBLE-Arduino/src/nimble/porting/nimble/src/nimble_port.c:319
#15 0x40188f2a:0x3fff2040 in std::enable_if<std::_and<std::_not<std::__is_tuple_like<unsigned char*> >, std::is_move_constructible<unsigned char*>, std::is_move_assignable<unsigned char*> >::value, void>::type std::swap<unsigned char*>(unsigned char*&, unsigned char*&) at c:\users\scoth.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\bits/move.h:194
(inlined by) std::_Vector_base<unsigned char, std::allocator >::_Vector_impl::_M_swap_data(std::_Vector_base<unsigned char, std::allocator >::_Vector_impl&) at c:\users\scoth.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\bits/stl_vector.h:112
(inlined by) std::vector<unsigned char, std::allocator >::swap(std::vector<unsigned char, std::allocator >&) at c:\users\scoth.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\bits/stl_vector.h:1373
(inlined by) NimBLEAdvertising::setManufacturerData(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&) at .pio/libdeps/adafruit_feather_esp32_v2/NimBLE-Arduino/src/NimBLEAdvertising.cpp:159
Is there a way to track this down?
I believe it might be related to this function in my code
void BLEAppInterface_startAdvertising() {
if (!pAdvertising) {
pAdvertising = NimBLEDevice::getAdvertising();
} else {
pAdvertising->stop(); // Ensure previous advertising is stopped
}
if (!isUUIDAdded) {
try {
pAdvertising->addServiceUUID(pFireplaceControlService->getUUID());
isUUIDAdded = true;
} catch (const std::bad_alloc& e) {
Serial.println("Failed to add Service UUID to Advertising: Out of Memory");
return;
} catch (...) {
Serial.println("Failed to add Service UUID to Advertising: Unknown Error");
return;
}
}
uint8_t currentTick = _getCurrentTick();
uint8_t currentStatus = _getCurrentStatus();
uint8_t currentTankLevel = _getCurrentTankLevel();
uint8_t currentFuelConsumption = _getCurrentFuelConsumption();
// Check if there are changes in the values (excluding currentTick)
if (currentStatus == previousStatus &&
currentTankLevel == previousTankLevel &&
currentFuelConsumption == previousFuelConsumption) {
Serial.println("No changes in advertising data, skipping advertising.");
return;
}
uint8_t Adv_DATA[] = {
0x7f, 0x01, // build ManufacturerData
0x7e, 0x88, 0xfd,
currentTick,
0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab,
currentStatus, currentTankLevel, currentFuelConsumption, 0x00, 0x00, _getCurrentTankSize()
};
std::string manufacturerData(reinterpret_cast<char*>(Adv_DATA), sizeof(Adv_DATA));
pAdvertising->setManufacturerData(manufacturerData); // Only one argument now
pAdvertising->setScanResponse(true);
pAdvertising->start();
Serial.println("Advertising Started");
// Update previous values
previousStatus = currentStatus;
previousTankLevel = currentTankLevel;
previousFuelConsumption = currentFuelConsumption;
}