XDK MQTT Example in v3.4 not building
Answer
9/19/18 12:11 PM

Hi,

I've installed the Workbench 3.4 and connected my XDK to the Workbench. In the start-screen, I've selected the MQTT Example, updated WifiSSID, WifiPwd, SNTP URL, MQTT URL and MQTT Port.

After 6 minutes of build process it crashes with the following console output:

I2CTransceiver.c:(.text.I2CTransceiver_Write+0x7a): undefined reference to `xQueueSemaphoreTake'
./../Platform/Utils/release/libUtils_efm32.a(I2CTransceiver.o):I2CTransceiver.c:(.text.I2CTransceiver_Write+0xbc): more undefined references to `xQueueSemaphoreTake' follow
collect2.exe: error: ld returned 1 exit status
application.mk:391: recipe for target 'C:/Users/DEKBUTZ1/XDK-Workspace/SendDataOverMQTT/debug/SendDataOverMQTT.out' failed
mingw32-make[1]: *** [C:/Users/DEKBUTZ1/XDK-Workspace/SendDataOverMQTT/debug/SendDataOverMQTT.out] Error 1
mingw32-make[1]: Leaving directory 'C:/XDK-Workbench/XDK/SDK/xdk110/Common'
Makefile:53: recipe for target 'debug' failed
mingw32-make: *** [debug] Error 2

14:09:52 Build Finished (took 6m:3s.972ms)

What could be the problem here? Is it a known error?

Best wishes

Korbinian

0 (0 Votes)
RE: XDK MQTT Example in v3.4 not building
Answer
9/20/18 7:43 AM as a reply to K Butz.
Hello Korbinian,

The error you received was caused by the initial build of the MQTT example, wich you executed from the Welcome Screen of the XDK-Workbench. This initial build creates the SDK and in your case corrupted during that process.

To solve this common issue, I recommend to:
 
  1. Clean the project
  2. Start the build once more
Since you mentioned a building time over 6 minutes, activating the parallel build option in the project settings of your MQTT example would drastically reduce that.
To speed up the project's building process, right-click the project folder, click on Properties and select the C/C++ Build tab. Choose Behavior and check the checkbox Enable parallel build .

This modification ensures to build your project by using the optimal system threads, instead of only one, like in the current, the default state.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: XDK MQTT Example in v3.4 not building
Answer
9/21/18 11:53 AM as a reply to Franjo Stjepandic.

Hi Franco, 

thank you for your response, your tips helped me - with setting the parallel build option, the process works way faster than before.

Now I've managed to deploy the demo project to the xdk. After flashing and restarting the device, it connects to my WiFi successfully, but after this the following errors are thrown periodically:

 INFO | XDK DEVICE 1: WLANPersonalWPA2Connect : Connected to WPA network successfully. 
 INFO | XDK DEVICE 1: MqttEventHandler : Event - 2
 INFO | XDK DEVICE 1: MqttEventHandler : Event - 3
 INFO | XDK DEVICE 1: Error in XDK110 Application package.
 INFO | XDK DEVICE 1: 	Package ID: 153	Module ID: 36	Severity code: 2	Error code: 116
 INFO | XDK DEVICE 1: Error in XDK110 Application package.
 INFO | XDK DEVICE 1: 	Package ID: 153	Module ID: 36	Severity code: 2	Error code: 122
 INFO | XDK DEVICE 1: Error in XDK110 Application package.
 INFO | XDK DEVICE 1: 	Package ID: 153	Module ID: 36	Severity code: 2	Error code: 122
 INFO | XDK DEVICE 1: Error in XDK110 Application package.
 INFO | XDK DEVICE 1: 	Package ID: 153	Module ID: 36	Severity code: 2	Error code: 122
 INFO | XDK DEVICE 1: Error in XDK110 Application package.
 INFO | XDK DEVICE 1: 	Package ID: 153	Module ID: 36	Severity code: 2	Error code: 122
 INFO | XDK DEVICE 1: Error in XDK110 Application package.
 INFO | XDK DEVICE 1: 	Package ID: 153	Module ID: 36	Severity code: 2	Error code: 122

