Libelium / waspmoteapi

Tested and stable Waspmote API repository
137 stars 129 forks source link

Possible bug when opening Socket in BG96 library. #52

Closed snspinn closed 2 years ago

snspinn commented 2 years ago

In the process of chasing down an intemittent issue in NBIoT comms and it's looking like a device side issue. During my investigation, I noticed what looks like a typo in the openSocketClient() in WaspBG96.cpp. At line 2855 the variable answer is set by calling getSocketStatus(). The following if statements seems to be incorrect, but I am not yet certain of the intention in the code section and the effect of the bug, so won't hazard a PR. However, I will take a guess that, in openSocketClient(), the statement;

if (answer == 0)
    {
        if (answer == 2)
        {
            getErrorCode();

            #if DEBUG_BG96 > 0
                printErrorCode();
            #endif
        }
        if (answer == 1)
        {
            PRINT_BG96(F("Error opening socket - Socket is already opened\n"));
        }

        return 23;
    }

... should in fact start with;

if (answer != 0)
    {
        ....
                ....
Libelium commented 2 years ago

You are right. It will be fixed on the next API release. Thanks for reporting.