Talking to an MQTT-SN gateway from Thread - gateway not found

330 views
Skip to first unread message

Electronut

unread,
Aug 5, 2018, 10:34:18 PM8/5/18
to openthread-users

I have a Thread network setup using Nordic nRF52840 as per the documentation below, using the Raspberry Pi image provided by Nordic.

http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.thread_zigbee.v1.0.0/thread_border_router.html?cp=4_2_0_1_0_8


I am able to ping external IPv4 addresses from a thread node using CLI.


I am trying to get the Nordic  mqttsn_client_publisher example working, but I get the MQTTSN_SEARCH_GATEWAY_NO_GATEWAY_FOUND error in the program.


I have confirmed that paho-mqttns-gateway.service is running on the pi, and that /etc/paho-mqttsn-gateway default values are correct.


This is the function that's searching for the gateway:


uint32_t mqttsn_packet_sender_searchgw(mqttsn_client_t * p_client)



{

   
unsigned char radius   = 1;

    uint32_t      err_code
= NRF_SUCCESS;

    uint8_t    
* p_data   = nrf_malloc(MQTTSN_PACKET_SEARCHGW_LENGTH);




   
do

   
{

       
if (p_data == NULL)

       
{

            err_code
= NRF_ERROR_NO_MEM;

            NRF_LOG_ERROR
("SEARCHGW message cannot be allocated\r\n");

           
break;

       
}




        uint16_t datalen
= MQTTSNSerialize_searchgw(p_data, MQTTSN_PACKET_SEARCHGW_LENGTH, radius);

       
if (datalen == 0)

       
{

            err_code
= NRF_ERROR_INVALID_PARAM;

           
break;

       
}




       
const mqttsn_remote_t broadcast_search =

       
{

           
.addr        = MQTTSN_BROADCAST_ADDR,

           
.port_number = MQTTSN_DEFAULT_CLIENT_PORT,

       
};




        err_code
= mqttsn_packet_sender_send(p_client, &broadcast_search, p_data, datalen);




   
} while (0);




   
if (p_data)

   
{

        nrf_free
(p_data);

   
}




   
return err_code;

}



Here are the broadcast values used:


/**@brief IPv6 address SEARCHGW message is sent to. */



#define MQTTSN_BROADCAST_ADDR { 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \

                               
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }




/**@brief Default port MQTT-SN gateway binds to. */

#define MQTTSN_DEFAULT_GATEWAY_PORT           47193




/**@brief Maximum MQTT-SN packet ID. */

#define MQTTSN_MAX_PACKET_ID                  65535



Any idea why gateway discovery is failing? The thread network seems alive and it's able to ping to the internet via the pi gateway,


I am using nRF5_SDK_for_Thread_and_Zigbee_v1.0.0.


I'd appreciate any help with the above error.


Regards




Electronut

unread,
Aug 6, 2018, 8:39:33 AM8/6/18
to openthread-users

I found the problem. The Nordic MQTT-SN code uses a different UDP6 port compared to the one in the conf file.


Need to make the following change to /etc/paho-mqtt-sn-gateway.conf:


#GatewayUDP6Broadcast = ff33:40:fdde:ad00:beef:0:0:1

GatewayUDP6Broadcast = ff03::1

Nikhil Komalan

unread,
Jul 7, 2021, 12:49:59 PM7/7/21
to openthread-users

Hey,
Was this issue resolved in nRF SDK 5 for thread v4.1 ? Because I see in the paho-mqttsn-gateway.conf file that Gateway UDP 6 address isn't ff03::1 
Reply all
Reply to author
Forward
0 new messages