-
-
Notifications
You must be signed in to change notification settings - Fork 172
increasing heap consumption over time #694
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
Comments
I'm assuming you found the issue? Was it something in the library? |
I made a mistake with some connection for my BLE HID remote. It seems to be fixed and had nothing to do with the App implementation side of the code. The heap is now under control. I do have a reconnection issue though. I am almost giving up on getting this remote to reconnect after a reboot of the esp32... |
Thanks. What is happening with reconnecting? Some changes were made lately to help reconnecting with bonded devices. |
It does not seem to do it at all actually. Once i restart i need to have a button pressed on the remote. If not no device is shown which seems okay. I guess the remote is going in to sleep mode if no button is pressed for X time. I use a slightly modified version of the "NimBLE_client.ino" example to accomodate the HID spec. #include "remote.h" static uint32_t scanTime = 0; // Scan time in seconds int bleServers = 0; static NimBLEUUID batteryServiceUUID("180F"); extern bool remoteDebug; void setHexStr(const char* value) { const char* getHexStr() { /** None of these are required as they will be handled by the library with defaults. **
void AdvertisedDeviceCallbacks::onResult(NimBLEAdvertisedDevice *ad) { void handleBatteryLevelNotification(uint8_t* data, size_t length) {
} void handleHIDNotification(uint8_t* data, size_t length) {
} void buttonPressCallback(NimBLERemoteCharacteristic* characteristic, uint8_t* data, size_t length, bool is_notify) {
} void scanEndedCB(NimBLEScanResults results) { static ClientCallbacks clientCB; bool connectToServer() {
} void initRemoteClient(bool initDevice) {
} void remoteTick() { |
Now i have got it to reconnect. I had a variable declared at bool and not static bool which somehow made the difference. Yay. Now i am keen to find a faster reconnect. It seems to need to rediscover all characteristics and resubscribe after a reboot. Is this needed? Should it save the device information for the next reconnect? |
Great! Yes, when reconnecting you should set the deleteAttributes parameter to false so you won't need to discover them again. |
the one you are referring to is this one right?
|
here is the whole function just for reference bool connectToServer() {
} |
i can also see that this NimBLEDevice::getClientListSize() Returns a 0 so it does not seem to be stored |
i can see that after a successful connection is made with the connect to server that a bond if formed and the ClientListSize is increased by 1. The data is not persistent between reboots though |
By pulling the battery of the remote and inserting again and not rebooting i can reconnect. But the code performs a full discovery again |
The attributes are not stored in flash, only bond info is if enabled, so you would need to do discovery after reboot. |
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
}
}
The text was updated successfully, but these errors were encountered: