MQTT_PublishSensor()
Description
Function publishes sensor data to server. No other options available for this function.
Note that this function is responsible to set a flag for pending sensor registration. Once every second sensors table is being checked for pending sensor capturing. When telemetry frame is being serialized values available at the moment of data capturing are being used.
MQTT_PublishSensor function is not synchronized with data serialization. Async use of this function may result in data being split across two consecutive telemetry frames. In case where data consistency within single payload is required, use publishing synchronization using MQTT_PublishPending callback.
Syntax
MQTT_PublishSensor(sensor_ID);
Parameters
Variable | Input |
|---|---|
| Any sensor from Script sensor list. |
Returns
Return value | Return explanation |
SCRIPT_OPERATION_SUCCESS | Success |
SCRIPT_OPERATION_FAILED | Failed |
SCRIPT_PARAM_INVALID | Incorrect sensor ID. |
Function call example
Example of publishing sensor value to server
main()
{
MQTT_PublishSensor(Sensor_GPS_coordinates); // publish Sensor_GPS_coordinates to server
MQTT_PublishSensor(Sensor_GPS_speed); // publish Sensor_GPS_speed to server
MQTT_PublishSensor(Sensor_SignalIN2); // publish Sensor_SignalIN2 to server
MQTT_PublishSensor(Sensor_SignalMotion); // publish Sensor_SignalMotion to server
MQTT_PublishSensor(Sensor_GSM_PWR); // publish Sensor_GSM_PWR to server
for(;;)
{
Delay(100);
}
}