Coder Social home page Coder Social logo

Comments (16)

MathewHDYT avatar MathewHDYT commented on June 6, 2024

This seems to be a case of the OTA_Update_Callback, being configured incorrectly. Can you attach your script, and are you sure your instance looks like this.

const OTA_Update_Callback callback(&progressCallback, &updatedCallback, CURRENT_FIRMWARE_TITLE, CURRENT_FIRMWARE_VERSION, &updater, FIRMWARE_FAILURE_RETRIES, FIRMWARE_PACKET_SIZE);

Especially important are the CURRENT_FIRMWARE_TITLE and CURRENT_FIRMWARE_VERSION which need to be passed and seem to be missing or are empty strings in your case.

Ensure you pass valid const char* to the methods and ensure they live on for the complete lifetime until the OTA Update is started. Variables need to be in global scope or static.

from thingsboard-client-sdk.

ChrSchultz avatar ChrSchultz commented on June 6, 2024

ok that was the first failure , corrected and now it works, but the device didn't download the Version 0.0.2 .
Telemetry-Key: fw_state = "UPDATED" ... with actual timestamp.

If I use the example I got the failure: not for us: Title different... but I use in device and thingsboard-cloud the same title... eg: "Test"

from thingsboard-client-sdk.

MathewHDYT avatar MathewHDYT commented on June 6, 2024

Are you really sure the title are the same. The title configured in the OTA_Update_Callback has to be the same as from the OTA package assigned in ThingsBoard.

To check can you add a print to Firmware_Shared_Attribute_Received method in ThingsBoard.h after fw_title and curr_fw_title has been initalized.

Serial.printf("Received fw title: (%s), curr_fw_title: (%s)\n", fw_title, curr_fw_title);

from thingsboard-client-sdk.

ChrSchultz avatar ChrSchultz commented on June 6, 2024

curr_fw_title : �!@
fw_title: TEST
but in demo.thingsboard.org is and in the code is all the same... i use the orginal Example file. I modified Thingsboard.h with in the .pio directory with printf("",,) to see curr_fw_title and fw_title. after failed comparision.
It seem that curr_fw_title wasn't read correct. I can give you my credentials for demo.thingsboard.io via mail so you can see.

from thingsboard-client-sdk.

MathewHDYT avatar MathewHDYT commented on June 6, 2024

As mentioned above in less detail, because the OTA_Updater_Callback does not save the actual memory to the title and version. It simply copies the pointer, meaning if the string is deleted while we are waiting to actually start downloading then the issue we can see in your case is occurring.

More simply the memory to the string has been erased already and it is now garbage and is then compared with from the cloud received JSON data. This results in the comparison failing, because the 2 strings can not be the same.

If you need further help I would need your main file and especially the location your FW_TITLE is located in the main file. Because the user utilising the library needs to ensure the string is kept alive until the OTA udpate has started. To achieve that either put the variable into global scope or make it static.

from thingsboard-client-sdk.

ChrSchultz avatar ChrSchultz commented on June 6, 2024

I use the orgiginal example 0009-esp8266-esp32-proceess_ota.ino without StreamUtil support.

from thingsboard-client-sdk.

MathewHDYT avatar MathewHDYT commented on June 6, 2024

Okay good to know, perhaps there is some issue with flash strings, can you add this line on top of your main file.

#define THINGSBOARD_ENABLE_PROGMEM 0

from thingsboard-client-sdk.

ChrSchultz avatar ChrSchultz commented on June 6, 2024

Okay good to know, perhaps there is some issue with flash strings, can you add this line on top of your main file.

#define THINGSBOARD_ENABLE_PROGMEM 0

is by default, because i use platformio and board=d1_mini that has #define ESP8266... i see it higlighted in editor

from thingsboard-client-sdk.

MathewHDYT avatar MathewHDYT commented on June 6, 2024

Ah good to know you are on ESP8266. For now as a dirty fix can you go into the OTA_Update_Callback and change the line.

const char      *m_fwTitel;      // Current firmware title of device

to

std::string      m_fwTitel;      // Current firmware title of device

and additionally add an include to #include <string> at the top of the file under the include guards.

from thingsboard-client-sdk.

ChrSchultz avatar ChrSchultz commented on June 6, 2024

i tried to alter m_fwTitle but i got an compiler_error:

#include <string>
...
std:string m_fwTitle;
...
void OTA_Update_Callback::Set_Firmware_Title(const char *currFwTitle) {
    m_fwTitel = currFwTitle;
}

.pio\libdeps\d1_mini\ThingsBoard\src\OTA_Update_Callback.cpp: In member function 'void OTA_Update_Callback::Set_Firmware_Title(const char*)':
.pio\libdeps\d1_mini\ThingsBoard\src\OTA_Update_Callback.cpp:40:17: error: no match for 'operator=' (operand types are 'const string' {aka 'const std::__cxx11::basic_string'} and 'const char*')
40 | m_fwTitel = currFwTitle;

