diff --git a/src/senddata.cpp b/src/senddata.cpp index f89710ca..00986562 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -181,144 +181,6 @@ void sendData() { } // sendData() -void flushQueues() { -#if (HAS_LORA) - lora_queuereset(); -#endif -#ifdef HAS_SPI - spi_queuereset(); -#endif -} - SendBuffer.MessagePort = port; - } - memcpy(SendBuffer.Message, payload.getBuffer(), SendBuffer.MessageSize); - -// enqueue message in device's send queues -#if (HAS_LORA) - lora_enqueuedata(&SendBuffer); -#endif -#ifdef HAS_SPI - spi_enqueuedata(&SendBuffer); -#endif - -// write data to sdcard, if present -#ifdef HAS_SDCARD - sdcardWriteData(macs_wifi, macs_ble); -#endif - -} // SendPayload - -// interrupt triggered function to prepare payload to send -void sendData() { - - uint8_t bitmask = cfg.payloadmask; - uint8_t mask = 1; - #if (HAS_GPS) - gpsStatus_t gps_status; - #endif - - while (bitmask) { - switch (bitmask & mask) { - -#if ((WIFICOUNTER) || (BLECOUNTER)) - case COUNT_DATA: - payload.reset(); -#if !(PAYLOAD_OPENSENSEBOX) - if (cfg.wifiscan) - payload.addCount(macs_wifi, MAC_SNIFF_WIFI); - if (cfg.blescan) - payload.addCount(macs_ble, MAC_SNIFF_BLE); -#endif -#if (HAS_GPS) - if (GPSPORT == COUNTERPORT) { - // send GPS position only if we have a fix - if (gps_hasfix()) { - gps_storelocation(&gps_status); - payload.addGPS(gps_status); - } else - ESP_LOGD(TAG, "No valid GPS position"); - } -#endif -#if (PAYLOAD_OPENSENSEBOX) - if (cfg.wifiscan) - payload.addCount(macs_wifi, MAC_SNIFF_WIFI); - if (cfg.blescan) - payload.addCount(macs_ble, MAC_SNIFF_BLE); -#endif -#if (HAS_SDS011) - payload.addPM10(pm10); - payload.addPM25(pm25); -#endif - SendPayload(COUNTERPORT, prio_normal); - // clear counter if not in cumulative counter mode - if (cfg.countermode != 1) { - reset_counters(); // clear macs container and reset all counters - get_salt(); // get new salt for salting hashes - ESP_LOGI(TAG, "Counter cleared"); - } -#ifdef HAS_DISPLAY - else - oledPlotCurve(macs.size(), true); -#endif - break; -#endif - -#if (HAS_BME) - case MEMS_DATA: - payload.reset(); - payload.addBME(bme_status); - SendPayload(BMEPORT, prio_normal); - 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, prio_high); - } else - ESP_LOGD(TAG, "No valid GPS position"); - } - break; -#endif - -#if (HAS_SENSORS) - case SENSOR1_DATA: - payload.reset(); - payload.addSensor(sensor_read(1)); - SendPayload(SENSOR1PORT, prio_normal); - break; - case SENSOR2_DATA: - payload.reset(); - payload.addSensor(sensor_read(2)); - SendPayload(SENSOR2PORT, prio_normal); - break; - case SENSOR3_DATA: - payload.reset(); - payload.addSensor(sensor_read(3)); - SendPayload(SENSOR3PORT, prio_normal); - break; -#endif - -#if (defined BAT_MEASURE_ADC || defined HAS_PMU) - case BATT_DATA: - payload.reset(); - payload.addVoltage(read_voltage()); - SendPayload(BATTPORT, prio_normal); - break; -#endif - - } // switch - bitmask &= ~mask; - mask <<= 1; - } // while (bitmask) - -} // sendData() - void flushQueues() { #if (HAS_LORA) lora_queuereset();