Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

Do not post any new messages.

Long Boot - Connect - Publish cycle after deep sleep. Are there strategies to speed these up?

edited August 2018 in Mongoose OS

I am using an ESP32 to periodically wake up from Deep Sleep to publish some data to a AWS IOT server about every 5 minutes. This process takes about 7.7 seconds and the application does very little processing. I would like to get to 2 seconds. Is this reasonable?

Boot up to mos_init2 takes about 2 seconds, and there are some things to try to speed this up from what I read by disabling boot messages, and faster spi clock speeds and flash modes. Probably not a discussion for this forum

[Aug 30 19:01:46.833] rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[Aug 30 19:01:47.588] mgos_init2           demo-c 1.0 (20180829-050129)

Then the OS starts many things, wifi, bt, shadows, time, etc and a a little later

[Aug 30 19:01:48.279] mgos_init            Init done, RAM: 184544 total, 78728 free, 78688 min free

And connects to wifi a second later

[Aug 30 19:01:49.262] mgos_net_on_change_c WiFi STA: connected

And starts to send messages for SNTP and MTTQ and AWS Shadow. It would be nice for all this to faster! Still about half the time, nearly 4 seconds, is used with this:

[Aug 30 19:01:50.111] SW ECDSA verify curve 3 hash_len 32 sig_len 71
[Aug 30 19:01:51.235] SW ECDSA verify curve 3 hash_len 64 sig_len 72
[Aug 30 19:01:52.353] SW ECDH curve 3
[Aug 30 19:01:54.065] mongoose_poll        New heap free LWM: 59468

I assume this is some "big number" calculations for TLS.
Since this is the biggest time sink is there any way to speed this up? Does it need to occur every time the system boots and connects?
Any other speed up techniques/strategies are welcome.



  • Hello Paul!
    Any progress ? I'm interested in this too...

  • rojerrojer Dublin, Ireland
    edited November 2018

    so, there are possible solutions. you can set cipher suite that doesn't do use ECDH during handshake - set mqtt.ssl_cipher_suites=TLS-RSA-WITH-AES-128-GCM-SHA256:

    [Nov 16 13:48:19.750] mgos_mqtt_global_con MQTT connecting to
    [Nov 16 13:48:19.779] mongoose_poll        New heap free LWM: 110108   
    [Nov 16 13:48:19.850] mg_ssl_mbed_log      0x3ffe188c ciphersuite: TLS-RSA-WITH-AES-128-GCM-SHA256
    [Nov 16 13:48:20.565] mongoose_poll        New heap free LWM: 103948
    [Nov 16 13:48:20.577] timer_cb             Tick uptime: 6.86, RAM: 233360, 113392 free
    [Nov 16 13:48:20.587] mgos_mqtt_ev         MQTT TCP connect ok (0)      
    [Nov 16 13:48:20.642] mgos_mqtt_ev         MQTT CONNACK 0            

    however, this reduces security of the connection and is not recommended. but can be used in a pinch.
    other solution that might work would be to try and implement TLS session caching so that handshake can be skipped on subsequent connection (provided AWS stores TLS sessions for long enough, or at all - which is not a given).

Sign In or Register to comment.