1.2.3.18 SYS_MQTT_Publish Function
C
int32_t SYS_MQTT_Publish(SYS_MODULE_OBJ obj,
SYS_MQTT_PublishTopicCfg *psPubCfg, char *message, uint16_t message_len);
Summary
Returns success/ failure for the publishing of message on a topic by the user.
Description
This function is used for Publishing a message on a Topic.
Precondition
SYS_MQTT_Connect should have been called before calling this function
Parameters
Param | Description |
---|---|
obj | SYS MQTT object handle, returned from SYS_MQTT_Connect psPubCfg - valid pointer to the Topic details on which to Publish message - Message to be published |
message_len | Message length |
Returns
SYS_MQTT_SUCCESS - Indicates that the Request was catered to successfully
SYS_MQTT_FAILURE - Indicates that the Request failed
Example
SYS_MQTT_PublishTopicCfg sTopicCfg; memset(&sTopicCfg, 0, sizeof(sTopicCfg)); sTopicCfg.qos = 1; sTopicCfg.retain = 1; strcpy(sTopicCfg.topicName, "house/temperature/first_floor/kitchen"); sTopicCfg.topicLength = strlen("house/temperature/first_floor/kitchen"); // Handle "objSysMqtt" value must have been returned from SYS_MQTT_Connect. if( SYS_MQTT_Publish(objSysMqtt, &sPublishCfg, "80.17", strlen("80.17")) == SYS_MQTT_SUCCESS) { }