VSChina / ESP32_AzureIoT_Arduino

The library for ESP32 Azure IoT for Arduino
MIT License
37 stars 43 forks source link

ESP32 reboots with error if the connection resets using Microsoft Examples #12

Open jpagliaccio opened 5 years ago

jpagliaccio commented 5 years ago

On the Adafruit HUZZAH32 Feather, if you loose your WiFi connection, or just have a slow connection, the code crashes and the ESP32 reboots.

This is with the latest Microsoft Azure Libraries and boards files from Espressif json file added to the Boards Manager. The code is from Examples in Azure IoT and "A simple Azure IoT example for sending telemetry." Microsoft example.

You can see below, 4 good messages and then late message because of network latency.

Then we get an error with Func:tlsio_openssl_destroy and when it resets it crashes when trying to initialize SNTP. Network problems will happen - they cant cause errors and reboot.

From button-press restart

rst:0x10 (RTCWDT_RTC_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:808 load:0x40078000,len:6084 load:0x40080000,len:6696 entry 0x400802e4 Starting connecting WiFi. ..WiFi connected IP address: 192.168.1.69 Info: Initializing SNTP Info: SNTP initialization complete Info: IoT Hub SDK for C, version 1.1.23 Info: >>>Connection status: connected

start sending events. Info: >>>IoTHubClient_LL_SendEventAsync accepted message for transmission to IoT Hub. Info: >>>Confirmation[0] received for message tracking id = 0 with result = IOTHUB_CLIENT_CONFIRMATION_OK Sending data succeed

start sending events. Info: >>>IoTHubClient_LL_SendEventAsync accepted message for transmission to IoT Hub. Info: >>>Confirmation[1] received for message tracking id = 1 with result = IOTHUB_CLIENT_CONFIRMATION_OK Sending data succeed

start sending events. Info: >>>IoTHubClient_LL_SendEventAsync accepted message for transmission to IoT Hub. Info: >>>Confirmation[2] received for message tracking id = 2 with result = IOTHUB_CLIENT_CONFIRMATION_OK Sending data succeed

start sending events. Info: >>>IoTHubClient_LL_SendEventAsync accepted message for transmission to IoT Hub. Info: >>>Confirmation[3] received for message tracking id = 3 with result = IOTHUB_CLIENT_CONFIRMATION_OK Sending data succeed

start sending events. Info: >>>IoTHubClient_LL_SendEventAsync accepted message for transmission to IoT Hub. Info: >>>Confirmation[4] received for message tracking id = 4 with result = IOTHUB_CLIENT_CONFIRMATION_OK

Sending data succeed start sending events. Info: >>>IoTHubClient_LL_SendEventAsync accepted message for transmission to IoT Hub. Error: Time:Thu Nov 15 02:48:20 2018 File:/home/jpagliaccio/.arduino15/packages/esp32/hardware/esp32/1.0.0/libraries/AzureIoT/src/Esp32MQTTClient.cpp Func:SendEventOnce Line:316 Waiting for send confirmation, time is up 10003

Info: >>>Re-connect.

Error: Time:Thu Nov 15 02:48:20 2018 File:/home/jpagliaccio/.arduino15/packages/esp32/hardware/esp32/1.0.0/libraries/AzureIoT/src/az_iot/c-utility/pal/src/tlsio_openssl_compact.c Func:tlsio_openssl_destroy Line:213 tlsio_openssl_destroy called while not in TLSIO_STATE_CLOSED.

Info: >>>Confirmation[5] received for message tracking id = 5 with result = IOTHUB_CLIENT_CONFIRMATION_BECAUSE_DESTROY

Info: Initializing SNTP assertion "Operating mode must not be set while SNTP client is running" failed: file "/Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/lwip/apps/sntp/sntp.c", line 591, function: sntp_setoperatingmode abort() was called at PC 0x400e35a3 on core 1

Backtrace: 0x4008f6f4:0x3ffb1d60 0x4008f8f7:0x3ffb1d80 0x400e35a3:0x3ffb1da0 0x40119359:0x3ffb1dd0 0x400d3fca:0x3ffb1df0 0x400d4026:0x3ffb1e10 0x400d30f2:0x3ffb1e30 0x400d339a:0x3ffb1e70 0x400d33d1:0x3ffb1e90 0x400d34f7:0x3ffb1ed0 0x400d2481:0x3ffb1ef0 0x40147f68:0x3ffb1fa0

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:808 load:0x40078000,len:6084 load:0x40080000,len:6696 entry 0x400802e4 Starting connecting WiFi. ..WiFi connected IP address: 192.168.1.69 Info: Initializing SNTP

Info: SNTP initialization complete Info: IoT Hub SDK for C, version 1.1.23 Info: >>>Connection status: connected

start sending events. Info: >>>IoTHubClient_LL_SendEventAsync accepted message for transmission to IoT Hub. Info: >>>Confirmation[0] received for message tracking id = 0 with result = IOTHUB_CLIENT_CONFIRMATION_OK Sending data succeed

beegee-tokyo commented 4 years ago

Pull request 19 should fix the problem.

assertion "Operating mode must not be set while SNTP client is running" failed: file "/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/lwip/lwip/src/apps/sntp/sntp.c", line 600, function: sntp_setoperatingmode

SNTP_Deinit(); required before sntp_setoperatingmode(SNTP_OPMODE_POLL); if SNTP was initialized already.