krzmaz / LinakDeskEsp32Controller

Standalone ESP32 controller for Linak standing desks (e.g. Ikea Idasen) with HTTP API and Alexa integration
MIT License
33 stars 2 forks source link

Get height causing reboot #7

Closed SeraphimSerapis closed 3 years ago

SeraphimSerapis commented 3 years ago

After successfully connecting to my desk (using a Linak DPG1M004-00) and WiFi, I ran getHeight to get my device's current height. This is what I got, followed by a rebooting ESP32.

abort() was called at PC 0x40086b3f on core 0

ELF file SHA256: 0000000000000000

Backtrace: 0x40090e99:0x3fff0f60 0x40091261:0x3fff0f80 0x40086b3f:0x3fff0fa0 0x40086c5e:0x3fff0fc0 0x4014ca0a:0x3fff0fe0 0x40149b17:0x3fff1100 0x4014ca89:0x3fff1410 0x400863a1:0x3fff1440 0x400863c9:0x3fff1470 0x400f0425:0x3fff14c0 0x401081b6:0x3fff1530 0x400fd7e1:0x3fff1560 0x400fd9a8:0x3fff15b0 0x40118e31:0x3fff15d0 0x40119241:0x3fff15f0 0x4011c2c5:0x3fff1630 0x4011c339:0x3fff1650 0x400995da:0x3fff1670 0x40092fa9:0x3fff16a0
  #0  0x40090e99:0x3fff0f60 in invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:155
  #1  0x40091261:0x3fff0f80 in abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:172
  #2  0x40086b3f:0x3fff0fa0 in lock_init_generic at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/locks.c:81
  #3  0x40086c5e:0x3fff0fc0 in _lock_init_recursive at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/newlib/locks.c:95
  #4  0x4014ca0a:0x3fff0fe0 in __sbprintf at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/vfprintf.c:476
  #5  0x40149b17:0x3fff1100 in _vfprintf_r at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/vfprintf.c:868 (discriminator 5)
  #6  0x4014ca89:0x3fff1410 in vprintf at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/newlib/newlib/libc/stdio/vprintf.c:34
  #7  0x400863a1:0x3fff1440 in esp_log_writev at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/log/log.c:216
  #8  0x400863c9:0x3fff1470 in esp_log_write at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/log/log.c:225
  #9  0x400f0425:0x3fff14c0 in wifi_log at ??:?
  #10 0x401081b6:0x3fff1530 in ieee80211_getmgtframe at ??:?
  #11 0x400fd7e1:0x3fff1560 in ieee80211_encap_null_data at ??:?
  #12 0x400fd9a8:0x3fff15b0 in ieee80211_pm_tx_null_process at ??:?
  #13 0x40118e31:0x3fff15d0 in pm_go_to_wake at ??:?
  #14 0x40119241:0x3fff15f0 in pm_tbtt_process at ??:?
  #15 0x4011c2c5:0x3fff1630 in dbg_lmac_init at ??:?
  #16 0x4011c339:0x3fff1650 in pp_timer_do_process at ??:?
  #17 0x400995da:0x3fff1670 in ppTask at ??:?
  #18 0x40092fa9:0x3fff16a0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:143

Any clues what may cause this behavior?

SeraphimSerapis commented 3 years ago

This is the stacktrace I get when running moveToHeight?destination=700:

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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1364
load:0x40078000,len:12656
load:0x40080400,len:3512
entry 0x40080624
Connecting to desk: E9:43:60:EC:13:9A
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
Name:
Tim Desk
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 03 01 8F 1A 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 07 01 7B 12 B3 BE 08 00 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 07 01 82 04 15 24 00 00 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 05 00 FF FF FF FF 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 11 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 00 
connected
Connecting to WiFi
..
WiFi connected!
Got IP: 192.168.20.240
HTTP server started
abort() was called at PC 0x4016e1f7 on core 1

ELF file SHA256: 0000000000000000

Backtrace: 0x40090e99:0x3fffee40 0x40091261:0x3fffee60 0x4016e1f7:0x3fffee80 0x4016e23e:0x3fffeea0 0x4015576d:0x3fffeec0 0x401555a4:0x3fffeee0 0x400d2b75:0x3fffef00 0x400d425d:0x3fffef60 0x400d432d:0x3fffefa0 0x400d4545:0x3fffefe0 0x401709ba:0x3ffff000 0x40170a3d:0x3ffff030 0x401711a6:0x3ffff050 0x40092fa9:0x3ffff080
  #0  0x40090e99:0x3fffee40 in invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:155
  #1  0x40091261:0x3fffee60 in abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:172
  #2  0x4016e1f7:0x3fffee80 in __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
  #3  0x4016e23e:0x3fffeea0 in std::terminate() at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57
  #4  0x4015576d:0x3fffeec0 in __cxa_allocate_exception at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_alloc.cc:300
  #5  0x401555a4:0x3fffeee0 in operator new(unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/new_op.cc:54
  #6  0x400d2b75:0x3fffef00 in AsyncWebServerRequest::_parseReqHeader() at .pio/libdeps/esp32dev/ESP Async WebServer/src/WebRequest.cpp:349
  #7  0x400d425d:0x3fffef60 in AsyncWebServerRequest::_parseLine() at .pio/libdeps/esp32dev/ESP Async WebServer/src/WebRequest.cpp:585
  #8  0x400d432d:0x3fffefa0 in AsyncWebServerRequest::_onData(void*, unsigned int) at .pio/libdeps/esp32dev/ESP Async WebServer/src/WebRequest.cpp:123
  #9  0x400d4545:0x3fffefe0 in operator() at .pio/libdeps/esp32dev/ESP Async WebServer/src/WebRequest.cpp:76
      (inlined by) _M_invoke at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:297
  #10 0x401709ba:0x3ffff000 in AsyncClient::_recv(tcp_pcb*, pbuf*, signed char) at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:687
      (inlined by) AsyncClient::_recv(tcp_pcb*, pbuf*, signed char) at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:915
  #11 0x40170a3d:0x3ffff030 in AsyncClient::_s_recv(void*, tcp_pcb*, pbuf*, signed char) at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:1191
  #12 0x401711a6:0x3ffff050 in _handle_async_event at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:159
      (inlined by) _async_service_task at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:194
  #13 0x40092fa9:0x3ffff080 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:143

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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1364
load:0x40078000,len:12656
load:0x40080400,len:3512
entry 0x40080624
Connecting to desk: E9:43:60:EC:13:9A
Couldn't connect to desk!
krzmaz commented 3 years ago

