cancel
Showing results for 
Search instead for 
Did you mean: 

GenericMQTT example LED On or Off not working with mosquitto MQTT server with two projects given at en.x-cube-cld-gen\STM32CubeExpansion_Cloud_CLD_GEN_V1.0.0\Projects/B-L475E-IOT01/Applications/Cloud/GenericMQTT on B-L475E-IOT0 and for STM32F769I-Discov

VK Verma
Senior

Hi @Guillaume!

I tested GenericMQTT example with mosquitto MQTT server with two projects examples given at en.x-cube-cld-gen\STM32CubeExpansion_Cloud_CLD_GEN_V1.0.0\Projects/B-L475E-IOT01/Applications/Cloud/GenericMQTT on B-L475E-IOT01

and at

en.x-cube-cld-gen\STM32CubeExpansion_Cloud_CLD_GEN_V1.0.0\Projects\STM32F769I-Discovery\Applications\Cloud\GenericMQTT\MDK-ARM on STM32F769I-Discovery,

wherein I observed that in both examples data is sent to MQTT mosquitto server successfully and data is received by the MQTT mosquitto server and visible in TeraTerm but the received commands are not being processed for either of the commands like

     {"LedOn": true }

     {"LedOn": false }

     {"TelemetryInterval": <number of seconds> }

     {"Reboot": true }

I observed that in GenericMQTTXcubeSample.c

at line no 266 cJSON * root = cJSON_Parse(mqtt_msg); it provides zero or NULL value in root pointer and i think due to which at line no 267

 json = cJSON_GetObjectItemCaseSensitive(root, "LedOn"); it returns with NULL value and not going into belwo if statement and turning LED ON or OFF.

 if (json != NULL)

 {

  if (cJSON_IsBool(json) == true)

  {

   status_data.LedOn = (cJSON_IsTrue(json) == true);

   Led_SetState(status_data.LedOn);

   g_statusChanged = true;

  }

-- Please suggest where am I doing wrong to turn on the LED ON or OFF over MQTT- mosquitto server. if it works then I am planning to develop a Broker server based on mosquitto local host to test the complete application before switching to cloud. ( Can you also suggest such application ready for testing)

Thanks in advance .

VK Verma

@Guillaume K​ 

0 REPLIES 0