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
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