from thingsboard-client-sdk.

MathewHDYT avatar MathewHDYT commented on June 6, 2024

Sorry my bad simply change

void OTA_Update_Callback::Set_Firmware_Title(const char *currFwTitle) {
    m_fwTitel = currFwTitle;
}

to this instead

void OTA_Update_Callback::Set_Firmware_Title(std::string currFwTitle) {
    m_fwTitel = currFwTitle;
}

from thingsboard-client-sdk.

ChrSchultz avatar ChrSchultz commented on June 6, 2024

I altered all depending functions on std::string currFwTitle , and pushed to my fork in branch "testing". What now happens is that my ESP8266 abort due to some runtime errors. compilation works fine...
Here my exception log from esp8266_exeption_decoder:

0x4022179c in std::__throw_length_error(char const*) at ??:?
0x40222d22 in std::iterator_traits<char*>::difference_type std::__distance<char*>(char*, char*, std::random_access_iterator_tag) at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/stl_iterator_base_funcs.h:104
 (inlined by) std::iterator_traits<char*>::difference_type std::distance<char*>(char*, char*) at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/stl_iterator_base_funcs.h:141
 (inlined by) void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc:217
0x4020a456 in OTA_Update_Callback::Get_Firmware_Title[abi:cxx11]() const at ??:?
0x40208375 in ThingsBoardSized<8u, ThingsBoardDefaultLogger>::Firmware_Shared_Attribute_Received(ArduinoJson::V6214PB2::JsonObjectConst const&) at ??:?  
0x40222e2e in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_limit(unsigned int, unsigned int) const at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h:333
 (inlined by) std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int) at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h:484
0x40222e7a in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::substr(unsigned int, unsigned int) const at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h:2837
0x40206f6e in ThingsBoardSized<8u, ThingsBoardDefaultLogger>::process_attribute_request_message(char*, ArduinoJson::V6214PB2::JsonObjectConst&) at ??:?  
0x401001e4 in ets_post at ??:?
0x40208c5a in _ZN11ArduinoJson8V6214PB26detail16JsonDeserializerINS1_13BoundedReaderIPhvEENS1_11StringMoverEE12parseVariantINS1_14AllowAllFilterEEENS0_20DeserializationError4CodeERNS1_11VariantDataET_NS0_21DeserializationOption12NestingLimitE$isra$0 at main.cpp:?
0x4020966f in PubSubClient::readByte(unsigned char*) at ??:?
0x4020ad68 in WiFiClient::available() at ??:?
0x40208ffc in ThingsBoardSized<8u, ThingsBoardDefaultLogger>::onMQTTMessage(char*, unsigned char*, unsigned int) at ??:?
0x40208839 in ThingsBoardSized<8u, ThingsBoardDefaultLogger>::Start_Firmware_Update(OTA_Update_Callback const&) at ??:?
0x40105d85 in ets_timer_arm_new at ??:?
0x4020b3e6 in WiFiClient::read() at ??:?
0x402096a0 in PubSubClient::readByte(unsigned char*) at ??:?

and:

0x4010303a in wDev_MacTim1Arm at ??:?
0x401030b1 in wDev_ProcessFiq at ??:?
0x40103054 in wDev_ProcessFiq at ??:?
0x40219a05 in _vsnprintf_r at /workdir/repo/newlib/newlib/libc/stdio/vsnprintf.c:71 (discriminator 4)
0x40219a05 in _vsnprintf_r at /workdir/repo/newlib/newlib/libc/stdio/vsnprintf.c:71 (discriminator 4)
0x40219a41 in vsnprintf at /workdir/repo/newlib/newlib/libc/stdio/vsnprintf.c:41
0x40219a05 in _vsnprintf_r at /workdir/repo/newlib/newlib/libc/stdio/vsnprintf.c:71 (discriminator 4)
0x40219a41 in vsnprintf at /workdir/repo/newlib/newlib/libc/stdio/vsnprintf.c:41
0x4020d7b5 in ets_printf_P at core_esp8266_postmortem.cpp:?
0x4020d7a8 in ets_printf_P at core_esp8266_postmortem.cpp:?
0x40219a41 in vsnprintf at /workdir/repo/newlib/newlib/libc/stdio/vsnprintf.c:41
0x4026f100 in etharp_output at ??:?
0x4021d68c in __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:179
0x4020d7b5 in ets_printf_P at core_esp8266_postmortem.cpp:?
0x4020d7a8 in ets_printf_P at core_esp8266_postmortem.cpp:?
0x40102e78 in rcReachRetryLimit at ??:?
0x4020d802 in print_stack at core_esp8266_postmortem.cpp:?
0x4020daa6 in postmortem_report at core_esp8266_postmortem.cpp:?
0x4020d247 in operator new(unsigned int) at ??:?
0x4020db1a in raise_exception at core_esp8266_postmortem.cpp:?
0x4020db2c in __unhandled_exception at ??:?
0x4022179c in std::__throw_length_error(char const*) at ??:?
0x40222d22 in std::iterator_traits<char*>::difference_type std::__distance<char*>(char*, char*, std::random_access_iterator_tag) at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/stl_iterator_base_funcs.h:104
 (inlined by) std::iterator_traits<char*>::difference_type std::distance<char*>(char*, char*) at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/stl_iterator_base_funcs.h:141
 (inlined by) void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc:217
