43:70c99c2084dc | 44:e52d11b8f252 |
---|---|
52 return false; | 52 return false; |
53 } | 53 } |
54 | 54 |
55 | 55 |
56 | 56 |
57 /** | |
58 * @brief Generate the mqtt payload header. | |
59 * @return Allocated character string with the header. | |
60 */ | |
57 char *payload_header(void) | 61 char *payload_header(void) |
58 { | 62 { |
59 char *tmp, buf[128]; | 63 char *tmp, buf[128]; |
60 esp_err_t err; | 64 esp_err_t err; |
61 | 65 |
69 return tmp; | 73 return tmp; |
70 } | 74 } |
71 | 75 |
72 | 76 |
73 | 77 |
78 /** | |
79 * @brief Generate the mqtt topic base part. | |
80 * @param msgtype The message type part of the topic. | |
81 * @return The topic string allocated in memory. | |
82 */ | |
74 char *topic_base(char *msgtype) | 83 char *topic_base(char *msgtype) |
75 { | 84 { |
76 char *tmp; | 85 char *tmp; |
77 | 86 |
78 tmp = xstrcpy((char *)"mbv1.0/co2meters/"); | 87 tmp = xstrcpy((char *)"mbv1.0/co2meters/"); |
82 return tmp; | 91 return tmp; |
83 } | 92 } |
84 | 93 |
85 | 94 |
86 | 95 |
96 /** | |
97 * @brief The mqtt generic publish function. | |
98 * @param topic The topic of the mqtt message. | |
99 * @param payload The payload of the mqtt message. | |
100 */ | |
87 void publisher(char *topic, char *payload) | 101 void publisher(char *topic, char *payload) |
88 { | 102 { |
89 /* | 103 /* |
90 * First count, then sent the data. | 104 * First count, then sent the data. |
91 */ | 105 */ |
102 esp_mqtt_client_publish(client, topic, NULL, 0, 1, 0); | 116 esp_mqtt_client_publish(client, topic, NULL, 0, 1, 0); |
103 } | 117 } |
104 | 118 |
105 | 119 |
106 | 120 |
121 /** | |
122 * @brief Generate json data for the given unit. | |
123 * @param i The unit record number. | |
124 * @return The json string allocated in memory. | |
125 */ | |
107 char *unit_data(int i) | 126 char *unit_data(int i) |
108 { | 127 { |
109 char *payload = NULL; | 128 char *payload = NULL; |
110 char buf[128]; | 129 char buf[128]; |
111 | 130 |