Hey, thanks for giving my project a try! :)

First thing that comes to my mind is that you may have a different set of dependencies considering esp32-arduino-lib-builder and /builds/idf/crosstool-NG/ in paths of your sources - I don't have those.

Could you share some details regarding your local setup? What are you building on, and if you may be reusing some dependencies from other projects?

SeraphimSerapis commented 3 years ago

Thank you for the swift response. It's much appreciated!

I'm building on a MBP 16" running Big Sur 11.2.2. I recently received this as a new machine and this is one of the first few ESP projects I'm building, so I am not sure if any of the overhead you noticed may come from that.

My setup is VSCode into PlatformIO 5.0.4 and starting with a clean build from there.

I tried building https://github.com/j5lien/esphome-idasen-desk-controller and a few other EPSHome issues, but ran into similar issues on this platform. As the project's author states he took heavy inspiration from your project, I figured I reach out to you first.

I'm terribly new to building for ESPs/Arduino outside the ESPHome universe, so if there is anything you'd need me to run: I'm all ears! :)

Thanks again for your help!

krzmaz commented 3 years ago

It may be a BigSur thing, as I am on a MBP as well, just Catalina 10.15.7... (I haven't switched yet due to being afraid of platform problems šŸ˜… )

For starters as you have previously played around with ESPhome things, I'd recommend removing as much of ESP related things as you are comfortable with, and letting platformio download and build all that's needed.

I've just checked out the repo to a new location, removed everything ESP related from ~/.platformio/platforms and ~/.platformio/packages and did a rebuild, and everything works...

Here is the log for you to compare: fresh_install.log

Make sure the platform and toolchain are properly installed and compare yours PLATFORM, HARDWARE and PACKAGES sections. Also check the versions of

|-- <ESP Async WebServer> 1.2.3
|   |-- <AsyncTCP> 1.1.1

because I recall that there were some problems with those libraries

As I cannot reproduce the problem, I most likely won't be able to help you a lot, but let me know if you have any new questions or findings! Good luck!

krzmaz commented 3 years ago

@SeraphimSerapis One additional thing I've noticed is that after reboot you get Couldn't connect to desk! which is odd as for me ESP is always able to reconnect after reboot if the desk is not connected to no other device. Are you sure that your BT connection is stable? When you manually reboot the ESP board does it reconnect?

SeraphimSerapis commented 3 years ago

I noticed that, too. It doesn't seem to keep the connection persistently, but I haven't figured out why. I noticed this across different ESP boards. Might be some weird controller thing. I'll reset tomorrow and will build from scratch as you suggested and will keep you posted.

Thanks again for being so helpful!

krzmaz commented 3 years ago

One thing you can also do if the fresh build doesn't help is to play with different debug log levels set here: https://github.com/TheRealMazur/LinakDeskEsp32Controller/blob/main/platformio.ini#L28

You can add , log2file to monitor filters in line 25 to have the serial output written to file, as there will be a lot of it šŸ˜‰

Let me know how it goes, I want to make this software work with as many devices as possible! šŸ˜

SeraphimSerapis commented 3 years ago

Thanks again for your help. I reset my desk, removed conflicting platformio versions and did some more housekeeping -- now the ESP32 reconnects to the desk but I still get a crash every time I run the get or move command.

WiFi connected!
Got IP: 192.168.20.201
HTTP server started
abort() was called at PC 0x4016e1f7 on core 0

ELF file SHA256: 0000000000000000

Backtrace: 0x40090e99:0x3ffef280 0x40091261:0x3ffef2a0 0x4016e1f7:0x3ffef2c0 0x4016e23e:0x3ffef2e0 0x4015576d:0x3ffef300 0x401555a4:0x3ffef320 0x40170c7a:0x3ffef340 0x40170d18:0x3ffef370 0x401396c9:0x3ffef390 0x4013a2b5:0x3ffef3c0 0x40131746:0x3ffef3f0 0x401377e5:0x3ffef410 0x40127b2d:0x3ffef430 0x40127bac:0x3ffef450 0x40092fa9:0x3ffef480
  #0  0x40090e99:0x3ffef280 in invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:155
  #1  0x40091261:0x3ffef2a0 in abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:172
  #2  0x4016e1f7:0x3ffef2c0 in __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
  #3  0x4016e23e:0x3ffef2e0 in std::terminate() at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57
  #4  0x4015576d:0x3ffef300 in __cxa_allocate_exception at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_alloc.cc:300
  #5  0x401555a4:0x3ffef320 in operator new(unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/new_op.cc:54
  #6  0x40170c7a:0x3ffef340 in AsyncServer::_accept(tcp_pcb*, signed char) at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:1297
  #7  0x40170d18:0x3ffef370 in AsyncServer::_s_accept(void*, tcp_pcb*, signed char) at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:1333
  #8  0x401396c9:0x3ffef390 in tcp_process at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/tcp_in.c:941 (discriminator 1)
  #9  0x4013a2b5:0x3ffef3c0 in tcp_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/tcp_in.c:438
  #10 0x40131746:0x3ffef3f0 in ip4_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/core/ipv4/ip4.c:784
  #11 0x401377e5:0x3ffef410 in ethernet_input at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/netif/ethernet.c:186
  #12 0x40127b2d:0x3ffef430 in tcpip_thread_handle_msg at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c:180
  #13 0x40127bac:0x3ffef450 in tcpip_thread at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/api/tcpip.c:154
  #14 0x40092fa9:0x3ffef480 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:143

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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1364
load:0x40078000,len:12656
load:0x40080400,len:3512
entry 0x40080624
Connecting to desk: E9:43:60:EC:13:9A
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
Name:
Tim Desk
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 03 01 90 1A 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 07 01 7B 12 B3 BE 08 00 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 07 01 82 04 15 24 00 00 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 05 00 FF FF FF FF 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 11 01 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 00 
connected
Connecting to WiFi
.
WiFi connected!
Got IP: 192.168.20.201
HTTP server started

Here is my build log:

> Executing task: platformio run <

Processing esp32dev (platform: https://github.com/platformio/platform-espressif32.git#feature/idf-v4.0; board: esp32dev; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (1.12.1+sha.833f645) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES: 
 - framework-arduino-esp32 0.0.0+sha.beedeea 
 - framework-arduinoespressif32 0.0.0+sha.d011dd7 
 - tool-esptoolpy 1.30000.201119 (3.0.0) 
 - toolchain-xtensa32 3.80200.200512 (8.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 29 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ESP Async WebServer> 1.2.3
|   |-- <AsyncTCP> 1.1.1
|   |-- <FS> 1.0
|   |-- <WiFi> 1.0
|-- <LinakDeskEmbedded>
|   |-- <LinakDeskCore>
|   |-- <ESP32 BLE Arduino> 1.0.1
|-- <ESPmDNS> 1.0
|   |-- <WiFi> 1.0
|-- <WiFi> 1.0
Building in release mode
Compiling .pio/build/esp32dev/src/main.cpp.o
Generating partitions .pio/build/esp32dev/partitions.bin
Compiling .pio/build/esp32dev/lib586/AsyncTCP/AsyncTCP.cpp.o
Compiling .pio/build/esp32dev/liba82/FS/FS.cpp.o
Compiling .pio/build/esp32dev/liba82/FS/vfs_api.cpp.o
Compiling .pio/build/esp32dev/lib6af/WiFi/ETH.cpp.o
Compiling .pio/build/esp32dev/lib6af/WiFi/WiFi.cpp.o
Compiling .pio/build/esp32dev/lib6af/WiFi/WiFiAP.cpp.o
Compiling .pio/build/esp32dev/lib6af/WiFi/WiFiClient.cpp.o
Compiling .pio/build/esp32dev/lib6af/WiFi/WiFiGeneric.cpp.o
Compiling .pio/build/esp32dev/lib6af/WiFi/WiFiMulti.cpp.o
Compiling .pio/build/esp32dev/lib6af/WiFi/WiFiSTA.cpp.o
Compiling .pio/build/esp32dev/lib6af/WiFi/WiFiScan.cpp.o
Compiling .pio/build/esp32dev/lib6af/WiFi/WiFiServer.cpp.o
Archiving .pio/build/esp32dev/liba82/libFS.a
Indexing .pio/build/esp32dev/liba82/libFS.a
Compiling .pio/build/esp32dev/lib6af/WiFi/WiFiUdp.cpp.o
Compiling .pio/build/esp32dev/libeae/ESP Async WebServer/AsyncEventSource.cpp.o
Compiling .pio/build/esp32dev/libeae/ESP Async WebServer/AsyncWebSocket.cpp.o
Compiling .pio/build/esp32dev/libeae/ESP Async WebServer/SPIFFSEditor.cpp.o
Compiling .pio/build/esp32dev/libeae/ESP Async WebServer/WebAuthentication.cpp.o
Archiving .pio/build/esp32dev/lib586/libAsyncTCP.a
Compiling .pio/build/esp32dev/libeae/ESP Async WebServer/WebHandlers.cpp.o
Indexing .pio/build/esp32dev/lib586/libAsyncTCP.a
Compiling .pio/build/esp32dev/libeae/ESP Async WebServer/WebRequest.cpp.o
Compiling .pio/build/esp32dev/libeae/ESP Async WebServer/WebResponses.cpp.o
Compiling .pio/build/esp32dev/libeae/ESP Async WebServer/WebServer.cpp.o
Compiling .pio/build/esp32dev/lib3d5/LinakDeskCore/DeskController.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLE2902.cpp.o
Archiving .pio/build/esp32dev/lib6af/libWiFi.a
Indexing .pio/build/esp32dev/lib6af/libWiFi.a
Compiling .pio/build/esp32dev/lib10c/BLE/BLE2904.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEAddress.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEAdvertisedDevice.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEAdvertising.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEBeacon.cpp.o
Archiving .pio/build/esp32dev/lib3d5/libLinakDeskCore.a
Compiling .pio/build/esp32dev/lib10c/BLE/BLECharacteristic.cpp.o
Indexing .pio/build/esp32dev/lib3d5/libLinakDeskCore.a
Compiling .pio/build/esp32dev/lib10c/BLE/BLECharacteristicMap.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEClient.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEDescriptor.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEDescriptorMap.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEDevice.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEEddystoneTLM.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEEddystoneURL.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEExceptions.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEHIDDevice.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLERemoteCharacteristic.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLERemoteDescriptor.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLERemoteService.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEScan.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLESecurity.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEServer.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEService.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEServiceMap.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEUUID.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEUtils.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/BLEValue.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/FreeRTOS.cpp.o
Compiling .pio/build/esp32dev/lib10c/BLE/GeneralUtils.cpp.o
Compiling .pio/build/esp32dev/lib43d/LinakDeskEmbedded/BluetoothConnection.cpp.o
Compiling .pio/build/esp32dev/lib7ee/ESPmDNS/ESPmDNS.cpp.o
Archiving .pio/build/esp32dev/libFrameworkArduinoVariant.a
Indexing .pio/build/esp32dev/libFrameworkArduinoVariant.a
Compiling .pio/build/esp32dev/FrameworkArduino/Esp.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/FunctionalInterrupt.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/IPAddress.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/IPv6Address.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/MD5Builder.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/Print.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/Stream.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/StreamString.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/WMath.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/WString.cpp.o
Archiving .pio/build/esp32dev/lib10c/libBLE.a
Compiling .pio/build/esp32dev/FrameworkArduino/base64.cpp.o
Compiling .pio/build/esp32dev/FrameworkArduino/cbuf.cpp.o
Indexing .pio/build/esp32dev/lib10c/libBLE.a
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-adc.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-bt.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-cpu.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-dac.c.o
Archiving .pio/build/esp32dev/lib7ee/libESPmDNS.a
Indexing .pio/build/esp32dev/lib7ee/libESPmDNS.a
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-gpio.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-i2c.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-ledc.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-matrix.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-misc.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-psram.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-rmt.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-sigmadelta.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-spi.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-time.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-timer.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-touch.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/esp32-hal-uart.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/libb64/cdecode.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/libb64/cencode.c.o
Archiving .pio/build/esp32dev/lib43d/libLinakDeskEmbedded.a
Compiling .pio/build/esp32dev/FrameworkArduino/main.cpp.o
Indexing .pio/build/esp32dev/lib43d/libLinakDeskEmbedded.a
Compiling .pio/build/esp32dev/FrameworkArduino/stdlib_noniso.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/wiring_pulse.c.o
Compiling .pio/build/esp32dev/FrameworkArduino/wiring_shift.c.o
Archiving .pio/build/esp32dev/libeae/libESP Async WebServer.a
Indexing .pio/build/esp32dev/libeae/libESP Async WebServer.a
Archiving .pio/build/esp32dev/libFrameworkArduino.a
Indexing .pio/build/esp32dev/libFrameworkArduino.a
Linking .pio/build/esp32dev/firmware.elf
Building .pio/build/esp32dev/firmware.bin
Retrieving maximum program size .pio/build/esp32dev/firmware.elf
Checking size .pio/build/esp32dev/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  17.0% (used 55708 bytes from 327680 bytes)
Flash: [========  ]  83.8% (used 1757936 bytes from 2097152 bytes)
esptool.py v3.0
=================================================================================== [SUCCESS] Took 29.77 seconds ===================================================================================

Environment    Status    Duration
-------------  --------  ------------
esp32dev       SUCCESS   00:00:29.768
=================================================================================== 1 succeeded in 00:00:29.768 ===================================================================================

Terminal will be reused by tasks, press any key to close it.

My hunch is that my controller might not match the Ikea idasen commands and therefore doesn't seem to comply with whatever my poor ESP32 sends via BLE.

krzmaz commented 3 years ago

Hmm as all your backtraces point towards the AsyncWebServer stuff, I'd like to check if the connection works when invoked manually. Could you apply this diff and run the code? getHeightAfterConnect.txt

If it works you can add controller.moveToHeight with a value near to the current height, to see if that works as well.

I was planning to improve the controller to work in more async fashion anyway, so I might have more code for you to test later this week šŸ˜

SeraphimSerapis commented 3 years ago

It seems like at least the initial connection works:

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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1364
load:0x40078000,len:12656
load:0x40080400,len:3512
entry 0x40080624
Connecting to desk: E9:43:60:EC:13:9A
Couldn't connect to desk!
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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1364
load:0x40078000,len:12656
load:0x40080400,len:3512
entry 0x40080624
Connecting to desk: E9:43:60:EC:13:9A
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
Name:
Tim Desk
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 03 01 90 1A 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 07 01 53 04 A0 0E 8F 01 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 07 01 D8 11 B3 0E 8F 01 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 05 00 FF FF FF FF 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 11 01 D2 31 58 2C 8A F9 43 BE B3 EC 35 A9 A5 18 FF 1A 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 00 
connected
Current height: 1108
Getting height and printing it took: 174ms
Connecting to WiFi
..
WiFi connected!
Got IP: 192.168.20.201
HTTP server started

I then added controller.moveToHeight(1300) and that seemed to work:

--- Miniterm on /dev/cu.usbserial-0001  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ad:0x3fff001ļæ½Kļæ½ļæ½ļæ½ļæ½j
load:0x40078000,len:12656
load:0x40080400,len:3512
entry 0x40080624
Connecting to desk: E9:43:60:EC:13:9A
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
Name:
Tim Desk
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 03 01 90 1A 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 07 01 53 04 A0 0E 8F 01 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 07 01 D8 11 B3 0E 8F 01 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 05 00 FF FF FF FF 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 11 01 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 00 
connected
Current height: 1108
Getting height and printing it took: 113ms
Control response:

Control response:

Input response:

Notify callback for HeightSpeed: Height: 1109 Speed: 656
Input response:
Notify callback for HeightSpeed: Height: 1112 Speed: 1008
Notify callback for HeightSpeed: Height: 1117 Speed: 1392
Notify callback for HeightSpeed: Height: 1120 Speed: 1584

Notify callback for HeightSpeed: Height: 1129 Speed: 2048
Notify callback for HeightSpeed: Height: 1139 Speed: 2448
Notify callback for HeightSpeed: Height: 1146 Speed: 2720
Input response:
Notify callback for HeightSpeed: Height: 1158 Speed: 3104
Notify callback for HeightSpeed: Height: 1172 Speed: 3504
Notify callback for HeightSpeed: Height: 1185 Speed: 3840

Notify callback for HeightSpeed: Height: 1198 Speed: 4160
Notify callback for HeightSpeed: Height: 1214 Speed: 4496
Notify callback for HeightSpeed: Height: 1233 Speed: 4880
Input response:
Notify callback for HeightSpeed: Height: 1244 Speed: 5088
Notify callback for HeightSpeed: Height: 1266 Speed: 4080

Notify callback for HeightSpeed: Height: 1281 Speed: 3056
Input response:
Notify callback for HeightSpeed: Height: 1289 Speed: 2336
Notify callback for HeightSpeed: Height: 1296 Speed: 1296
Notify callback for HeightSpeed: Height: 1299 Speed: 768
Notify callback for HeightSpeed: Height: 1300 Speed: 0

Connecting to WiFi

It seems like indeed the webserver seems to be causing the problems, not the actual code you use to control the desk.

krzmaz commented 3 years ago

Okay, that seems to narrow down the problem. I'm surprised that getting the height via http request doesn't work for you, since it takes below 200ms, which should be reasonable for the async server... BTW do you see a lot of fluctuation in the handling time of getting height? I see in your logs 174ms and 113ms. With my controller it is always within couple of ms around 120ms...

Another thing we should test is to check whether it is a general problem with the web server or a problem with the interaction between the web server and desk controller. Could you add this code:

        server.on("/heap", HTTP_GET, [](AsyncWebServerRequest *request){
          request->send(200, "text/plain", String(ESP.getFreeHeap()));
        });

above or below other calls to server.on in setup?

Doing curl 192.168.20.201/heap you should get the amount of free heap (for me it's around 24000).

Also, looking around the internet for possible root causes I've stumbled upon answers suggesting that the problems may be related with the hardware itself, especially we should look into the way your ESP is powered. When doing a lot of communication - both BT and WiFi, the ESP could experience voltage drops leading to weird behavior. Could you double check with different microUSB cables and different power sources (i.e. power bank instead of USB port)? Just to rule that one out šŸ˜›

SeraphimSerapis commented 3 years ago
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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1364
load:0x40078000,len:12656
load:0x40080400,len:3512
entry 0x40080624
Connecting to desk: E9:43:60:EC:13:9A
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[E][BLERemoteCharacteristic.cpp:275] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
Name:
Tim Desk
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 03 01 90 1A 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 07 01 53 04 A0 0E 8F 01 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 07 01 D8 11 B3 0E 8F 01 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 05 00 FF FF FF FF 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 11 01 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 
Notify callback for characteristic: 99fa0011-338a-1024-8a49-009c0215f78a
Data: 01 00 
connected
Current height: 4568
Getting height and printing it took: 115ms
Connecting to WiFi
..
WiFi connected!
Got IP: 192.168.20.201
HTTP server started
abort() was called at PC 0x4016ec13 on core 1

ELF file SHA256: 0000000000000000

Backtrace: 0x40090e99:0x3ffff110 0x40091261:0x3ffff130 0x4016ec13:0x3ffff150 0x4016ec5a:0x3ffff170 0x40156189:0x3ffff190 0x40155fc0:0x3ffff1b0 0x400d2d41:0x3ffff1d0 0x400d43fd:0x3ffff230 0x400d44cd:0x3ffff270 0x400d46e5:0x3ffff2b0 0x401713d6:0x3ffff2d0 0x40171459:0x3ffff300 0x40171bc2:0x3ffff320 0x40092fa9:0x3ffff350
  #0  0x40090e99:0x3ffff110 in invoke_abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:155
  #1  0x40091261:0x3ffff130 in abort at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/panic.c:172
  #2  0x4016ec13:0x3ffff150 in __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
  #3  0x4016ec5a:0x3ffff170 in std::terminate() at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57
  #4  0x40156189:0x3ffff190 in __cxa_allocate_exception at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_alloc.cc:300
  #5  0x40155fc0:0x3ffff1b0 in operator new(unsigned int) at /builds/idf/crosstool-NG/.build/HOST-x86_64-apple-darwin12/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/new_op.cc:54
  #6  0x400d2d41:0x3ffff1d0 in AsyncWebServerRequest::_parseReqHeader() at .pio/libdeps/esp32dev/ESP Async WebServer/src/StringArray.h:67 (discriminator 3)
      (inlined by) AsyncWebServerRequest::_parseReqHeader() at .pio/libdeps/esp32dev/ESP Async WebServer/src/WebRequest.cpp:349 (discriminator 3)
  #7  0x400d43fd:0x3ffff230 in AsyncWebServerRequest::_parseLine() at .pio/libdeps/esp32dev/ESP Async WebServer/src/WebRequest.cpp:585
  #8  0x400d44cd:0x3ffff270 in AsyncWebServerRequest::_onData(void*, unsigned int) at .pio/libdeps/esp32dev/ESP Async WebServer/src/WebRequest.cpp:123
  #9  0x400d46e5:0x3ffff2b0 in operator() at .pio/libdeps/esp32dev/ESP Async WebServer/src/WebRequest.cpp:76
      (inlined by) _M_invoke at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:297
  #10 0x401713d6:0x3ffff2d0 in AsyncClient::_recv(tcp_pcb*, pbuf*, signed char) at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:687
      (inlined by) AsyncClient::_recv(tcp_pcb*, pbuf*, signed char) at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:915
  #11 0x40171459:0x3ffff300 in AsyncClient::_s_recv(void*, tcp_pcb*, pbuf*, signed char) at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:1191
  #12 0x40171bc2:0x3ffff320 in _handle_async_event at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:159
      (inlined by) _async_service_task at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:194
  #13 0x40092fa9:0x3ffff350 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:143

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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1364
load:0x40078000,len:12656
load:0x40080400,len:3512
entry 0x40080624
Connecting to desk: E9:43:60:EC:13:9A
Couldn't connect to desk!

Another crash when I try calling /heap after adding the server.on line.

I tried a hotspot to rule out firewall snafu. The difference in latency probably comes from: "Does Tim stand between the ESP32 and the desk or not".

krzmaz commented 3 years ago

Okay, from __cxa_allocate_exception I'm assuming that your ESP may be running out of heap memory, so let's check that by adding this code in loop():

    static unsigned long last = millis();
    if (millis() - last > 5000) {
        last = millis();
        Serial.printf("[MAIN] Free heap: %d bytes\n", ESP.getFreeHeap());
    }

If the values printed there will be around 20000 as in my case, please enable core debug logs as mentioned here: https://github.com/TheRealMazur/LinakDeskEsp32Controller/issues/7#issuecomment-794420088 and let's see if there are any useful information logged when you do curl 192.168.20.201/heap

SeraphimSerapis commented 3 years ago

It says [MAIN] Free heap: 124420 bytes.

I also changed platformio.ini to

build_flags = 
  ; -DCORE_DEBUG_LEVEL=5, log2file
  -std=gnu++17
  -Wall
  -Wextra

Where would I define the file to log to? Or is this a flag that automatically creates that log file?

krzmaz commented 3 years ago

Hmm, that's a interestingly high amount of free heap memory, what is the ESP board you are using?

To enable the logs, you need to change line 25 to: monitor_filters = esp32_exception_decoder, log2file and uncomment (remove the ;) from line 28:

[env:esp32dev]
platform = https://github.com/platformio/platform-espressif32.git#feature/idf-v4.0
platform_packages =
  ; use upstream Git version
  framework-arduino-esp32 @ https://github.com/espressif/arduino-esp32#idf-release/v4.2

board = esp32dev
framework = arduino
monitor_filters = esp32_exception_decoder, log2file
monitor_speed = 115200
build_flags = 
  -DCORE_DEBUG_LEVEL=5
  -std=gnu++17
  -Wall
  -Wextra
build_unflags = -std=gnu++11
upload_speed = 921600
board_build.partitions = no_ota.csv
; debug_tool = esp-prog
; upload_protocol = esp-prog
; debug_init_break = tbreak setup
lib_deps = 
  me-no-dev/ESP Async WebServer @ ^1.2.3

The logs will be saved to a file with a timestamp in the name whenever you open the serial port monitor

krzmaz commented 3 years ago

Regarding hardware - could you look if you get similar data in your upload logs?

Looking for upload port...
Auto-detected: /dev/cu.usbserial-0205C8D6
Uploading .pio/build/esp32dev/firmware.bin
esptool.py v3.0
Serial port /dev/cu.usbserial-0205C8D6
Connecting....
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
SeraphimSerapis commented 3 years ago

This is taken right out of my logs:

Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [==        ]  17.1% (used 55960 bytes from 327680 bytes)
Flash: [========  ]  84.8% (used 1778120 bytes from 2097152 bytes)
esptool.py v3.0
Configuring upload protocol...
AVAILABLE: esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port...
Auto-detected: /dev/cu.usbserial-0001
Uploading .pio/build/esp32dev/firmware.bin
esptool.py v3.0
Serial port /dev/cu.usbserial-0001
Connecting........____
Chip is ESP32-D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz

The board I use is this one from Amazon (produced by AZDelivery - ESP-WROOM-32).

SeraphimSerapis commented 3 years ago

And here is the debug log you asked for: platformio-device-monitor-210311-113934.log

krzmaz commented 3 years ago

Okay, from the log, this is the line we could investigate, there seems to be a timeout in _poll function of AsyncTCP.cpp right before the reboot: [W][AsyncTCP.cpp:950] _poll(): rx timeout 4

One other thing is that your board seems to have more RAM that the default esp32dev I'm using. I've found info on a preconfigured setup for that manufacturer's board here: https://docs.platformio.org/en/latest/boards/espressif32/az-delivery-devkit-v4.html#board-espressif32-az-delivery-devkit-v4

Could you change the board value in platformio.ini as follows?

[env:esp32dev]
platform = https://github.com/platformio/platform-espressif32.git#feature/idf-v4.0
platform_packages =
  ; use upstream Git version
  framework-arduino-esp32 @ https://github.com/espressif/arduino-esp32#idf-release/v4.2

board = az-delivery-devkit-v4
framework = arduino

and test it?

SeraphimSerapis commented 3 years ago

Done! The result seems to match the previous behavior noticed: platformio-device-monitor-210311-125057.log

krzmaz commented 3 years ago

Hmmm yeah, but there is definitely something wird going on with the amount of free heap memory available to the MCU - grepping the previous log shows:

[MAIN] Free heap: 14748 bytes
[MAIN] Free heap: 14748 bytes
[MAIN] Free heap: 14748 bytes
[MAIN] Free heap: 13288 bytes
[MAIN] Free heap: 124208 bytes
[MAIN] Free heap: 124208 bytes
[MAIN] Free heap: 124208 bytes
[MAIN] Free heap: 124208 bytes
[MAIN] Free heap: 124208 bytes
[MAIN] Free heap: 124208 bytes

and for me it shows constantly values around 24000...

I see that your Amazon link is for 3 pieces - have you tested the code on multiple boards? My German is a bit rusty, but I saw a comment mentioning problems with connectivity on the board...

If you tested on multiple boards then it may be a problem with configuration - it may require special configuration based on https://github.com/platformio/platform-espressif32/blob/master/boards/az-delivery-devkit-v4.json ... I really don't want to be that guy to recommend this, but it may be quicker to just get boards from a different manufacturer šŸ˜¶

SeraphimSerapis commented 3 years ago

I tried this on 2 out of 3 boards (1 is out of reach right now) and agree that I may have to buy a different board (or two) to see if they work better.

Thanks again for your help!

SeraphimSerapis commented 3 years ago

What I missed to say is: thank you for your helpfulness and the work you put into this project. It's very much appreciated! šŸŽ‰

krzmaz commented 3 years ago

Thanks, glad to read this šŸ˜Š

Hope that new boards will work without problems!

krzmaz commented 3 years ago

@SeraphimSerapis Were you able to get the controller working with different ESP32 boards? I've just posted an update changing the BLE library, which saved about 100kB of heap in runtime, and reduced the program size removing the need of custom partitions. If you have the time to test it, I'd appreciate the feedback on the latest version :)

SeraphimSerapis commented 3 years ago

@TheRealMazur Thank you for checking! I ordered a different board (same manufacturer) but ran into the same issue. I also ordered some other boards from other manufacturers but am not sure when they'll be delivered. They might be stuck somewhere on the Suez Canal šŸ˜†

I'll test your code tomorrow and will keep you posted on how things go!

SeraphimSerapis commented 3 years ago

Uploaded the new version and running into the following stacktrace:

Config file was successfully parsed
W (1238) wifi:Haven't to connect to a suitable AP now!
After waiting 0.50 secs , Connection result is 3
Local IP: 192.168.20.85
HTTP server started
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x40164121  PS      : 0x00060c30  A0      : 0x800e6398  A1      : 0x3ffe7ea0  
A2      : 0x3ffe7ef4  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x3ffe7ef4  
A6      : 0xfffffffc  A7      : 0x3ffe0498  A8      : 0x80094746  A9      : 0x3ffe7ee0  
A10     : 0x00000000  A11     : 0x3ffe0478  A12     : 0x000020c4  A13     : 0x3ffe1e8c  
A14     : 0x00000001  A15     : 0xfffffffc  SAR     : 0x00000018  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000020  LBEG    : 0x4008edc9  LEND    : 0x4008edd9  LCOUNT  : 0xfffffff8  

ELF file SHA256: 0000000000000000

Backtrace: 0x4016411e:0x3ffe7ea0 0x400e6395:0x3ffe7ef0 0x400e63da:0x3ffe7f30 0x400e5f1c:0x3ffe7f50 0x400d1738:0x3ffe7f70 0x40196f8d:0x3ffe7fa0 0x400ddbd4:0x3ffe7fc0 0x400dde7b:0x3ffe8040 0x400dc909:0x3ffe8090 0x400db32e:0x3ffe80d0 0x400dbdc9:0x3ffe8110 0x400d2481:0x3ffe8150 0x400de0be:0x3ffe8190 0x400dbfa9:0x3ffe81d0 0x400dc0c1:0x3ffe8210 0x400dc2d9:0x3ffe8250 0x400d7bfe:0x3ffe8270 0x400d7c95:0x3ffe82a0 0x400d831e:0x3ffe82c0 0x40091189:0x3ffe82f0
  #0  0x4016411e:0x3ffe7ea0 in NimBLERemoteCharacteristic::readValue[abi:cxx11](long*) at .pio/libdeps/esp32dev/NimBLE-Arduino/src/NimBLERemoteCharacteristic.cpp:418
  #1  0x400e6395:0x3ffe7ef0 in unsigned short NimBLERemoteCharacteristic::readValue<unsigned short>(long*, bool) at .pio/libdeps/esp32dev/NimBLE-Arduino/src/NimBLERemoteCharacteristic.h:78
  #2  0x400e63da:0x3ffe7f30 in LinakDesk::BluetoothConnection::getHeightMm() const at lib/LinakDeskEmbedded/BluetoothConnection.cpp:122
  #3  0x400e5f1c:0x3ffe7f50 in LinakDesk::DeskController::getHeightMm() const at lib/LinakDeskCore/DeskController.cpp:39
  #4  0x400d1738:0x3ffe7f70 in html::processor(String const&) at src/html.h:25
  #5  0x40196f8d:0x3ffe7fa0 in std::_Function_handler<String (String const&), String (*)(String const&)>::_M_invoke(std::_Any_data const&, String const&) at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:283
  #6  0x400ddbd4:0x3ffe7fc0 in AsyncAbstractResponse::_fillBufferAndProcessTemplates(unsigned char*, unsigned int) at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:687
      (inlined by) AsyncAbstractResponse::_fillBufferAndProcessTemplates(unsigned char*, unsigned int) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebResponses.cpp:441
  #7  0x400dde7b:0x3ffe8040 in AsyncAbstractResponse::_ack(AsyncWebServerRequest*, unsigned int, unsigned int) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebResponses.cpp:315
  #8  0x400dc909:0x3ffe8090 in AsyncAbstractResponse::_respond(AsyncWebServerRequest*) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebResponses.cpp:261 (discriminator 2)
  #9  0x400db32e:0x3ffe80d0 in AsyncWebServerRequest::send(AsyncWebServerResponse*) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebRequest.cpp:725
  #10 0x400dbdc9:0x3ffe8110 in AsyncWebServerRequest::send_P(int, String const&, char const*, std::function<String (String const&)>) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebRequest.cpp:804
  #11 0x400d2481:0x3ffe8150 in operator() at src/main.cpp:212
      (inlined by) _M_invoke at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:297
  #12 0x400de0be:0x3ffe8190 in AsyncCallbackWebHandler::handleRequest(AsyncWebServerRequest*) at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:687
      (inlined by) AsyncCallbackWebHandler::handleRequest(AsyncWebServerRequest*) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebHandlerImpl.h:132
  #13 0x400dbfa9:0x3ffe81d0 in AsyncWebServerRequest::_parseLine() at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebRequest.cpp:581 (discriminator 1)
  #14 0x400dc0c1:0x3ffe8210 in AsyncWebServerRequest::_onData(void*, unsigned int) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebRequest.cpp:123
  #15 0x400dc2d9:0x3ffe8250 in operator() at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebRequest.cpp:76
      (inlined by) _M_invoke at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:297
  #16 0x400d7bfe:0x3ffe8270 in AsyncClient::_recv(tcp_pcb*, pbuf*, signed char) at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:687
      (inlined by) AsyncClient::_recv(tcp_pcb*, pbuf*, signed char) at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:915
  #17 0x400d7c95:0x3ffe82a0 in AsyncClient::_s_recv(void*, tcp_pcb*, pbuf*, signed char) at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:1191
  #18 0x400d831e:0x3ffe82c0 in _handle_async_event at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:159
      (inlined by) _async_service_task at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:194
  #19 0x40091189:0x3ffe82f0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:143

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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1364
load:0x40078000,len:12656
load:0x40080400,len:3512
entry 0x40080624
{"DeskName":"Standing desk","DeskBtAddress":"E9:43:60:EC:13:9A","UserReset":false}
Config file was successfully parsed
W (1266) wifi:Haven't to connect to a suitable AP now!
After waiting 0.40 secs , Connection result is 3
Local IP: 192.168.20.85
HTTP server started
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC      : 0x40164121  PS      : 0x00060c30  A0      : 0x800e6398  A1      : 0x3ffe7ea0  
A2      : 0x3ffe7ef4  A3      : 0x00000000  A4      : 0x00000000  A5      : 0x3ffe7ef4  
A6      : 0xfffffffc  A7      : 0x3ffdfe5c  A8      : 0x80094746  A9      : 0x3ffe7ee0  
A10     : 0x00000000  A11     : 0x3ffdfe3c  A12     : 0x000000b0  A13     : 0x3ffdfff8  
A14     : 0x00000001  A15     : 0xfffffffc  SAR     : 0x00000018  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000020  LBEG    : 0x4008edc9  LEND    : 0x4008edd9  LCOUNT  : 0xfffffff8  

ELF file SHA256: 0000000000000000

Backtrace: 0x4016411e:0x3ffe7ea0 0x400e6395:0x3ffe7ef0 0x400e63da:0x3ffe7f30 0x400e5f1c:0x3ffe7f50 0x400d1738:0x3ffe7f70 0x40196f8d:0x3ffe7fa0 0x400ddbd4:0x3ffe7fc0 0x400dde7b:0x3ffe8040 0x400dc909:0x3ffe8090 0x400db32e:0x3ffe80d0 0x400dbdc9:0x3ffe8110 0x400d2481:0x3ffe8150 0x400de0be:0x3ffe8190 0x400dbfa9:0x3ffe81d0 0x400dc0c1:0x3ffe8210 0x400dc2d9:0x3ffe8250 0x400d7bfe:0x3ffe8270 0x400d7c95:0x3ffe82a0 0x400d831e:0x3ffe82c0 0x40091189:0x3ffe82f0
  #0  0x4016411e:0x3ffe7ea0 in NimBLERemoteCharacteristic::readValue[abi:cxx11](long*) at .pio/libdeps/esp32dev/NimBLE-Arduino/src/NimBLERemoteCharacteristic.cpp:418
  #1  0x400e6395:0x3ffe7ef0 in unsigned short NimBLERemoteCharacteristic::readValue<unsigned short>(long*, bool) at .pio/libdeps/esp32dev/NimBLE-Arduino/src/NimBLERemoteCharacteristic.h:78
  #2  0x400e63da:0x3ffe7f30 in LinakDesk::BluetoothConnection::getHeightMm() const at lib/LinakDeskEmbedded/BluetoothConnection.cpp:122
  #3  0x400e5f1c:0x3ffe7f50 in LinakDesk::DeskController::getHeightMm() const at lib/LinakDeskCore/DeskController.cpp:39
  #4  0x400d1738:0x3ffe7f70 in html::processor(String const&) at src/html.h:25
  #5  0x40196f8d:0x3ffe7fa0 in std::_Function_handler<String (String const&), String (*)(String const&)>::_M_invoke(std::_Any_data const&, String const&) at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:283
  #6  0x400ddbd4:0x3ffe7fc0 in AsyncAbstractResponse::_fillBufferAndProcessTemplates(unsigned char*, unsigned int) at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:687
      (inlined by) AsyncAbstractResponse::_fillBufferAndProcessTemplates(unsigned char*, unsigned int) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebResponses.cpp:441
  #7  0x400dde7b:0x3ffe8040 in AsyncAbstractResponse::_ack(AsyncWebServerRequest*, unsigned int, unsigned int) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebResponses.cpp:315
  #8  0x400dc909:0x3ffe8090 in AsyncAbstractResponse::_respond(AsyncWebServerRequest*) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebResponses.cpp:261 (discriminator 2)
  #9  0x400db32e:0x3ffe80d0 in AsyncWebServerRequest::send(AsyncWebServerResponse*) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebRequest.cpp:725
  #10 0x400dbdc9:0x3ffe8110 in AsyncWebServerRequest::send_P(int, String const&, char const*, std::function<String (String const&)>) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebRequest.cpp:804
  #11 0x400d2481:0x3ffe8150 in operator() at src/main.cpp:212
      (inlined by) _M_invoke at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:297
  #12 0x400de0be:0x3ffe8190 in AsyncCallbackWebHandler::handleRequest(AsyncWebServerRequest*) at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:687
      (inlined by) AsyncCallbackWebHandler::handleRequest(AsyncWebServerRequest*) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebHandlerImpl.h:132
  #13 0x400dbfa9:0x3ffe81d0 in AsyncWebServerRequest::_parseLine() at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebRequest.cpp:581 (discriminator 1)
  #14 0x400dc0c1:0x3ffe8210 in AsyncWebServerRequest::_onData(void*, unsigned int) at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebRequest.cpp:123
  #15 0x400dc2d9:0x3ffe8250 in operator() at .pio/libdeps/esp32dev/ESP Async WebServer@src-e4ae2ab88c47a569bbf518658033926f/src/WebRequest.cpp:76
      (inlined by) _M_invoke at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:297
  #16 0x400d7bfe:0x3ffe8270 in AsyncClient::_recv(tcp_pcb*, pbuf*, signed char) at /Users/messerschmidt/.platformio/packages/toolchain-xtensa32/xtensa-esp32-elf/include/c++/8.2.0/bits/std_function.h:687
      (inlined by) AsyncClient::_recv(tcp_pcb*, pbuf*, signed char) at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:915
  #17 0x400d7c95:0x3ffe82a0 in AsyncClient::_s_recv(void*, tcp_pcb*, pbuf*, signed char) at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:1191
  #18 0x400d831e:0x3ffe82c0 in _handle_async_event at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:159
      (inlined by) _async_service_task at .pio/libdeps/esp32dev/AsyncTCP/src/AsyncTCP.cpp:194
  #19 0x40091189:0x3ffe82f0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:143

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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1364
load:0x40078000,len:12656
load:0x40080400,len:3512
entry 0x40080624
{"DeskName":"Standing desk","DeskBtAddress":"E9:43:60:EC:13:9A","UserReset":false}
Config file was successfully parsed
Detected Double Reset
W (1293) wifi:Haven't to connect to a suitable AP now!
Starting Config Portal
krzmaz commented 3 years ago

I see that stacktrace is from the WebUI page, have you tried simple endpoints - /heap and /getHeightMm? I see that you were able to set some values in the ConfigPortal, so that means the webserver finally worked! I'm suspecting that your board has some weird configuration regarding RAM - the Amazon listing said 520KB which is more than my boards have (I'm testing on two different boards with 320KB of RAM each), but the symptoms suggest that there are still issues with memory... When BT stack gets initialized, the problems start to appear...

One last thing you could do right now is to again change the board in platformio.ini to
board = az-delivery-devkit-v4
but I think that your boards are something different, and not those v4 kind...

If you feel like it, you could also experiment with enabling SPIRAM, but without access to your boards I won't be able to help much with debugging... According to this: https://community.platformio.org/t/correct-settings-to-enable-external-ram-on-esp32/18607 https://docs.platformio.org/en/latest/platforms/espressif32.html#external-ram-psram it could help just to add

    -DBOARD_HAS_PSRAM
    -mfix-esp32-psram-cache-issue

to build_flags

SeraphimSerapis commented 3 years ago

It seems like this is what has been missing. No crashes for now! Thanks for being so dilligent!

I adjusted both the board as you suggested and added the two build_flags.

Tim

krzmaz commented 3 years ago

That's great news! šŸ˜ I think it was the build flags, as changing the board hasn't helped last time. I thought that the board definitions had those PSRAM fixes included but apparently not. I'm closing the issue.

BTW Do you maybe have a alexa device and would want to test controlling the desk with voice commands? ;>

SeraphimSerapis commented 3 years ago

I fear I don't. Plenty of Google Assistant devices but no Alexa in my home :D

krzmaz commented 3 years ago

Sadly Google Home seems to be harder to integrate - AFAIK it uses only cloud solutions and not direct local communication to smart home devices... At least that's what I've found in the issues of the library I'm experimenting with: https://github.com/vintlabs/fauxmoESP/issues/124#issuecomment-761164849 That's a shame for people who use voice assistants other than Alexa, as I'm currently experimenting with controlling my desk with an Amazon Echo using fauxmoESP library and it's a very nice experience šŸ˜

Anyway I'm glad that the project works for you and I hope you find it useful! šŸ˜Š