hardwario / twr-sdk

HARDWARIO TOWER Firmware SDK (Software Development Kit)
MIT License
28 stars 20 forks source link

sigfox get device pac bug #148

Closed oldrich-s closed 6 years ago

oldrich-s commented 6 years ago

I think that the following code is wrong. As a response I get ED700B1981C3FC7F or as dec 069d 068d 055d 048d 048d 066d 049d 057d 056d 049d 067d 051d 070d 067d 055d 070d so there is no \r and the length is 16 characters and not 17.

https://github.com/bigclownlabs/bcf-sdk/blob/216c8e8060f8cf7349faa2e1458313c226242870/bcl/src/bc_wssfm10r1at.c#L140

    if (strlen(self->_response) != 17 || self->_response[16] != '\r')
    {
        return false;
    }

EDIT: I think the same will go for bc_wssfm10r1at_get_device_id

oldrich-s commented 6 years ago

The error was with buffer length. If the function returned an error code instead of false ( https://github.com/bigclownlabs/bcf-sdk/issues/149 ), then it would be much easier to track down the problem ;)

hubpav commented 6 years ago

Yeah - you are correct, the error codes would have made it easier for debugging. On the other hand, people are lazy to write if (api_call() != 0) ... - not everybody is up to POSIX-style approach :smile: Another idea would be introducing API debugging logs via bc_log API and a new log-level BC_LOG_LEVEL_SDK (that would be lower than BC_LOG_LEVEL_DEBUG). What do you think?