diff --git a/src/senddata.cpp b/src/senddata.cpp index 1d4bd81b..5fb2cd6a 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -96,9 +96,8 @@ void sendData() { #if !(PAYLOAD_OPENSENSEBOX) payload.addCount(count.wifi_count, MAC_SNIFF_WIFI); - if (cfg.blescan) { + if (cfg.blescan) payload.addCount(count.ble_count, MAC_SNIFF_BLE); - } #endif #if (HAS_GPS) @@ -114,116 +113,116 @@ void sendData() { #if (PAYLOAD_OPENSENSEBOX) payload.addCount(count.wifi_count, MAC_SNIFF_WIFI); - if (cfg.blescan) { + if (cfg.blescan) payload.addCount(count.ble_count, MAC_SNIFF_BLE); #endif #if (HAS_SDS011) - sds011_store(&sds_status); - payload.addSDS(sds_status); + sds011_store(&sds_status); + payload.addSDS(sds_status); #endif #ifdef HAS_DISPLAY - dp_plotCurve(count.pax, true); + dp_plotCurve(count.pax, true); #endif #if (HAS_SDCARD) - sdcardWriteData(count.wifi_count, count.ble_count + sdcardWriteData(count.wifi_count, count.ble_count #if (defined BAT_MEASURE_ADC || defined HAS_PMU) - , - read_voltage() + , + read_voltage() #endif - ); + ); #endif // HAS_SDCARD - SendPayload(COUNTERPORT); - break; // case COUNTDATA + SendPayload(COUNTERPORT); + break; // case COUNTDATA #endif // ((WIFICOUNTER) || (BLECOUNTER)) #if (HAS_BME) - case MEMS_DATA: - payload.reset(); - payload.addBME(bme_status); - SendPayload(BMEPORT); - break; + case MEMS_DATA: + payload.reset(); + payload.addBME(bme_status); + SendPayload(BMEPORT); + break; #endif #if (HAS_GPS) - case GPS_DATA: - if (GPSPORT != COUNTERPORT) { - // send GPS position only if we have a fix - if (gps_hasfix()) { - gps_storelocation(&gps_status); - payload.reset(); - payload.addGPS(gps_status); - SendPayload(GPSPORT); - } else - ESP_LOGD(TAG, "No valid GPS position"); - } - break; + case GPS_DATA: + if (GPSPORT != COUNTERPORT) { + // send GPS position only if we have a fix + if (gps_hasfix()) { + gps_storelocation(&gps_status); + payload.reset(); + payload.addGPS(gps_status); + SendPayload(GPSPORT); + } else + ESP_LOGD(TAG, "No valid GPS position"); + } + break; #endif #if (HAS_SENSORS) #if (HAS_SENSOR_1) - case SENSOR1_DATA: - payload.reset(); - payload.addSensor(sensor_read(1)); - SendPayload(SENSOR1PORT); - break; + case SENSOR1_DATA: + payload.reset(); + payload.addSensor(sensor_read(1)); + SendPayload(SENSOR1PORT); + break; #endif #if (HAS_SENSOR_2) - case SENSOR2_DATA: - payload.reset(); - payload.addSensor(sensor_read(2)); - SendPayload(SENSOR2PORT); - break; + case SENSOR2_DATA: + payload.reset(); + payload.addSensor(sensor_read(2)); + SendPayload(SENSOR2PORT); + break; #endif #if (HAS_SENSOR_3) - case SENSOR3_DATA: - payload.reset(); - payload.addSensor(sensor_read(3)); - SendPayload(SENSOR3PORT); - break; + case SENSOR3_DATA: + payload.reset(); + payload.addSensor(sensor_read(3)); + SendPayload(SENSOR3PORT); + break; #endif #endif #if (defined BAT_MEASURE_ADC || defined HAS_PMU) - case BATT_DATA: - payload.reset(); - payload.addVoltage(read_voltage()); - SendPayload(BATTPORT); - break; + case BATT_DATA: + payload.reset(); + payload.addVoltage(read_voltage()); + SendPayload(BATTPORT); + break; #endif - } // switch - bitmask &= ~mask; - mask <<= 1; - } // while (bitmask) - } // sendData() + } // switch + bitmask &= ~mask; + mask <<= 1; + } // while (bitmask) +} // sendData() - void flushQueues(void) { - rcmd_queuereset(); +void flushQueues(void) { + rcmd_queuereset(); #if (HAS_LORA) - lora_queuereset(); + lora_queuereset(); #endif #ifdef HAS_SPI - spi_queuereset(); + spi_queuereset(); #endif #ifdef HAS_MQTT - mqtt_queuereset(); + mqtt_queuereset(); #endif - } +} - bool allQueuesEmtpy(void) { - uint32_t rc = rcmd_queuewaiting(); +bool allQueuesEmtpy(void) { + uint32_t rc = rcmd_queuewaiting(); #if (HAS_LORA) - rc += lora_queuewaiting(); + rc += lora_queuewaiting(); #endif #ifdef HAS_SPI - rc += spi_queuewaiting(); + rc += spi_queuewaiting(); #endif #ifdef HAS_MQTT - rc += mqtt_queuewaiting(); + rc += mqtt_queuewaiting(); #endif - return (rc == 0) ? true : false; - } + return (rc == 0) ? true : false; +}