Dear XDK Community,

 

as part of a project at Bosch I am trying to connect some XDK devices to a MQTT broker (mosquitto). I already can connect one XDK device to that broker and I also can subscribe and publish data. But if I want to connect another XDK device to the same broker at the same time, the other XDK device will go into the assertion mode. So I can only connect one XDK device to the same broker at the same time. The last console log of the device going into the assertion mode is the following:

INFO | XDK DEVICE 2: asserted at Filename 3rd-party/ServalStack/src/Msg/TcpMsg.c , line no  91

Now I am looking for possible reasons. The XDK devices send data permanently (every second) to the broker, so I think that the problem cannot be caused by the keep-alive-interval.

I would be very glad if you could help me!

 

Thank you very much in advance!

Pascal Nothacker

0 (0 Voti)
RE: Connect more than one XDK device to a MQTT broker at the same time
Risposta
02/07/19 6.09 come risposta a Pascal Nothacker.

If you flash the same application on both of your XDKs and you have the device name hard code it trys to connect to the same broker with the same Client ID, which is not possible. You're devices need to have different Client IDs to register to the MQTT Broker.

A good idea to have different IDs would be to use the WLAN MAC Address on the backside of your XDK. You get that by using the following function: sl_NetCfgGet(const _u8 ConfigId, _u8 *pConfigOpt, _u8 *ConfigLen, _u8 *pValues)

I used that to get it by the following way:

#define SL_MAC_ADDR_LEN		UINT8_C(6)
_u8 wlanMacAddressVal[SL_MAC_ADDR_LEN];
_u8 wlanMacAddressLen = SL_MAC_ADDR_LEN;

sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&wlanMacAddressLen,(_u8 *)wlanMacAddressVal);

afterwards the MAC Address is in the wlanMacAddressVal.

 

Hope this might help you.

Martin

0 (0 Voti)