channel hopping switch on/off option
This commit is contained in:
1 parent
258b6fce53
commit
28d30493fd
5 files changed
+36
-17
No files matched your search
+2
-2
@@ -88,8 +88,8 @@ triggers pps 1 sec impulse
|
||||
configData_t cfg; // struct holds current device configuration
|
||||
char lmic_event_msg[LMIC_EVENTMSG_LEN]; // display buffer for LMIC event message
|
||||
uint8_t batt_level = 0; // display value
|
||||
uint8_t volatile channel = 0; // channel rotation counter
|
||||
uint8_t volatile rf_load = 0; // RF traffic indicator
|
||||
uint8_t volatile channel = WIFI_CHANNEL_MIN; // channel rotation counter
|
||||
uint8_t volatile rf_load = 0; // RF traffic indicator
|
||||
uint16_t volatile macs_wifi = 0, macs_ble = 0; // globals for display
|
||||
|
||||
hw_timer_t *ppsIRQ = NULL, *displayIRQ = NULL, *matrixDisplayIRQ = NULL;
|
||||
|
||||
+16
-7
@@ -63,11 +63,20 @@ void set_sleepcycle(uint8_t val[]) {
|
||||
void set_wifichancycle(uint8_t val[]) {
|
||||
cfg.wifichancycle = val[0];
|
||||
// update Wifi channel rotation timer period
|
||||
xTimerChangePeriod(WifiChanTimer, pdMS_TO_TICKS(cfg.wifichancycle * 10), 100);
|
||||
|
||||
if (cfg.wifichancycle > 0) {
|
||||
if (xTimerIsTimerActive(WifiChanTimer) == pdFALSE)
|
||||
xTimerStart(WifiChanTimer, (TickType_t) 0);
|
||||
xTimerChangePeriod(WifiChanTimer, pdMS_TO_TICKS(cfg.wifichancycle * 10),
|
||||
100);
|
||||
ESP_LOGI(TAG,
|
||||
"Remote command: set Wifi channel switch interval to %.1f seconds",
|
||||
"Remote command: set Wifi channel hopping interval to %.1f seconds",
|
||||
cfg.wifichancycle / float(100));
|
||||
} else {
|
||||
xTimerStop(WifiChanTimer, (TickType_t) 0);
|
||||
esp_wifi_set_channel(WIFI_CHANNEL_MIN, WIFI_SECOND_CHAN_NONE);
|
||||
channel = WIFI_CHANNEL_MIN;
|
||||
ESP_LOGI(TAG, "Remote command: set Wifi channel hopping to off");
|
||||
}
|
||||
}
|
||||
|
||||
void set_blescantime(uint8_t val[]) {
|
||||
@@ -404,10 +413,10 @@ void rcommand(const uint8_t cmd[], const uint8_t cmdlength) {
|
||||
table[i].func(
|
||||
foundcmd); // execute assigned function with given parameters
|
||||
} else
|
||||
ESP_LOGI(
|
||||
TAG,
|
||||
"Remote command x%02X called with missing parameter(s), skipped",
|
||||
table[i].opcode);
|
||||
ESP_LOGI(TAG,
|
||||
"Remote command x%02X called with missing parameter(s), "
|
||||
"skipped",
|
||||
table[i].opcode);
|
||||
break; // command found -> exit table lookup loop
|
||||
} // end of command validation
|
||||
} // end of command table lookup loop
|
||||
|
||||
+13
-6
@@ -41,8 +41,6 @@ IRAM_ATTR void wifi_sniffer_packet_handler(void *buff,
|
||||
|
||||
// Software-timer driven Wifi channel rotation callback function
|
||||
void switchWifiChannel(TimerHandle_t xTimer) {
|
||||
// static uint8_t channel = 0; // channel rotation counter
|
||||
_ASSERT(xTimer != NULL);
|
||||
channel =
|
||||
(channel % WIFI_CHANNEL_MAX) + 1; // rotate channel 1..WIFI_CHANNEL_MAX
|
||||
esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
|
||||
@@ -74,20 +72,29 @@ void wifi_sniffer_init(void) {
|
||||
|
||||
// setup wifi channel rotation timer
|
||||
WifiChanTimer =
|
||||
xTimerCreate("WifiChannelTimer", pdMS_TO_TICKS(cfg.wifichancycle * 10),
|
||||
xTimerCreate("WifiChannelTimer",
|
||||
(cfg.wifichancycle > 0) ? pdMS_TO_TICKS(cfg.wifichancycle)
|
||||
: pdMS_TO_TICKS(50),
|
||||
pdTRUE, (void *)0, switchWifiChannel);
|
||||
if (cfg.wifichancycle > 0)
|
||||
xTimerStart(WifiChanTimer, (TickType_t) 0);
|
||||
else
|
||||
esp_wifi_set_channel(WIFI_CHANNEL_MIN, WIFI_SECOND_CHAN_NONE);
|
||||
}
|
||||
|
||||
void switch_wifi_sniffer(uint8_t state) {
|
||||
_ASSERT(WifiChanTimer != NULL);
|
||||
if (state) {
|
||||
// switch wifi sniffer on
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
xTimerStart(WifiChanTimer, 0);
|
||||
if (cfg.wifichancycle > 0)
|
||||
xTimerStart(WifiChanTimer, (TickType_t) 0);
|
||||
else
|
||||
esp_wifi_set_channel(WIFI_CHANNEL_MIN, WIFI_SECOND_CHAN_NONE);
|
||||
esp_wifi_set_promiscuous(true);
|
||||
} else {
|
||||
// switch wifi sniffer off
|
||||
xTimerStop(WifiChanTimer, 0);
|
||||
if (xTimerIsTimerActive(WifiChanTimer) != pdFALSE)
|
||||
xTimerStop(WifiChanTimer, (TickType_t) 0);
|
||||
esp_wifi_set_promiscuous(false);
|
||||
ESP_ERROR_CHECK(esp_wifi_stop());
|
||||
macs_wifi = 0; // clear WIFI counter
|
||||
|
||||
Reference in new issue
Block a user