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