restructured wifi channel rotation
This commit is contained in:
parent
5678a5b23c
commit
ff759e1533
14
src/main.cpp
14
src/main.cpp
@ -291,8 +291,7 @@ void setup() {
|
|||||||
Task Core Prio Purpose
|
Task Core Prio Purpose
|
||||||
====================================================================
|
====================================================================
|
||||||
IDLE 0 0 ESP32 arduino scheduler
|
IDLE 0 0 ESP32 arduino scheduler
|
||||||
wifiloop 0 1 switches Wifi channels
|
gpsloop 0 2 read data from GPS over serial or i2c
|
||||||
gpsloop 0 2 reasd data from GPS over serial or i2c
|
|
||||||
IDLE 1 0 Arduino loop() -> unused
|
IDLE 1 0 Arduino loop() -> unused
|
||||||
loraloop 1 1 runs the LMIC stack
|
loraloop 1 1 runs the LMIC stack
|
||||||
statemachine 1 3 switches process logic
|
statemachine 1 3 switches process logic
|
||||||
@ -338,8 +337,6 @@ void setup() {
|
|||||||
// arduino-esp32 core. Note: do this *after* wifi has started, since
|
// arduino-esp32 core. Note: do this *after* wifi has started, since
|
||||||
// function gets it's seed from RF noise
|
// function gets it's seed from RF noise
|
||||||
reset_salt(); // get new 16bit for salting hashes
|
reset_salt(); // get new 16bit for salting hashes
|
||||||
xTaskCreatePinnedToCore(wifi_channel_loop, "wifiloop", 2048, (void *)1, 1,
|
|
||||||
&WifiLoopTask, 0);
|
|
||||||
|
|
||||||
// start state machine
|
// start state machine
|
||||||
ESP_LOGI(TAG, "Starting Statemachine...");
|
ESP_LOGI(TAG, "Starting Statemachine...");
|
||||||
@ -366,12 +363,15 @@ void stateMachine(void *pvParameters) {
|
|||||||
updateDisplay();
|
updateDisplay();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// check housekeeping cycle and if expired do the work
|
// check wifi scan cycle and if due rotate channel
|
||||||
|
if (ChannelTimerIRQ)
|
||||||
|
switchWifiChannel(channel);
|
||||||
|
// check housekeeping cycle and if due do the work
|
||||||
if (HomeCycleIRQ)
|
if (HomeCycleIRQ)
|
||||||
doHousekeeping();
|
doHousekeeping();
|
||||||
// check send queue and process it
|
// check send queue and process it
|
||||||
processSendBuffer();
|
enqueuePayload();
|
||||||
// check send cycle and enqueue payload if cycle is expired
|
// check send cycle and if due enqueue payload to send
|
||||||
if (SendCycleTimerIRQ)
|
if (SendCycleTimerIRQ)
|
||||||
sendPayload();
|
sendPayload();
|
||||||
// yield to CPU
|
// yield to CPU
|
||||||
|
@ -74,7 +74,7 @@ void IRAM_ATTR SendCycleIRQ() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// interrupt triggered function to eat data from RTos send queues and transmit it
|
// interrupt triggered function to eat data from RTos send queues and transmit it
|
||||||
void processSendBuffer() {
|
void enqueuePayload() {
|
||||||
MessageBuffer_t SendBuffer;
|
MessageBuffer_t SendBuffer;
|
||||||
|
|
||||||
#ifdef HAS_LORA
|
#ifdef HAS_LORA
|
||||||
@ -98,7 +98,7 @@ void processSendBuffer() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // processSendBuffer
|
} // enqueuePayload
|
||||||
|
|
||||||
void flushQueues() {
|
void flushQueues() {
|
||||||
#ifdef HAS_LORA
|
#ifdef HAS_LORA
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
void SendData(uint8_t port);
|
void SendData(uint8_t port);
|
||||||
void sendPayload(void);
|
void sendPayload(void);
|
||||||
void SendCycleIRQ(void);
|
void SendCycleIRQ(void);
|
||||||
void processSendBuffer(void);
|
void enqueuePayload(void);
|
||||||
void flushQueues();
|
void flushQueues();
|
||||||
|
|
||||||
#endif // _SENDDATA_H_
|
#endif // _SENDDATA_H_
|
@ -43,26 +43,15 @@ void wifi_sniffer_init(void) {
|
|||||||
ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true)); // now switch on monitor mode
|
ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true)); // now switch on monitor mode
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wifi channel rotation task
|
// Wifi channel rotation
|
||||||
void wifi_channel_loop(void *pvParameters) {
|
void switchWifiChannel(uint8_t &ch) {
|
||||||
|
|
||||||
configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
|
|
||||||
if (ChannelTimerIRQ) {
|
|
||||||
portENTER_CRITICAL(&timerMux);
|
portENTER_CRITICAL(&timerMux);
|
||||||
ChannelTimerIRQ = 0;
|
ChannelTimerIRQ = 0;
|
||||||
portEXIT_CRITICAL(&timerMux);
|
portEXIT_CRITICAL(&timerMux);
|
||||||
// rotates variable channel 1..WIFI_CHANNEL_MAX
|
// rotates variable channel 1..WIFI_CHANNEL_MAX
|
||||||
channel = (channel % WIFI_CHANNEL_MAX) + 1;
|
ch = (ch % WIFI_CHANNEL_MAX) + 1;
|
||||||
esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
|
esp_wifi_set_channel(ch, WIFI_SECOND_CHAN_NONE);
|
||||||
ESP_LOGD(TAG, "Wifi set channel %d", channel);
|
ESP_LOGD(TAG, "Wifi set channel %d", &ch);
|
||||||
}
|
|
||||||
|
|
||||||
vTaskDelay(2 / portTICK_PERIOD_MS); // yield to CPU
|
|
||||||
|
|
||||||
} // end of infinite wifi channel rotation loop
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IRQ handler
|
// IRQ handler
|
||||||
|
@ -28,6 +28,6 @@ typedef struct {
|
|||||||
void wifi_sniffer_init(void);
|
void wifi_sniffer_init(void);
|
||||||
void wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type);
|
void wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type);
|
||||||
void ChannelSwitchIRQ(void);
|
void ChannelSwitchIRQ(void);
|
||||||
void wifi_channel_loop(void *pvParameters);
|
void switchWifiChannel(uint8_t &ch);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user