feat(pico-sensor): send sensor values on get-measurement mqtt messages
This commit is contained in:
@@ -132,12 +132,17 @@ static void MqttTask(void *pv) {
|
|||||||
McuLog_error("failed publishing sensor values");
|
McuLog_error("failed publishing sensor values");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
vTaskDelay(pdMS_TO_TICKS(10000));
|
||||||
} /* for */
|
} /* for */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MyMqttMessageCallback(topic_ID_e topic, const unsigned char *payload, size_t len) {
|
static void MyMqttMessageCallback(topic_ID_e topic, const unsigned char *payload, size_t len) {
|
||||||
McuLog_info("MQTT message received, topic: %d, payload: %.*s", topic, (int)len, payload);
|
McuLog_info("MQTT message received, topic: %d, payload: %.*s", topic, (int)len, payload);
|
||||||
|
if (topic==Topic_ID_Send_Measurement) {
|
||||||
|
if (MqttClient_Publish_SensorValues(Sensor_GetTemperature(), Sensor_GetHumidity())!=ERR_OK) {
|
||||||
|
McuLog_error("failed publishing sensor values");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -301,6 +301,8 @@ static void mqtt_incoming_publish_cb(void *arg, const char *topic, u32_t tot_len
|
|||||||
#elif MQTT_CLIENT_IS_SENSOR
|
#elif MQTT_CLIENT_IS_SENSOR
|
||||||
if (McuUtility_strcmp(topic, mqtt.sensors_update_topic)==0) {
|
if (McuUtility_strcmp(topic, mqtt.sensors_update_topic)==0) {
|
||||||
mqtt.in_pub_ID = Topic_ID_Sensor_Update;
|
mqtt.in_pub_ID = Topic_ID_Sensor_Update;
|
||||||
|
} else if (McuUtility_strcmp(topic, mqtt.send_measurement_topic)==0) {
|
||||||
|
mqtt.in_pub_ID = Topic_ID_Send_Measurement;
|
||||||
#endif
|
#endif
|
||||||
} else { /* unknown */
|
} else { /* unknown */
|
||||||
McuLog_trace("MQTT client \"%s\" publish cb: topic %s, len %d", client_info->client_id, topic, (int)tot_len);
|
McuLog_trace("MQTT client \"%s\" publish cb: topic %s, len %d", client_info->client_id, topic, (int)tot_len);
|
||||||
|
|||||||
Reference in New Issue
Block a user