task stack sizes tailored; semaphore controlled wifi task
This commit is contained in:
parent
cb4870bce5
commit
b22fd808b8
@ -6,13 +6,13 @@
|
||||
|
||||
; ---> SELECT TARGET PLATFORM HERE! <---
|
||||
[platformio]
|
||||
;env_default = generic
|
||||
env_default = generic
|
||||
;env_default = ebox
|
||||
;env_default = heltec
|
||||
;env_default = ttgov1
|
||||
;env_default = ttgov2
|
||||
;env_default = ttgov21old
|
||||
env_default = ttgov21new
|
||||
;env_default = ttgov21new
|
||||
;env_default = ttgobeam
|
||||
;env_default = lopy
|
||||
;env_default = lopy4
|
||||
@ -29,7 +29,7 @@ description = Paxcounter is a proof-of-concept ESP32 device for metering passeng
|
||||
release_version = 1.5.7
|
||||
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
|
||||
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
|
||||
debug_level = 3
|
||||
debug_level = 0
|
||||
; UPLOAD MODE: select esptool to flash via USB/UART, select custom to upload to cloud for OTA
|
||||
upload_protocol = esptool
|
||||
;upload_protocol = custom
|
||||
|
@ -23,6 +23,19 @@ void doHousekeeping() {
|
||||
if (cfg.runmode == 1)
|
||||
ESP.restart();
|
||||
|
||||
// task storage debugging //
|
||||
#ifdef HAS_LORA
|
||||
ESP_LOGD(TAG, "Loraloop %d bytes left",
|
||||
uxTaskGetStackHighWaterMark(LoraTask));
|
||||
#endif
|
||||
ESP_LOGD(TAG, "Wifiloop %d bytes left",
|
||||
uxTaskGetStackHighWaterMark(wifiSwitchTask));
|
||||
ESP_LOGD(TAG, "Statemachine %d bytes left",
|
||||
uxTaskGetStackHighWaterMark(stateMachineTask));
|
||||
#ifdef HAS_GPS
|
||||
ESP_LOGD(TAG, "Gpsloop %d bytes left", uxTaskGetStackHighWaterMark(GpsTask));
|
||||
#endif
|
||||
|
||||
// read battery voltage into global variable
|
||||
#ifdef HAS_BATTERY_PROBE
|
||||
batt_voltage = read_voltage();
|
||||
|
@ -54,6 +54,7 @@ extern std::array<uint64_t, 0xff>::iterator it;
|
||||
extern std::array<uint64_t, 0xff> beacons;
|
||||
|
||||
extern SemaphoreHandle_t xWifiChannelSwitchSemaphore;
|
||||
extern TaskHandle_t stateMachineTask, wifiSwitchTask;
|
||||
|
||||
#ifdef HAS_GPS
|
||||
extern TaskHandle_t GpsTask;
|
||||
|
23
src/main.cpp
23
src/main.cpp
@ -59,7 +59,7 @@ hw_timer_t *channelSwitch, *displaytimer, *sendCycle, *homeCycle;
|
||||
uint8_t volatile ButtonPressedIRQ = 0, ChannelTimerIRQ = 0,
|
||||
SendCycleTimerIRQ = 0, DisplayTimerIRQ = 0, HomeCycleIRQ = 0;
|
||||
|
||||
TaskHandle_t stateMachineTask = NULL;
|
||||
TaskHandle_t stateMachineTask, wifiSwitchTask;
|
||||
|
||||
SemaphoreHandle_t xWifiChannelSwitchSemaphore;
|
||||
|
||||
@ -308,8 +308,13 @@ void setup() {
|
||||
// https://techtutorialsx.com/2017/05/09/esp32-get-task-execution-core/
|
||||
|
||||
ESP_LOGI(TAG, "Starting Lora...");
|
||||
xTaskCreatePinnedToCore(lorawan_loop, "loraloop", 2048, (void *)1, 1,
|
||||
&LoraTask, 1);
|
||||
xTaskCreatePinnedToCore(lorawan_loop, /* task function */
|
||||
"loraloop", /* name of task */
|
||||
2560, /* stack size of task */
|
||||
(void *)1, /* parameter of the task */
|
||||
1, /* priority of the task */
|
||||
&LoraTask, /* task handle*/
|
||||
1); /* CPU core */
|
||||
#endif
|
||||
|
||||
// if device has GPS and it is enabled, start GPS reader task on core 0 with
|
||||
@ -317,7 +322,13 @@ void setup() {
|
||||
// streaming NMEA data
|
||||
#ifdef HAS_GPS
|
||||
ESP_LOGI(TAG, "Starting GPS...");
|
||||
xTaskCreatePinnedToCore(gps_loop, "gpsloop", 2048, (void *)1, 2, &GpsTask, 0);
|
||||
xTaskCreatePinnedToCore(gps_loop, /* task function */
|
||||
"gpsloop", /* name of task */
|
||||
1024, /* stack size of task */
|
||||
(void *)1, /* parameter of the task */
|
||||
2, /* priority of the task */
|
||||
&GpsTask, /* task handle*/
|
||||
0); /* CPU core */
|
||||
#endif
|
||||
|
||||
// start BLE scan callback if BLE function is enabled in NVRAM configuration
|
||||
@ -339,10 +350,10 @@ void setup() {
|
||||
// start wifi channel rotation task
|
||||
xTaskCreatePinnedToCore(switchWifiChannel, /* task function */
|
||||
"wifiloop", /* name of task */
|
||||
3048, /* stack size of task */
|
||||
1024, /* stack size of task */
|
||||
NULL, /* parameter of the task */
|
||||
4, /* priority of the task */
|
||||
NULL, /* task handle*/
|
||||
&wifiSwitchTask, /* task handle*/
|
||||
0); /* CPU core */
|
||||
|
||||
// start state machine
|
||||
|
@ -57,7 +57,7 @@ void ChannelSwitchIRQ() {
|
||||
// Wifi channel rotation task
|
||||
void switchWifiChannel(void * parameter) {
|
||||
while (1) {
|
||||
// task in block state to wait for channel switch timer interrupt event
|
||||
// task is remaining in block state waiting for channel switch timer interrupt event
|
||||
xSemaphoreTake(xWifiChannelSwitchSemaphore, portMAX_DELAY);
|
||||
// rotates variable channel 1..WIFI_CHANNEL_MAX
|
||||
channel = (channel % WIFI_CHANNEL_MAX) + 1;
|
||||
|
Loading…
Reference in New Issue
Block a user