main/task_mqtt.c

changeset 32
84e54b14e7db
parent 26
29dc2064e2ce
child 37
50dbb626fbab
equal deleted inserted replaced
31:ec5c7794dcd6 32:84e54b14e7db
20 const int TASK_MQTT_DISCONNECTED = BIT3; 20 const int TASK_MQTT_DISCONNECTED = BIT3;
21 21
22 const char *sensState[] = { "OK", "ERROR" }; ///< Sensor state strings 22 const char *sensState[] = { "OK", "ERROR" }; ///< Sensor state strings
23 const char *unitMode[] = { "OFF", "ON" }; ///< Units state strings 23 const char *unitMode[] = { "OFF", "ON" }; ///< Units state strings
24 24
25 extern TEMP_State *temp_state; ///< Internal temperature state
26 extern SemaphoreHandle_t xSemaphoreTEMP; ///< Internal temperature semaphore
25 extern BMP280_State *bmp280_state; ///< BMP280 state 27 extern BMP280_State *bmp280_state; ///< BMP280 state
26 extern SemaphoreHandle_t xSemaphoreBMP280; ///< BMP280 lock semaphore 28 extern SemaphoreHandle_t xSemaphoreBMP280; ///< BMP280 lock semaphore
27 extern INA219_State *ina219_state; ///< INA219 state 29 extern INA219_State *ina219_state; ///< INA219 state
28 extern SemaphoreHandle_t xSemaphoreINA219; ///< INA219 lock semaphore 30 extern SemaphoreHandle_t xSemaphoreINA219; ///< INA219 lock semaphore
29 extern APDS9930_State *apds9930_state; ///< APDS9930 state 31 extern APDS9930_State *apds9930_state; ///< APDS9930 state
170 } 172 }
171 sprintf(buf, "%d", Quality); 173 sprintf(buf, "%d", Quality);
172 payload = xstrcat(payload, buf); 174 payload = xstrcat(payload, buf);
173 xSemaphoreGive(xSemaphoreWiFi); 175 xSemaphoreGive(xSemaphoreWiFi);
174 } 176 }
177 if (xSemaphoreTake(xSemaphoreTEMP, 25) == pdTRUE) {
178 payload = xstrcat(payload, (char *)",\"temperature\":");
179 sprintf(buf, "%.1f", temp_state->temperature);
180 payload = xstrcat(payload, buf);
181 xSemaphoreGive(xSemaphoreTEMP);
182 }
175 payload = xstrcat(payload, (char *)",\"light\":{\"lux\":"); 183 payload = xstrcat(payload, (char *)",\"light\":{\"lux\":");
176 if (xSemaphoreTake(xSemaphoreAPDS9930, 25) == pdTRUE) { 184 if (xSemaphoreTake(xSemaphoreAPDS9930, 25) == pdTRUE) {
177 sprintf(buf, "%.1f", apds9930_state->ambient_light); 185 sprintf(buf, "%.1f", apds9930_state->ambient_light);
178 payload = xstrcat(payload, buf); 186 payload = xstrcat(payload, buf);
179 payload = xstrcat(payload, (char *)",\"gain\":"); 187 payload = xstrcat(payload, (char *)",\"gain\":");

mercurial