How can I know where's the problem here? Is there a reference to error code descriptions?

BR Korbinian

// Edit: For some reasons after several clean/builds, the project is now working as soon as I've flashed the device. But after restart (via Workbench oder Hardware), the above errors are thrown...

0 (0 Votes)
RE: XDK MQTT Example in v3.4 not building
Answer
9/21/18 12:49 PM as a reply to K Butz.
Hello Korbinian,

The error is resulting from within your XDK application, that is indicated by the package ID 153. Furthermore, all examples are build on the simplified API based in the common folder of the XDK under SDK > xdk110 > Common > include .

As such, you can take a look at the interface XdkCommonInfo.h to search for the module ID and error code which is thrown by your MQTT example.

In your case, this is the XDK_MQTT.h interface and it is throwing the errors RETCODE_MQTT_CONNECT_STATUS_ERROR and RETCODE_MQTT_PUBLISH_FAILED . The first one is indicating a connection error to your MQTT broker and is indirectly also triggering that publishing to the configured topic cannot be done due to the nonexisting connection.

The same applies for the events you are getting, which are MQTT_CONNECT_SEND_FAILED and MQTT_CONNECT_TIMEOUT . Both are indicating that the MQTT broker, you want to connect to and send data to seems to be not reachable.

As such, I recommend taking a look into the MQTT broker itself.

Please let me know if this was helpful and feel free to ask if you have further questions.

Kind regards,
Franjo
0 (0 Votes)
RE: XDK MQTT Example in v3.4 not building
Answer
10/10/18 2:44 PM as a reply to Franjo Stjepandic.

Hi Franjo, 

thank you for your message and the hint where to find the error codes.

I've checked the MQTT Broker, tested it with two public and a locally installed MQTT broker, but the behaviour is always the same: after flashing the device, the XDK is sending its sensor data to the configured broker, everything works fine. But as soon as I shutdown the XDK (via button) and restart it again, the above errors (122, Mqtt sending failed) gets thrown periodically. Sometimes it does not work even directly after flashing, flashing it again with the same code and it might work. So at the moment, the transfer of data to Mqtt broker works, but on a completely unreliable basis.

This behaviour is the same for different (public) Mqtt Brokers and the brokers do work (checked it with Mqtt.fx). Wifi is always the same and works fine.

Do you have any idea what could be wrong here? 

BR Korbinian

0 (0 Votes)
RE: XDK MQTT Example in v3.4 not building
Answer
10/11/18 3:21 PM as a reply to K Butz.
Hello Korbinian,

the behavior might be related to a half-open TCP connection from the MQTT broker.

The MQTT configuration option Keep alive on the XDK side ensures that the connection between the MQTT broker and MQTT client is as long opened as the interval is configured. As long as messages get exchanged frequently and the keep-alive interval is not exceeded, there is no need to send an extra message to establish whether the connection is still open.

Please note, if you restart the XDK during the keepalive interval, it must send a PINGREQ packet to the broker to confirm the client's availability sides the broker. This step also checks client sided if the broker is alive.

As such, in your current scenario might be a conflict, while the XDK tries to open up a new connection to the MQTT broker, which awaits the XDK to connect to the still opened connection.
I assume this to cause the error you are receiving, but if I am wrong, there is another possible reason:

The MQTT broker itself might detect the half-open connection and perform (if configured) a "client-take-over".
As such, the MQTT broker closes the previous connection to the same client, and tries to establish a new connection. This also could result in the error you are observing.

To see which of them is true and causes the issues, I recommend to check what the MQTT broker does, while you observe the behavior of the XDK.
To examine the single steps during the established MQTT connection and the sending processes, I recommend to start the MQTT broker in debug mode.
Additionally, would you post an outline of the MQTT broker log? That would allow me to analyze its behavior, too.

Furthermore, I recommend to check if the client-take-over option is available and also activated on the MQTT broker itself.

Otherwise, I recommend to take a look at the configuration of the keepalive time interval sides the XDK.

Please tell me if this was helpful, and do not hesitate to ask further questions.

Kind regards,
Franjo
0 (0 Votes)