main.cpp: bug fixed in loop count logic (issue #18)

This commit is contained in:
Klaus K Wilting 2018-04-02 21:02:22 +02:00
parent 703e6ec894
commit da9ea6a35d
2 changed files with 26 additions and 24 deletions

View File

@ -253,13 +253,6 @@ void wifi_sniffer_loop(void * pvParameters) {
nloop++; // acutal number of wifi loops, controls cycle when data is sent nloop++; // acutal number of wifi loops, controls cycle when data is sent
#ifdef BLECOUNTER // execute BLE count if BLE function is enabled
if (nloop % (WIFI_CHANNEL_MAX*2) == 0 ) { // once 2 full Wifi Channels scan, do a BLE scan
if (cfg.blescan) // execute BLE count if BLE function is enabled
BLECount();
}
#endif
vTaskDelay(cfg.wifichancycle*10 / portTICK_PERIOD_MS); vTaskDelay(cfg.wifichancycle*10 / portTICK_PERIOD_MS);
yield(); yield();
channel = (channel % WIFI_CHANNEL_MAX) + 1; // rotates variable channel 1..WIFI_CHANNEL_MAX channel = (channel % WIFI_CHANNEL_MAX) + 1; // rotates variable channel 1..WIFI_CHANNEL_MAX
@ -274,9 +267,9 @@ void wifi_sniffer_loop(void * pvParameters) {
u8x8.printf("MAC#: %-5i", wifis.size()); u8x8.printf("MAC#: %-5i", wifis.size());
// duration of one wifi scan loop reached? then send data and begin new scan cycle // duration of one wifi scan loop reached? then send data and begin new scan cycle
if( nloop >= ((100 / cfg.wifichancycle) * (cfg.wifiscancycle * 2)) ) { if( nloop >= ( (100 / cfg.wifichancycle) * (cfg.wifiscancycle * 2)) +1 ) {
u8x8.setPowerSave(!cfg.screenon); // set display on if enabled u8x8.setPowerSave(!cfg.screenon); // set display on if enabled
nloop = 0; // reset wifi scan loop counter nloop=0; channel=0; // reset wifi scan + channel loop counter
do_send(&sendjob); // Prepare and execute LoRaWAN data upload do_send(&sendjob); // Prepare and execute LoRaWAN data upload
vTaskDelay(500/portTICK_PERIOD_MS); vTaskDelay(500/portTICK_PERIOD_MS);
yield(); yield();
@ -314,6 +307,14 @@ void wifi_sniffer_loop(void * pvParameters) {
yield(); yield();
u8x8.setPowerSave(1 && cfg.screensaver); // set display off if screensaver is enabled u8x8.setPowerSave(1 && cfg.screensaver); // set display off if screensaver is enabled
} // end of send data cycle } // end of send data cycle
else {
#ifdef BLECOUNTER // execute BLE count if BLE function is enabled
if (nloop % (WIFI_CHANNEL_MAX * BLESCANCYCLE) == 0 ) { // once after BLESCANCYCLE Wifi scans, do a BLE scan
if (cfg.blescan) // execute BLE count if BLE function is enabled
BLECount();
}
#endif
} // end of channel rotation loop
} // end of infinite wifi scan loop } // end of infinite wifi scan loop
} }

View File

@ -1,5 +1,5 @@
// program version // program version
#define PROGVERSION "1.2.8" // use max 10 chars here! #define PROGVERSION "1.2.81" // use max 10 chars here!
#define PROGNAME "PAXCNT" #define PROGNAME "PAXCNT"
// Verbose enables serial output // Verbose enables serial output
@ -11,6 +11,7 @@
// BLE scan time // BLE scan time
#define BLESCANTIME 15 // [seconds] #define BLESCANTIME 15 // [seconds]
#define BLESCANCYCLE 2 // BLE scan once after each <BLECYCLE> wifi scans
// WiFi Sniffer cycle interval // WiFi Sniffer cycle interval
#define SEND_SECS 120 // [seconds/2] -> 240 sec. #define SEND_SECS 120 // [seconds/2] -> 240 sec.
@ -19,11 +20,11 @@
// WiFi sniffer config // WiFi sniffer config
#define WIFI_CHANNEL_MIN 1 // start channel number where scan begings #define WIFI_CHANNEL_MIN 1 // start channel number where scan begings
#define WIFI_CHANNEL_MAX 13 // total channel number to scan #define WIFI_CHANNEL_MAX 13 // total channel number to scan
#define WIFI_MY_COUNTRY "EU" // for Wifi RF settings #define WIFI_MY_COUNTRY "EU" // select locale for Wifi RF settings
#define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec. #define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec.
// Default LoRa Spreadfactor // Default LoRa Spreadfactor
#define LORASFDEFAULT 9 // 7 ... 12 #define LORASFDEFAULT 9 // 7 ... 12 SF, according to LoRaWAN specs
#define MAXLORARETRY 500 // maximum count of TX retries if LoRa busy #define MAXLORARETRY 500 // maximum count of TX retries if LoRa busy
#define RCMDPORT 2 // LoRaWAN Port on which device listenes for remote commands #define RCMDPORT 2 // LoRaWAN Port on which device listenes for remote commands