280 ESP_LOGI(TAG, "Loop timer: Wait MQTT"); |
280 ESP_LOGI(TAG, "Loop timer: Wait MQTT"); |
281 |
281 |
282 /* Get global temperature, use for all units. */ |
282 /* Get global temperature, use for all units. */ |
283 uint32_t temp = 0; |
283 uint32_t temp = 0; |
284 int state = 0; |
284 int state = 0; |
|
285 char rom_code[17]; |
285 if (xSemaphoreTake(xSemaphoreDS18B20, 10) == pdTRUE) { |
286 if (xSemaphoreTake(xSemaphoreDS18B20, 10) == pdTRUE) { |
286 temp = (ds18b20_state->bottle_temperature * 1000); |
287 temp = (ds18b20_state->sensor[0].temperature * 1000); |
287 state = (ds18b20_state->bottle_error == 0) ? 0:1; |
288 state = (ds18b20_state->sensor[0].error == 0) ? 0:1; |
|
289 strncpy(rom_code, ds18b20_state->sensor[0].rom_code, strlen(ds18b20_state->sensor[0].rom_code)); |
288 xSemaphoreGive(xSemaphoreDS18B20); |
290 xSemaphoreGive(xSemaphoreDS18B20); |
289 } |
291 } |
290 |
292 |
291 /* Copy measured data and calculate results */ |
293 /* Copy measured data and calculate results */ |
292 for (int i = 0; i < 3; i++) { |
294 for (int i = 0; i < 3; i++) { |
293 units[i].temperature = temp; |
295 units[i].temperature = temp; |
294 units[i].temperature_state = state; |
296 units[i].temperature_state = state; |
|
297 strncpy(units[i].temperature_rom_code, rom_code, strlen(rom_code)); |
295 if (xSemaphoreTake(xSemaphoreADC, 10) == pdTRUE) { |
298 if (xSemaphoreTake(xSemaphoreADC, 10) == pdTRUE) { |
296 units[i].pressure_state = adc_state->Pressure[i].error; |
299 units[i].pressure_state = adc_state->Pressure[i].error; |
297 units[i].pressure_channel = adc_state->Pressure[i].channel; |
300 units[i].pressure_channel = adc_state->Pressure[i].channel; |
298 units[i].pressure_voltage = adc_state->Pressure[i].voltage; |
301 units[i].pressure_voltage = adc_state->Pressure[i].voltage; |
299 units[i].pressure_zero = 110; |
302 units[i].pressure_zero = 110; |