Mercurial > code > home > repos > homeauto
comparison espNode/desk/src/mqtt.cpp @ 1678:7831b5de3572
espNode checkpoint
author | drewp@bigasterisk.com |
---|---|
date | Mon, 27 Sep 2021 22:59:39 -0700 |
parents | 3ff074ba25f1 |
children |
comparison
equal
deleted
inserted
replaced
1677:aa35ae7a1acc | 1678:7831b5de3572 |
---|---|
35 | 'get/model/<fid>' | 35 | 'get/model/<fid>' |
36 fingerprint/set/model/<fid> = binary model data | 36 fingerprint/set/model/<fid> = binary model data |
37 | 37 |
38 Published from MCU: | 38 Published from MCU: |
39 | 39 |
40 mode in {scan, enroll, download, setModel, deleteModel} | |
41 | |
40 fingerprint/<mode>/status = junk | 42 fingerprint/<mode>/status = junk |
41 fingerprint/<mode>/error/<caller> = FPM error message | 43 fingerprint/<mode>/error/<caller> = FPM error message |
42 fingerprint/store = some change to fingerprint storage | 44 fingerprint/store = some change to fingerprint storage |
43 fingerprint/detect = input finger | 45 fingerprint/detect = input finger |
44 fingerprint/model/<fid> = binary model data | 46 fingerprint/model/<fid> = binary model data |
45 fingerprint/image/<fid> = binary image data | 47 fingerprint/image/<fid> = binary image data |
48 fingerprint/temperature = "%.3fC" | |
46 */ | 49 */ |
47 void Publish(const std::string& subtopic, const std::string& msg) { | 50 void Publish(const std::string& subtopic, const std::string& msg) { |
48 std::string topic = "fingerprint/" + subtopic; | 51 std::string topic = "fingerprint/" + subtopic; |
49 mqttClient.publish(topic.c_str(), 1, /*retain=*/false, msg.data(), | 52 mqttClient.publish(topic.c_str(), 1, /*retain=*/false, msg.data(), |
50 msg.size()); | 53 msg.size()); |
59 float temp_c = temperatureRead(); | 62 float temp_c = temperatureRead(); |
60 char buf[20]; | 63 char buf[20]; |
61 snprintf(buf, sizeof(buf), "%.3fC", temp_c); | 64 snprintf(buf, sizeof(buf), "%.3fC", temp_c); |
62 mqttClient.publish("fingerprint/temperature", 1, /*retain=*/true, buf); | 65 mqttClient.publish("fingerprint/temperature", 1, /*retain=*/true, buf); |
63 } | 66 } |
67 | |
64 void onMqttConnect(bool sessionPresent) { | 68 void onMqttConnect(bool sessionPresent) { |
65 Serial.println("Connected to MQTT."); | 69 Serial.println("Connected to MQTT."); |
66 Serial.print("Session present: "); | 70 Serial.print("Session present: "); |
67 Serial.println(sessionPresent); | 71 Serial.println(sessionPresent); |
68 | 72 |