0x4020a456 in OTA_Update_Callback::Get_Firmware_Title[abi:cxx11]() const at ??:?
0x40208375 in ThingsBoardSized<8u, ThingsBoardDefaultLogger>::Firmware_Shared_Attribute_Received(ArduinoJson::V6214PB2::JsonObjectConst const&) at ??:?  
0x40222e2e in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_limit(unsigned int, unsigned int) const at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h:333
 (inlined by) std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned int, unsigned int) at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h:484
0x40222e7a in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::substr(unsigned int, unsigned int) const at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h:2837
0x40206f6e in ThingsBoardSized<8u, ThingsBoardDefaultLogger>::process_attribute_request_message(char*, ArduinoJson::V6214PB2::JsonObjectConst&) at ??:?  
0x401001e4 in ets_post at ??:?
0x40208c5a in _ZN11ArduinoJson8V6214PB26detail16JsonDeserializerINS1_13BoundedReaderIPhvEENS1_11StringMoverEE12parseVariantINS1_14AllowAllFilterEEENS0_20DeserializationError4CodeERNS1_11VariantDataET_NS0_21DeserializationOption12NestingLimitE$isra$0 at main.cpp:?
0x4020966f in PubSubClient::readByte(unsigned char*) at ??:?
0x4020ad68 in WiFiClient::available() at ??:?
0x40208ffc in ThingsBoardSized<8u, ThingsBoardDefaultLogger>::onMQTTMessage(char*, unsigned char*, unsigned int) at ??:?
0x40208839 in ThingsBoardSized<8u, ThingsBoardDefaultLogger>::Start_Firmware_Update(OTA_Update_Callback const&) at ??:?
0x40105d85 in ets_timer_arm_new at ??:?
0x4020b3e6 in WiFiClient::read() at ??:?
0x402096a0 in PubSubClient::readByte(unsigned char*) at ??:?
0x402097ba in PubSubClient::readPacket(unsigned char*) at ??:?
0x40209c6c in PubSubClient::loop() at ??:?
0x4020e458 in uart_write at ??:?
0x40210134 in std::_Function_handler<void (unsigned int const&, unsigned int const&), void (*)(unsigned int const&, unsigned int const&)>::_M_invoke(std::_Any_data const&, unsigned int const&, unsigned int const&) at ??:?
0x4020d664 in loop_wrapper() at core_esp8266_main.cpp:?
0x40100ec5 in cont_wrapper at ??:?

from thingsboard-client-sdk.

MathewHDYT avatar MathewHDYT commented on June 6, 2024

I am not 100% sure but perhaps it is an issue with the constness.

const std::string Get_Firmware_Title() const;

Will return a const copy-by-value. Which means the one calling the method can not make the received value non-const.

To fix that please adjust the method like this.

std::string Get_Firmware_Title() const;

For the second error I am unsure, but for now simply go into the Configuration.h file and hardcode THINGSBOARD_ENABLE_PROGMEM to 0.

from thingsboard-client-sdk.

ChrSchultz avatar ChrSchultz commented on June 6, 2024

now it seems as fixed, OTA-Update works
created a Pull-request, will be glad, if all will be merged.
Thanks, and a very good new year :-)

from thingsboard-client-sdk.

MathewHDYT avatar MathewHDYT commented on June 6, 2024

The problem is the std::string workaround is a dirty fix to copy the strings you pass in the constructor so the user can not mangle them up anymore.

But the underlying issue of the string being mangled even tough it should be in global scope still happens and that is what shouldn't occur. The problem is that I can't really reproduce your issue and as you mentioned you use the OTA example from the library so I am also not really sure were the error could be.


For now can you check out your branch without the std::string changes and go into the Configuration.h file and hardcode THINGSBOARD_ENABLE_PROGMEM to 0.

And then retry if it works, because I am assuming it has to do something with this. I currently can't imagine anything else, because that is the only real difference between the ESP8266 and the ESP32 version of the example.

from thingsboard-client-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.