channel hopping switch on/off option
This commit is contained in:
parent
258b6fce53
commit
28d30493fd
@ -303,7 +303,7 @@ Hereafter described is the default *plain* format, which uses MSB bit numbering.
|
||||
byte 6: Counter mode (0=cyclic unconfirmed, 1=cumulative, 2=cyclic confirmed) [default 0]
|
||||
bytes 7-8: RSSI limiter threshold value (negative) [default 0]
|
||||
byte 9: Lora Payload send cycle in seconds/2 (0..255) [default 120]
|
||||
byte 10: Wifi channel switch interval in seconds/100 (0..255) [default 50]
|
||||
byte 10: Wifi channel hopping interval in seconds/100 (0..255), 0 means no hopping [default 50]
|
||||
byte 11: Bluetooth channel switch interval in seconds/100 (0..255) [efault 10]
|
||||
byte 12: Bluetooth scanner status (1=on, 0=0ff) [default 1]
|
||||
byte 13: Wifi antenna switch (0=internal, 1=external) [default 0]
|
||||
@ -437,10 +437,11 @@ Send for example `8386` as Downlink on Port 2 to get battery status and time/dat
|
||||
0 ... 255 payload send cycle in seconds/2
|
||||
e.g. 120 -> payload is transmitted each 240 seconds [default]
|
||||
|
||||
0x0B set Wifi channel switch interval timer
|
||||
0x0B set Wifi channel hopping interval timer
|
||||
|
||||
0 ... 255 duration for scanning a wifi channel in seconds/100
|
||||
e.g. 50 -> each channel is scanned for 500 milliseconds [default]
|
||||
0 means no hopping, scanning on channel WIFI_CHANNEL_MIN only
|
||||
|
||||
0x0C set Bluetooth channel switch interval timer
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "antenna.h" // code for switching wifi antennas
|
||||
#include "macsniff.h"
|
||||
|
||||
extern TimerHandle_t WifiChanTimer;
|
||||
|
||||
void wifi_sniffer_init(void);
|
||||
void switch_wifi_sniffer(uint8_t state);
|
||||
void IRAM_ATTR wifi_sniffer_packet_handler(void *buff,
|
||||
|
@ -88,7 +88,7 @@ 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 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
|
||||
|
||||
|
@ -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,9 +413,9 @@ 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",
|
||||
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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user