commit
686571edd0
@ -26,7 +26,7 @@ description = Paxcounter is a proof-of-concept ESP32 device for metering passeng
|
||||
|
||||
[common]
|
||||
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
|
||||
release_version = 1.5.9
|
||||
release_version = 1.5.13
|
||||
; 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 = 0
|
||||
|
@ -6,6 +6,8 @@
|
||||
// Local logging tag
|
||||
static const char TAG[] = "main";
|
||||
|
||||
portMUX_TYPE mutexButton = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
void IRAM_ATTR ButtonIRQ() {
|
||||
portENTER_CRITICAL(&mutexButton);
|
||||
ButtonPressedIRQ++;
|
||||
|
@ -9,6 +9,8 @@
|
||||
// Local logging tag
|
||||
static const char TAG[] = "main";
|
||||
|
||||
portMUX_TYPE mutexHomeCycle = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
// do all housekeeping
|
||||
void doHousekeeping() {
|
||||
|
||||
|
@ -15,6 +15,8 @@ const char lora_datarate[] = {"100908078CNA121110090807"};
|
||||
|
||||
uint8_t volatile DisplayState = 0;
|
||||
|
||||
portMUX_TYPE mutexDisplay = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
// helper function, prints a hex key on display
|
||||
void DisplayKey(const uint8_t *key, uint8_t len, bool lsb) {
|
||||
const uint8_t *p;
|
||||
|
@ -46,7 +46,6 @@ extern uint16_t volatile macs_total, macs_wifi, macs_ble,
|
||||
batt_voltage; // display values
|
||||
extern std::set<uint16_t> macs; // temp storage for MACs
|
||||
extern hw_timer_t *channelSwitch, *sendCycle;
|
||||
extern portMUX_TYPE mutexButton, mutexDisplay, mutexHomeCycle, mutexSendCycle;
|
||||
extern volatile uint8_t SendCycleTimerIRQ, HomeCycleIRQ, DisplayTimerIRQ,
|
||||
ChannelTimerIRQ, ButtonPressedIRQ;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
|
||||
#define HAS_SPI 1 // comment out if device shall not send data via SPI
|
||||
#define CFG_sx1276_radio 1
|
||||
#define HAS_LED NOT_A_PIN // LoPy4 has no on board mono LED, we use on board RGB LED
|
||||
//#define HAS_LED NOT_A_PIN // LoPy4 has no on board mono LED, we use on board RGB LED
|
||||
#define HAS_RGB_LED GPIO_NUM_0 // WS2812B RGB LED on GPIO0
|
||||
#define BOARD_HAS_PSRAM // use extra 4MB extern RAM
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define HAS_SPI 1 // comment out if device shall not send data via SPI
|
||||
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
|
||||
#define HAS_LED NOT_A_PIN // no usable LED on board
|
||||
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
|
||||
|
||||
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
|
||||
//#define DISPLAY_FLIP 1 // rotated display
|
||||
|
14
src/main.cpp
14
src/main.cpp
@ -30,7 +30,7 @@ Task Core Prio Purpose
|
||||
IDLE 0 0 ESP32 arduino scheduler -> runs wifi sniffer task
|
||||
gpsloop 0 2 read data from GPS over serial or i2c
|
||||
IDLE 1 0 Arduino loop() -> used for LED switching
|
||||
loraloop 1 3 runs the LMIC stack
|
||||
loraloop 1 2 runs the LMIC stack
|
||||
statemachine 1 1 switches application process logic
|
||||
wifiloop 0 4 rotates wifi channels
|
||||
|
||||
@ -77,12 +77,6 @@ QueueHandle_t SPISendQueue;
|
||||
TaskHandle_t GpsTask = NULL;
|
||||
#endif
|
||||
|
||||
// sync main loop and ISR when modifying IRQ handler shared variables
|
||||
portMUX_TYPE mutexButton = portMUX_INITIALIZER_UNLOCKED;
|
||||
portMUX_TYPE mutexDisplay = portMUX_INITIALIZER_UNLOCKED;
|
||||
portMUX_TYPE mutexHomeCycle = portMUX_INITIALIZER_UNLOCKED;
|
||||
portMUX_TYPE mutexSendCycle = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
std::set<uint16_t> macs; // container holding unique MAC adress hashes
|
||||
|
||||
// initialize payload encoder
|
||||
@ -312,9 +306,9 @@ void setup() {
|
||||
ESP_LOGI(TAG, "Starting Lora...");
|
||||
xTaskCreatePinnedToCore(lorawan_loop, /* task function */
|
||||
"loraloop", /* name of task */
|
||||
2560, /* stack size of task */
|
||||
3048, /* stack size of task */
|
||||
(void *)1, /* parameter of the task */
|
||||
3, /* priority of the task */
|
||||
2, /* priority of the task */
|
||||
&LoraTask, /* task handle*/
|
||||
1); /* CPU core */
|
||||
#endif
|
||||
@ -352,7 +346,7 @@ void setup() {
|
||||
// start wifi channel rotation task
|
||||
xTaskCreatePinnedToCore(switchWifiChannel, /* task function */
|
||||
"wifiloop", /* name of task */
|
||||
1536, /* stack size of task */
|
||||
2048, /* stack size of task */
|
||||
NULL, /* parameter of the task */
|
||||
4, /* priority of the task */
|
||||
&wifiSwitchTask, /* task handle*/
|
||||
|
@ -1,6 +1,8 @@
|
||||
// Basic Config
|
||||
#include "globals.h"
|
||||
|
||||
portMUX_TYPE mutexSendCycle = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
// put data to send in RTos Queues used for transmit over channels Lora and SPI
|
||||
void SendData(uint8_t port) {
|
||||
|
||||
|
@ -33,9 +33,6 @@ void wifi_sniffer_init(void) {
|
||||
// .filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT}; // only MGMT frames
|
||||
.filter_mask = WIFI_PROMIS_FILTER_MASK_ALL}; // we use all frames
|
||||
|
||||
// esp_event_loop_init(NULL, NULL);
|
||||
// ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL));
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg)); // configure Wifi with cfg
|
||||
ESP_ERROR_CHECK(
|
||||
esp_wifi_set_country(&wifi_country)); // set locales for RF and channels
|
||||
@ -50,7 +47,7 @@ void wifi_sniffer_init(void) {
|
||||
}
|
||||
|
||||
// IRQ Handler
|
||||
void ChannelSwitchIRQ() {
|
||||
void IRAM_ATTR ChannelSwitchIRQ() {
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
// unblock wifi channel rotation task
|
||||
xSemaphoreGiveFromISR(xWifiChannelSwitchSemaphore, &xHigherPriorityTaskWoken);
|
||||
|
@ -27,7 +27,7 @@ typedef struct {
|
||||
|
||||
void wifi_sniffer_init(void);
|
||||
void IRAM_ATTR wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type);
|
||||
void ChannelSwitchIRQ(void);
|
||||
void IRAM_ATTR ChannelSwitchIRQ(void);
|
||||
void switchWifiChannel(void * parameter);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user