senddata restructured

This commit is contained in:
Klaus K Wilting 2018-07-14 23:38:43 +02:00
parent bb3f06bfc4
commit 2821bc60f3
3 changed files with 12 additions and 11 deletions

View File

@ -47,8 +47,8 @@ build_flags =
; otherwise device may crash in dense environments due to serial buffer overflow ; 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_NONE
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_INFO
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE ; -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
; ;
; override lora settings from LMiC library in lmic/config.h and use main.h instead ; override lora settings from LMiC library in lmic/config.h and use main.h instead

View File

@ -38,8 +38,7 @@ extern uint64_t uptimecounter;
extern int countermode, screensaver, adrmode, lorasf, txpower, rlim; extern int countermode, screensaver, adrmode, lorasf, txpower, rlim;
extern uint16_t macs_total, macs_wifi, macs_ble; // MAC counters extern uint16_t macs_total, macs_wifi, macs_ble; // MAC counters
extern std::set<uint16_t> macs; extern std::set<uint16_t> macs;
extern hw_timer_t extern hw_timer_t *channelSwitch, *sendCycle;
*channelSwitch; // hardware timer used for wifi channel switching
#ifdef HAS_GPS #ifdef HAS_GPS
extern gpsStatus_t gps_status; // struct for storing gps data extern gpsStatus_t gps_status; // struct for storing gps data

View File

@ -107,16 +107,18 @@ void set_rssi(uint8_t val) {
void set_sendcycle(uint8_t val) { void set_sendcycle(uint8_t val) {
cfg.sendcycle = 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", ESP_LOGI(TAG, "Remote command: set payload send cycle to %d seconds",
cfg.sendcycle * 2); cfg.sendcycle * 2);
}; };
void set_wifichancycle(uint8_t val) { void set_wifichancycle(uint8_t val) {
cfg.wifichancycle = val; cfg.wifichancycle = val;
// modify wifi channel rotation IRQ // update channel rotation interrupt
timerAlarmWrite( timerAlarmWrite(channelSwitch, cfg.wifichancycle * 10000, true);
channelSwitch, cfg.wifichancycle * 10000,
true); // reload interrupt after each trigger of channel switch cycle
ESP_LOGI(TAG, ESP_LOGI(TAG,
"Remote command: set Wifi channel switch interval to %.1f seconds", "Remote command: set Wifi channel switch interval to %.1f seconds",
cfg.wifichancycle / float(100)); 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); ESP_LOGI(TAG, "Remote command: set LoRa TXPOWER to %d", val);
switch_lora(cfg.lorasf, val); switch_lora(cfg.lorasf, val);
#else #else
ESP_LOGW(TAG, "Remote command: LoRa not implemented"); ESP_LOGW(TAG, "Remote command: LoRa not implemented");
#endif // HAS_LORA #endif // HAS_LORA
}; };
@ -289,7 +291,7 @@ void get_status(uint8_t val) {
#ifdef HAS_BATTERY_PROBE #ifdef HAS_BATTERY_PROBE
uint16_t voltage = read_voltage(); uint16_t voltage = read_voltage();
#else #else
uint16_t voltage = 0; uint16_t voltage = 0;
#endif #endif
payload.reset(); payload.reset();
payload.addStatus(voltage, uptimecounter, temperatureRead()); payload.addStatus(voltage, uptimecounter, temperatureRead());
@ -304,7 +306,7 @@ void get_gps(uint8_t val) {
payload.addGPS(gps_status); payload.addGPS(gps_status);
senddata(GPSPORT); senddata(GPSPORT);
#else #else
ESP_LOGW(TAG, "GPS function not supported"); ESP_LOGW(TAG, "GPS function not supported");
#endif #endif
}; };