From 2821bc60f304fc0cb6209415f472a173bf31be08 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 14 Jul 2018 23:38:43 +0200 Subject: [PATCH] senddata restructured --- platformio.ini | 4 ++-- src/globals.h | 3 +-- src/rcommand.cpp | 16 +++++++++------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/platformio.ini b/platformio.ini index 8ed83df6..98b73fc2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -47,8 +47,8 @@ build_flags = ; otherwise device may crash in dense environments due to serial buffer overflow ; ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_NONE - -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO -; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG +; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO + -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE ; ; override lora settings from LMiC library in lmic/config.h and use main.h instead diff --git a/src/globals.h b/src/globals.h index 92a70ad0..606d9e69 100644 --- a/src/globals.h +++ b/src/globals.h @@ -38,8 +38,7 @@ extern uint64_t uptimecounter; extern int countermode, screensaver, adrmode, lorasf, txpower, rlim; extern uint16_t macs_total, macs_wifi, macs_ble; // MAC counters extern std::set macs; -extern hw_timer_t - *channelSwitch; // hardware timer used for wifi channel switching +extern hw_timer_t *channelSwitch, *sendCycle; #ifdef HAS_GPS extern gpsStatus_t gps_status; // struct for storing gps data diff --git a/src/rcommand.cpp b/src/rcommand.cpp index 81d920b5..243b6fc3 100644 --- a/src/rcommand.cpp +++ b/src/rcommand.cpp @@ -107,16 +107,18 @@ void set_rssi(uint8_t val) { void set_sendcycle(uint8_t val) { cfg.sendcycle = val; + // update send cycle interrupt + timerAlarmWrite(sendCycle, cfg.sendcycle * 2 * 10000, true); + // reload interrupt after each trigger of channel switch cycle ESP_LOGI(TAG, "Remote command: set payload send cycle to %d seconds", cfg.sendcycle * 2); }; void set_wifichancycle(uint8_t val) { cfg.wifichancycle = val; - // modify wifi channel rotation IRQ - timerAlarmWrite( - channelSwitch, cfg.wifichancycle * 10000, - true); // reload interrupt after each trigger of channel switch cycle + // update channel rotation interrupt + timerAlarmWrite(channelSwitch, cfg.wifichancycle * 10000, true); + ESP_LOGI(TAG, "Remote command: set Wifi channel switch interval to %.1f seconds", cfg.wifichancycle / float(100)); @@ -273,7 +275,7 @@ void set_lorapower(uint8_t val) { ESP_LOGI(TAG, "Remote command: set LoRa TXPOWER to %d", val); switch_lora(cfg.lorasf, val); #else - ESP_LOGW(TAG, "Remote command: LoRa not implemented"); + ESP_LOGW(TAG, "Remote command: LoRa not implemented"); #endif // HAS_LORA }; @@ -289,7 +291,7 @@ void get_status(uint8_t val) { #ifdef HAS_BATTERY_PROBE uint16_t voltage = read_voltage(); #else - uint16_t voltage = 0; + uint16_t voltage = 0; #endif payload.reset(); payload.addStatus(voltage, uptimecounter, temperatureRead()); @@ -304,7 +306,7 @@ void get_gps(uint8_t val) { payload.addGPS(gps_status); senddata(GPSPORT); #else - ESP_LOGW(TAG, "GPS function not supported"); + ESP_LOGW(TAG, "GPS function not supported"); #endif };