main.cpp: bug fixed channel rotation
This commit is contained in:
parent
65c9784fc7
commit
703e6ec894
26
src/main.cpp
26
src/main.cpp
@ -246,26 +246,24 @@ void wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type);
|
|||||||
void wifi_sniffer_loop(void * pvParameters) {
|
void wifi_sniffer_loop(void * pvParameters) {
|
||||||
|
|
||||||
configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check
|
configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check
|
||||||
uint8_t channel = 1;
|
uint8_t channel=0;
|
||||||
int nloop=0, lorawait=0;
|
int nloop=0, lorawait=0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
nloop++; // acutal number of wifi loops
|
|
||||||
|
|
||||||
// execute BLE count if BLE function is enabled
|
nloop++; // acutal number of wifi loops, controls cycle when data is sent
|
||||||
#ifdef BLECOUNTER
|
|
||||||
// Once 2 full Wifi Channels scan, do a BLE scan
|
#ifdef BLECOUNTER // execute BLE count if BLE function is enabled
|
||||||
if (nloop % (WIFI_CHANNEL_MAX*2) == 0 ) {
|
if (nloop % (WIFI_CHANNEL_MAX*2) == 0 ) { // once 2 full Wifi Channels scan, do a BLE scan
|
||||||
// execute BLE count if BLE function is enabled
|
if (cfg.blescan) // execute BLE count if BLE function is enabled
|
||||||
if (cfg.blescan)
|
|
||||||
BLECount();
|
BLECount();
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
||||||
wifi_sniffer_set_channel(channel);
|
wifi_sniffer_set_channel(channel);
|
||||||
channel = (channel % WIFI_CHANNEL_MAX) + 1;
|
|
||||||
ESP_LOGI(TAG, "Wifi set channel %d", channel);
|
ESP_LOGI(TAG, "Wifi set channel %d", channel);
|
||||||
|
|
||||||
u8x8.setCursor(0,5);
|
u8x8.setCursor(0,5);
|
||||||
@ -278,10 +276,8 @@ void wifi_sniffer_loop(void * pvParameters) {
|
|||||||
// 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)) ) {
|
||||||
u8x8.setPowerSave(!cfg.screenon); // set display on if enabled
|
u8x8.setPowerSave(!cfg.screenon); // set display on if enabled
|
||||||
nloop = 0; // reset wlan sniffing loop counter
|
nloop = 0; // reset wifi scan loop counter
|
||||||
|
do_send(&sendjob); // Prepare and execute LoRaWAN data upload
|
||||||
// Prepare and execute LoRaWAN data upload
|
|
||||||
do_send(&sendjob); // send payload
|
|
||||||
vTaskDelay(500/portTICK_PERIOD_MS);
|
vTaskDelay(500/portTICK_PERIOD_MS);
|
||||||
yield();
|
yield();
|
||||||
|
|
||||||
@ -317,8 +313,8 @@ 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 infinite wifi scan loop
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end wifi specific parts ------------------------------------------------------------ */
|
/* end wifi specific parts ------------------------------------------------------------ */
|
||||||
|
Loading…
Reference in New Issue
Block a user