This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Thread MQTT example causes ASSERT in Debug build

I am using nRF52840 with nRF5 SDK for Thread and Zigbee 1.0.0 on the nRF52840 development kit.

The Release build of the mqttsn_client example compiles and runs fine.

Using the Debug build causes an ASSERT.

Pressing Button 1, calls  mqttsn_client_search_gateway(&m_client, SEARCH_GATEWAY_TIMEOUT);

which calls  mqttsn_client_state_update(p_client, SENT_SEARCHGW) in mqttsn_client.c

which generates an ASSERT because fsm_event == SENT_SEARCHGW, which is not handled anywhere in mqttsn_client_state_update()

        case MQTTSN_CLIENT_DISCONNECTED:
        {
            switch (fsm_event)
            {
                case SENT_CONNECT:
                    p_client->client_state = MQTTSN_CLIENT_ESTABLISHING_CONNECTION;
                    break;

                default:
                    ASSERT(false);
                    break;
            }
            break;
        }

mqttsn_client_state_update() needs to handle that event.

Thanks,

Mary

Parents
  • Hi Mary,

    Thank you for reporting this. I have forwarded the bugreport internally to our Thread team.

    Best regards,
    Jørgen

  • I see that this has been corrected in SDK for Thread and Zigbee 2.0.0.

    However, there is another missing case.  

    in mqttsn_client.c

    The function keep_alive_transmission_attempt() calls

    mqttsn_client_state_update(p_client, SENT_PINGREQ);

    In mqttsn_client_state_update(), the case where fsm_event == SENT_PINGREQ is not handled, so you get an ASSERT with the Debug build.

            case MQTTSN_CLIENT_CONNECTED:
            {
                switch (fsm_event)
                {
                    case SENT_SLEEP_REQUEST:
                        p_client->client_state = MQTTSN_CLIENT_WAITING_FOR_SLEEP;
                        break;
    
                    case SENT_DISCONNECT_REQUEST:
                        p_client->client_state = MQTTSN_CLIENT_WAITING_FOR_DISCONNECT;
                        break;
    
                    case TIMEOUT_PINGREQ:
                        p_client->client_state = MQTTSN_CLIENT_DISCONNECTED;
                        break;
    
                    default:
                        ASSERT(false);
                        break;
                }
                break;

    Mary

Reply
  • I see that this has been corrected in SDK for Thread and Zigbee 2.0.0.

    However, there is another missing case.  

    in mqttsn_client.c

    The function keep_alive_transmission_attempt() calls

    mqttsn_client_state_update(p_client, SENT_PINGREQ);

    In mqttsn_client_state_update(), the case where fsm_event == SENT_PINGREQ is not handled, so you get an ASSERT with the Debug build.

            case MQTTSN_CLIENT_CONNECTED:
            {
                switch (fsm_event)
                {
                    case SENT_SLEEP_REQUEST:
                        p_client->client_state = MQTTSN_CLIENT_WAITING_FOR_SLEEP;
                        break;
    
                    case SENT_DISCONNECT_REQUEST:
                        p_client->client_state = MQTTSN_CLIENT_WAITING_FOR_DISCONNECT;
                        break;
    
                    case TIMEOUT_PINGREQ:
                        p_client->client_state = MQTTSN_CLIENT_DISCONNECTED;
                        break;
    
                    default:
                        ASSERT(false);
                        break;
                }
                break;

    Mary

Children
No Data
Related