thingsboard / thingsboard-client-sdk

Client SDK to connect with ThingsBoard IoT Platform from IoT devices (Arduino, Espressif, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OTA example issues due to callback defined inside loop?

adamwolf opened this issue · comments

Hiya folks!

The OTA examples seem to work fine for me, but when adapting them to larger programs, I kept having a series of issues.

I found that the const OTA_Update_Callback callback was being declared in loop() (

const OTA_Update_Callback callback(&progressCallback, &updatedCallback, CURRENT_FIRMWARE_TITLE, CURRENT_FIRMWARE_VERSION, &updater, FIRMWARE_FAILURE_RETRIES, FIRMWARE_PACKET_SIZE);
). I think maybe it should be in a larger scope, so that when loop() exits and restarts the pointers are still good. When I changed this in my larger programs, it seemed to instantly start to work reliably.

It might even be a cause of some of the issues like #183.

Aformentioned issue is fixed in the linked Pull Request and has been fixed already because of #159.

For now your fix with putting it into global scope will fix the issue. Once the PR has been merged it can be done like in the examples again. Sorry for any inconviences caused.