commit
0dd81379a1
@ -242,6 +242,8 @@ void bt_loop(void * pvParameters)
|
|||||||
// Initialize BT controller to allocate task and other resource.
|
// Initialize BT controller to allocate task and other resource.
|
||||||
ESP_LOGI(TAG, "Enabling Bluetooth Controller");
|
ESP_LOGI(TAG, "Enabling Bluetooth Controller");
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
|
bt_cfg.controller_task_stack_size = 8192; // double BT stack size
|
||||||
|
|
||||||
if (esp_bt_controller_init(&bt_cfg) != ESP_OK)
|
if (esp_bt_controller_init(&bt_cfg) != ESP_OK)
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG, "Bluetooth controller initialize failed");
|
ESP_LOGE(TAG, "Bluetooth controller initialize failed");
|
||||||
@ -255,6 +257,8 @@ void bt_loop(void * pvParameters)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//esp_bt_controller_mem_release(ESP_BT_MODE_BTDM); // gives 30KB more RAM for heap
|
||||||
|
|
||||||
// Init and alloc the resource for bluetooth, must be prior to every bluetooth stuff
|
// Init and alloc the resource for bluetooth, must be prior to every bluetooth stuff
|
||||||
ESP_LOGI(TAG, "Init Bluetooth stack");
|
ESP_LOGI(TAG, "Init Bluetooth stack");
|
||||||
status = esp_bluedroid_init();
|
status = esp_bluedroid_init();
|
||||||
@ -282,7 +286,7 @@ void bt_loop(void * pvParameters)
|
|||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
vTaskDelay(500/portTICK_PERIOD_MS);
|
vTaskDelay(10/portTICK_PERIOD_MS);
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
|
|
||||||
// std::set for unified array functions
|
// std::set for unified array functions
|
||||||
#include <set>
|
#include <set>
|
||||||
//#include <array>
|
#include <array>
|
||||||
//#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
// OLED Display
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
// OLED Display
|
|
||||||
#include <U8x8lib.h>
|
#include <U8x8lib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -46,13 +46,14 @@ typedef struct {
|
|||||||
extern configData_t cfg;
|
extern configData_t cfg;
|
||||||
extern uint8_t mydata[];
|
extern uint8_t mydata[];
|
||||||
extern uint64_t uptimecounter;
|
extern uint64_t uptimecounter;
|
||||||
extern uint32_t currentMillis ;
|
extern unsigned long currentMillis ;
|
||||||
extern osjob_t sendjob;
|
extern osjob_t sendjob;
|
||||||
extern char display_lora[], display_lmic[];
|
extern char display_lora[], display_lmic[], display_mem[];
|
||||||
extern int countermode, screensaver, adrmode, lorasf, txpower, rlim;
|
extern int countermode, screensaver, adrmode, lorasf, txpower, rlim;
|
||||||
extern uint16_t macs_total, macs_wifi, macs_ble; // MAC counters
|
extern uint16_t macs_total, macs_wifi, macs_ble; // MAC counters
|
||||||
extern bool joinstate;
|
extern bool joinstate;
|
||||||
extern std::set<uint16_t> macs;
|
extern std::set<uint16_t> macs;
|
||||||
|
extern const uint32_t heapmem;
|
||||||
|
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
extern HAS_DISPLAY u8x8;
|
extern HAS_DISPLAY u8x8;
|
||||||
|
@ -27,6 +27,7 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
|
|||||||
bool added = false;
|
bool added = false;
|
||||||
uint32_t addr2int, vendor2int; // temporary buffer for MAC and Vendor OUI
|
uint32_t addr2int, vendor2int; // temporary buffer for MAC and Vendor OUI
|
||||||
uint16_t hashedmac; // temporary buffer for generated hash value
|
uint16_t hashedmac; // temporary buffer for generated hash value
|
||||||
|
float memlevel; // % of used heap mem
|
||||||
|
|
||||||
// only last 3 MAC Address bytes are used for MAC address anonymization
|
// only last 3 MAC Address bytes are used for MAC address anonymization
|
||||||
// but since it's uint32 we take 4 bytes to avoid 1st value to be 0
|
// but since it's uint32 we take 4 bytes to avoid 1st value to be 0
|
||||||
@ -50,25 +51,32 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
|
|||||||
|
|
||||||
// Count only if MAC was not yet seen
|
// Count only if MAC was not yet seen
|
||||||
if (added) {
|
if (added) {
|
||||||
|
// Display heap memory left
|
||||||
|
memlevel = ESP.getFreeHeap() / heapmem * 100;
|
||||||
|
sprintf(display_mem, "%d%%", memlevel);
|
||||||
|
// increment counter and one blink led
|
||||||
if (sniff_type == MAC_SNIFF_WIFI ) {
|
if (sniff_type == MAC_SNIFF_WIFI ) {
|
||||||
macs_wifi++; // increment Wifi MACs counter
|
macs_wifi++; // increment Wifi MACs counter
|
||||||
if (joinstate)
|
#if (HAS_LED != NOT_A_PIN) || defined (HAS_RGB_LED)
|
||||||
blink_LED(COLOR_GREEN, 50, 0);
|
blink_LED(COLOR_GREEN, 50);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef BLECOUNTER
|
#ifdef BLECOUNTER
|
||||||
else if (sniff_type == MAC_SNIFF_BLE ) {
|
else if (sniff_type == MAC_SNIFF_BLE ) {
|
||||||
macs_ble++; // increment BLE Macs counter
|
macs_ble++; // increment BLE Macs counter
|
||||||
if (joinstate)
|
#if (HAS_LED != NOT_A_PIN) || defined (HAS_RGB_LED)
|
||||||
blink_LED(COLOR_MAGENTA, 50, 0);
|
blink_LED(COLOR_MAGENTA, 50);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log scan result
|
// Log scan result
|
||||||
ESP_LOGI(TAG, "%s RSSI %ddBi -> MAC %s -> Hash %04X -> WiFi:%d BLTH:%d %s",
|
ESP_LOGI(TAG, "%s RSSI %ddBi -> MAC %s -> Hash %04X -> WiFi:%d BLTH:%d %s -> %d Bytes left",
|
||||||
sniff_type==MAC_SNIFF_WIFI ? "WiFi":"BLTH",
|
sniff_type==MAC_SNIFF_WIFI ? "WiFi":"BLTH",
|
||||||
rssi, buff, hashedmac, macs_wifi, macs_ble,
|
rssi, buff, hashedmac, macs_wifi, macs_ble,
|
||||||
added ? "new" : "known");
|
added ? "new " : "known",
|
||||||
|
ESP.getFreeHeap());
|
||||||
|
|
||||||
#ifdef VENDORFILTER
|
#ifdef VENDORFILTER
|
||||||
} else {
|
} else {
|
||||||
|
171
src/main.cpp
171
src/main.cpp
@ -41,15 +41,20 @@ Refer to LICENSE.txt file in repository for more details.
|
|||||||
configData_t cfg; // struct holds current device configuration
|
configData_t cfg; // struct holds current device configuration
|
||||||
osjob_t sendjob, initjob; // LMIC jobs
|
osjob_t sendjob, initjob; // LMIC jobs
|
||||||
uint64_t uptimecounter = 0; // timer global for uptime counter
|
uint64_t uptimecounter = 0; // timer global for uptime counter
|
||||||
uint32_t currentMillis = millis(); // timer global for state machine
|
unsigned long currentMillis = millis(); // timer global for state machine
|
||||||
uint32_t previousDisplaymillis = currentMillis; // Display refresh for state machine
|
unsigned long previousDisplaymillis = currentMillis; // Display refresh for state machine
|
||||||
uint8_t DisplayState = 0; // globals for state machine
|
uint8_t DisplayState = 0; // globals for state machine
|
||||||
uint16_t LEDBlinkduration = 0, LEDInterval = 0, color = COLOR_NONE; // state machine variables
|
|
||||||
uint16_t macs_total = 0, macs_wifi = 0, macs_ble = 0; // MAC counters globals for display
|
uint16_t macs_total = 0, macs_wifi = 0, macs_ble = 0; // MAC counters globals for display
|
||||||
uint8_t channel = 0; // wifi channel rotation counter global for display
|
uint8_t channel = 0; // wifi channel rotation counter global for display
|
||||||
char display_lora[16], display_lmic[16]; // display buffers
|
char display_lora[16], display_lmic[16], display_mem[16]; // display buffers
|
||||||
enum states LEDState = LED_OFF, previousLEDState = LED_OFF; // LED state global for state machine
|
led_states LEDState = LED_OFF; // LED state global for state machine
|
||||||
|
led_states previousLEDState = LED_ON; // This will force LED to be off at boot since State is OFF
|
||||||
|
unsigned long LEDBlinkStarted = 0; // When (in millis() led blink started)
|
||||||
|
uint16_t LEDBlinkDuration = 0; // How long the blink need to be
|
||||||
|
uint16_t LEDColor = COLOR_NONE; // state machine variable to set RGB LED color
|
||||||
bool joinstate = false; // LoRa network joined? global flag
|
bool joinstate = false; // LoRa network joined? global flag
|
||||||
|
bool blinkdone = true; // flag for state machine for blinking LED once
|
||||||
|
const uint32_t heapmem = ESP.getFreeHeap(); // free heap memory after start (:= 100%)
|
||||||
|
|
||||||
std::set<uint16_t> macs; // associative container holds total of unique MAC adress hashes (Wifi + BLE)
|
std::set<uint16_t> macs; // associative container holds total of unique MAC adress hashes (Wifi + BLE)
|
||||||
|
|
||||||
@ -68,13 +73,6 @@ int redirect_log(const char * fmt, va_list args) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void blink_LED (uint16_t set_color, uint16_t set_blinkduration, uint16_t set_interval) {
|
|
||||||
color = set_color; // set color for RGB LED
|
|
||||||
LEDBlinkduration = set_blinkduration; // duration on
|
|
||||||
LEDInterval = set_interval; // duration off - on - off
|
|
||||||
LEDState = LED_ON; // start blink
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset_counters() {
|
void reset_counters() {
|
||||||
macs.clear(); // clear all macs container
|
macs.clear(); // clear all macs container
|
||||||
macs_total = 0; // reset all counters
|
macs_total = 0; // reset all counters
|
||||||
@ -148,22 +146,9 @@ void lorawan_loop(void * pvParameters) {
|
|||||||
|
|
||||||
os_runloop_once();
|
os_runloop_once();
|
||||||
|
|
||||||
// LED indicators for viusalizing LoRaWAN state
|
#if (HAS_LED != NOT_A_PIN) || defined (HAS_RGB_LED)
|
||||||
if ( LMIC.opmode & (OP_JOINING | OP_REJOIN) ) {
|
led_loop();
|
||||||
// 5 quick blinks 20ms on each 1/5 second while joining
|
#endif
|
||||||
blink_LED(COLOR_YELLOW, 20, 200);
|
|
||||||
// TX data pending
|
|
||||||
} else if (LMIC.opmode & (OP_TXDATA | OP_TXRXPEND)) {
|
|
||||||
// 3 small blink 10ms on each 1/2sec (not when joining)
|
|
||||||
blink_LED(COLOR_BLUE, 10, 500);
|
|
||||||
// This should not happen so indicate a problem
|
|
||||||
} else if ( LMIC.opmode & (OP_TXDATA | OP_TXRXPEND | OP_JOINING | OP_REJOIN) == 0 ) {
|
|
||||||
// 5 heartbeat long blink 200ms on each 2 seconds
|
|
||||||
blink_LED(COLOR_RED, 200, 2000);
|
|
||||||
} else {
|
|
||||||
// led off
|
|
||||||
blink_LED(COLOR_NONE, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
vTaskDelay(10/portTICK_PERIOD_MS);
|
vTaskDelay(10/portTICK_PERIOD_MS);
|
||||||
yield();
|
yield();
|
||||||
@ -344,6 +329,10 @@ uint64_t uptime() {
|
|||||||
u8x8.printf("%-16s", "BLTH:off");
|
u8x8.printf("%-16s", "BLTH:off");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// update free heap memory display (line 4)
|
||||||
|
u8x8.setCursor(11,4);
|
||||||
|
u8x8.printf("%-5s", display_mem);
|
||||||
|
|
||||||
// update RSSI limiter status & wifi channel display (line 5)
|
// update RSSI limiter status & wifi channel display (line 5)
|
||||||
u8x8.setCursor(0,5);
|
u8x8.setCursor(0,5);
|
||||||
u8x8.printf(!cfg.rssilimit ? "RLIM:off " : "RLIM:%-4d", cfg.rssilimit);
|
u8x8.printf(!cfg.rssilimit ? "RLIM:off " : "RLIM:%-4d", cfg.rssilimit);
|
||||||
@ -387,43 +376,85 @@ uint64_t uptime() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_LED
|
#if (HAS_LED != NOT_A_PIN) || defined (HAS_RGB_LED)
|
||||||
void switchLED() {
|
void blink_LED(uint16_t set_color, uint16_t set_blinkduration) {
|
||||||
|
LEDColor = set_color; // set color for RGB LED
|
||||||
// led need to change state? avoid digitalWrite() for nothing
|
LEDBlinkDuration = set_blinkduration; // duration
|
||||||
if (LEDState != previousLEDState) {
|
LEDBlinkStarted = millis(); // Time Start here
|
||||||
#ifdef LED_ACTIVE_LOW
|
LEDState = LED_ON; // Let main set LED on
|
||||||
digitalWrite(HAS_LED, !LEDState);
|
|
||||||
#else
|
|
||||||
digitalWrite(HAS_LED, LEDState);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAS_RGB_LED
|
|
||||||
rgb_set_color(LEDState ? color : COLOR_NONE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
previousLEDState = LEDState;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // switchLED()
|
void led_loop() {
|
||||||
|
// Custom blink running always have priority other LoRaWAN led management
|
||||||
|
if ( LEDBlinkStarted && LEDBlinkDuration) {
|
||||||
|
|
||||||
void switchLEDstate() {
|
//ESP_LOGI(TAG, "Start=%ld for %g",LEDBlinkStarted, LEDBlinkDuration );
|
||||||
|
|
||||||
// LEDInterval != 0 -> LED is currently blinking -> toggle if interval cycle time elapsed
|
// Custom blink is finished, let this order, avoid millis() overflow
|
||||||
// LEDInterval = 0 -> do one blink then turn off LED
|
if ( (millis() - LEDBlinkStarted) >= LEDBlinkDuration) {
|
||||||
|
// Led becomes off, and stop blink
|
||||||
|
LEDState = LED_OFF;
|
||||||
|
LEDBlinkStarted = 0;
|
||||||
|
LEDBlinkDuration = 0;
|
||||||
|
LEDColor = COLOR_NONE ;
|
||||||
|
} else {
|
||||||
|
// In case of LoRaWAN led management blinked off
|
||||||
|
LEDState = LED_ON;
|
||||||
|
}
|
||||||
|
|
||||||
if (LEDInterval) // LED is blinking, wait until time elapsed, then toggle
|
// No custom blink, check LoRaWAN state
|
||||||
LEDState = ((currentMillis % LEDInterval) < LEDBlinkduration) ? LED_ON : LED_OFF;
|
} else {
|
||||||
else // only one blink
|
|
||||||
LEDState = (currentMillis < LEDBlinkduration) ? LED_ON : LED_OFF;
|
|
||||||
|
|
||||||
} // switchLEDstate()
|
// LED indicators for viusalizing LoRaWAN state
|
||||||
#endif
|
if ( LMIC.opmode & (OP_JOINING | OP_REJOIN) ) {
|
||||||
|
LEDColor = COLOR_YELLOW;
|
||||||
|
// quick blink 20ms on each 1/5 second
|
||||||
|
LEDState = ((millis() % 200) < 20) ? LED_ON : LED_OFF; // TX data pending
|
||||||
|
} else if (LMIC.opmode & (OP_TXDATA | OP_TXRXPEND)) {
|
||||||
|
LEDColor = COLOR_BLUE;
|
||||||
|
// small blink 10ms on each 1/2sec (not when joining)
|
||||||
|
LEDState = ((millis() % 500) < 20) ? LED_ON : LED_OFF;
|
||||||
|
// This should not happen so indicate a problem
|
||||||
|
} else if ( LMIC.opmode & (OP_TXDATA | OP_TXRXPEND | OP_JOINING | OP_REJOIN) == 0 ) {
|
||||||
|
LEDColor = COLOR_RED;
|
||||||
|
// heartbeat long blink 200ms on each 2 seconds
|
||||||
|
LEDState = ((millis() % 2000) < 200) ? LED_ON : LED_OFF;
|
||||||
|
} else {
|
||||||
|
// led off
|
||||||
|
LEDColor = COLOR_NONE;
|
||||||
|
LEDState = LED_OFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//ESP_LOGI(TAG, "state=%d previous=%d Color=%d",LEDState, previousLEDState, LEDColor );
|
||||||
|
// led need to change state? avoid digitalWrite() for nothing
|
||||||
|
if (LEDState != previousLEDState) {
|
||||||
|
if (LEDState == LED_ON) {
|
||||||
|
rgb_set_color(LEDColor);
|
||||||
|
#ifdef LED_ACTIVE_LOW
|
||||||
|
digitalWrite(HAS_LED, LOW);
|
||||||
|
#else
|
||||||
|
digitalWrite(HAS_LED, HIGH);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
rgb_set_color(COLOR_NONE);
|
||||||
|
#ifdef LED_ACTIVE_LOW
|
||||||
|
digitalWrite(HAS_LED, HIGH);
|
||||||
|
#else
|
||||||
|
digitalWrite(HAS_LED, LOW);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
previousLEDState = LEDState;
|
||||||
|
}
|
||||||
|
}; // led_loop()
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* begin Aruino SETUP ------------------------------------------------------------ */
|
/* begin Aruino SETUP ------------------------------------------------------------ */
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
char features[64] = "";
|
||||||
|
|
||||||
// disable brownout detection
|
// disable brownout detection
|
||||||
#ifdef DISABLE_BROWNOUT
|
#ifdef DISABLE_BROWNOUT
|
||||||
@ -463,18 +494,28 @@ void setup() {
|
|||||||
loadConfig(); // includes initialize if necessary
|
loadConfig(); // includes initialize if necessary
|
||||||
|
|
||||||
// initialize led if needed
|
// initialize led if needed
|
||||||
#ifdef HAS_LED
|
#if (HAS_LED != NOT_A_PIN)
|
||||||
pinMode(HAS_LED, OUTPUT);
|
pinMode(HAS_LED, OUTPUT);
|
||||||
blink_LED(COLOR_NONE, 0, 0); // LED off
|
strcat(features, " LED");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_RGB_LED
|
||||||
|
rgb_set_color(COLOR_PINK);
|
||||||
|
strcat(features, " RGB");
|
||||||
|
delay(1000);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// initialize button handling if needed
|
// initialize button handling if needed
|
||||||
#ifdef HAS_BUTTON
|
#ifdef HAS_BUTTON
|
||||||
|
strcat(features, " BTN_");
|
||||||
#ifdef BUTTON_PULLUP
|
#ifdef BUTTON_PULLUP
|
||||||
|
strcat(features, "PU");
|
||||||
// install button interrupt (pullup mode)
|
// install button interrupt (pullup mode)
|
||||||
pinMode(HAS_BUTTON, INPUT_PULLUP);
|
pinMode(HAS_BUTTON, INPUT_PULLUP);
|
||||||
attachInterrupt(digitalPinToInterrupt(HAS_BUTTON), isr_button_pressed, RISING);
|
attachInterrupt(digitalPinToInterrupt(HAS_BUTTON), isr_button_pressed, RISING);
|
||||||
#else
|
#else
|
||||||
|
strcat(features, "PD");
|
||||||
// install button interrupt (pulldown mode)
|
// install button interrupt (pulldown mode)
|
||||||
pinMode(HAS_BUTTON, INPUT_PULLDOWN);
|
pinMode(HAS_BUTTON, INPUT_PULLDOWN);
|
||||||
attachInterrupt(digitalPinToInterrupt(HAS_BUTTON), isr_button_pressed, FALLING);
|
attachInterrupt(digitalPinToInterrupt(HAS_BUTTON), isr_button_pressed, FALLING);
|
||||||
@ -483,11 +524,13 @@ void setup() {
|
|||||||
|
|
||||||
// initialize wifi antenna if needed
|
// initialize wifi antenna if needed
|
||||||
#ifdef HAS_ANTENNA_SWITCH
|
#ifdef HAS_ANTENNA_SWITCH
|
||||||
|
strcat(features, " ANT");
|
||||||
antenna_init();
|
antenna_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_DISPLAY
|
#ifdef HAS_DISPLAY
|
||||||
// initialize display
|
strcat(features, " OLED");
|
||||||
|
// initialize display
|
||||||
init_display(PROGNAME, PROGVERSION);
|
init_display(PROGNAME, PROGVERSION);
|
||||||
DisplayState = cfg.screenon;
|
DisplayState = cfg.screenon;
|
||||||
u8x8.setPowerSave(!cfg.screenon); // set display off if disabled
|
u8x8.setPowerSave(!cfg.screenon); // set display off if disabled
|
||||||
@ -500,9 +543,13 @@ void setup() {
|
|||||||
#endif
|
#endif
|
||||||
u8x8.setCursor(0,5);
|
u8x8.setCursor(0,5);
|
||||||
u8x8.printf(!cfg.rssilimit ? "RLIM:off " : "RLIM:%d", cfg.rssilimit);
|
u8x8.printf(!cfg.rssilimit ? "RLIM:off " : "RLIM:%d", cfg.rssilimit);
|
||||||
|
|
||||||
sprintf(display_lora, "Join wait");
|
sprintf(display_lora, "Join wait");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Display features compiled for
|
||||||
|
ESP_LOGI(TAG, "Features %s", features);
|
||||||
|
|
||||||
// output LoRaWAN keys to console
|
// output LoRaWAN keys to console
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printKeys();
|
printKeys();
|
||||||
@ -521,12 +568,12 @@ ESP_LOGI(TAG, "Starting Lora task on core 1");
|
|||||||
xTaskCreatePinnedToCore(lorawan_loop, "loratask", 2048, ( void * ) 1, ( 5 | portPRIVILEGE_BIT ), NULL, 1);
|
xTaskCreatePinnedToCore(lorawan_loop, "loratask", 2048, ( void * ) 1, ( 5 | portPRIVILEGE_BIT ), NULL, 1);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "Starting Wifi task on core 0");
|
ESP_LOGI(TAG, "Starting Wifi task on core 0");
|
||||||
xTaskCreatePinnedToCore(sniffer_loop, "wifisniffer", 16384, ( void * ) 1, 1, NULL, 0);
|
xTaskCreatePinnedToCore(sniffer_loop, "wifisniffer", 2048, ( void * ) 1, 1, NULL, 0);
|
||||||
|
|
||||||
#ifdef BLECOUNTER
|
#ifdef BLECOUNTER
|
||||||
if (cfg.blescan) { // start BLE task only if BLE function is enabled in NVRAM configuration
|
if (cfg.blescan) { // start BLE task only if BLE function is enabled in NVRAM configuration
|
||||||
ESP_LOGI(TAG, "Starting Bluetooth task on core 0");
|
ESP_LOGI(TAG, "Starting Bluetooth task on core 0");
|
||||||
xTaskCreatePinnedToCore(bt_loop, "btscan", 16384, ( void * ) 1, 1, NULL, 0);
|
xTaskCreatePinnedToCore(bt_loop, "btscan", 4096, ( void * ) 1, 1, NULL, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -545,13 +592,11 @@ do_send(&sendjob);
|
|||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
// simple state machine for controlling display, LED, button, etc.
|
// simple state machine for controlling display, LED, button, etc.
|
||||||
|
|
||||||
uptimecounter = uptime() / 1000; // counts uptime in seconds (64bit)
|
uptimecounter = uptime() / 1000; // counts uptime in seconds (64bit)
|
||||||
currentMillis = millis(); // timebase for state machine in milliseconds (32bit)
|
currentMillis = millis(); // timebase for state machine in milliseconds (32bit)
|
||||||
|
|
||||||
#ifdef HAS_LED
|
#if (HAS_LED != NOT_A_PIN) || defined (HAS_RGB_LED)
|
||||||
switchLEDstate();
|
led_loop();
|
||||||
switchLED();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_BUTTON
|
#ifdef HAS_BUTTON
|
||||||
|
12
src/main.h
12
src/main.h
@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
// program version - note: increment version after modifications to configData_t struct!!
|
// program version - note: increment version after modifications to configData_t struct!!
|
||||||
#define PROGVERSION "1.3.2" // use max 10 chars here!
|
#define PROGVERSION "1.3.22" // use max 10 chars here!
|
||||||
#define PROGNAME "PAXCNT"
|
#define PROGNAME "PAXCNT"
|
||||||
|
|
||||||
//--- Declarations ---
|
//--- Declarations ---
|
||||||
|
|
||||||
enum states {
|
enum led_states {
|
||||||
LED_OFF,
|
LED_OFF,
|
||||||
LED_ON
|
LED_ON
|
||||||
};
|
};
|
||||||
@ -13,8 +13,9 @@ enum states {
|
|||||||
//--- Prototypes ---
|
//--- Prototypes ---
|
||||||
|
|
||||||
// defined in main.cpp
|
// defined in main.cpp
|
||||||
void blink_LED (uint16_t set_color, uint16_t set_blinkduration, uint16_t set_interval);
|
void reset_counters(void);
|
||||||
void reset_counters();
|
void blink_LED(uint16_t set_color, uint16_t set_blinkduration);
|
||||||
|
void led_loop(void);
|
||||||
|
|
||||||
// defined in configmanager.cpp
|
// defined in configmanager.cpp
|
||||||
void eraseConfig(void);
|
void eraseConfig(void);
|
||||||
@ -35,6 +36,3 @@ void wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type);
|
|||||||
|
|
||||||
// defined in blescan.cpp
|
// defined in blescan.cpp
|
||||||
void bt_loop(void *ignore);
|
void bt_loop(void *ignore);
|
||||||
|
|
||||||
// defined in main.cpp
|
|
||||||
void reset_counters(void);
|
|
@ -33,8 +33,8 @@
|
|||||||
#define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec.
|
#define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec.
|
||||||
|
|
||||||
// LoRa payload send cycle
|
// LoRa payload send cycle
|
||||||
//#define SEND_SECS 120 // [seconds/2] -> 240 sec.
|
#define SEND_SECS 120 // [seconds/2] -> 240 sec.
|
||||||
#define SEND_SECS 30 // [seconds/2] -> 60 sec.
|
//#define SEND_SECS 30 // [seconds/2] -> 60 sec.
|
||||||
|
|
||||||
// Default LoRa Spreadfactor
|
// Default LoRa Spreadfactor
|
||||||
#define LORASFDEFAULT 9 // 7 ... 12 SF, according to LoRaWAN specs
|
#define LORASFDEFAULT 9 // 7 ... 12 SF, according to LoRaWAN specs
|
||||||
|
Loading…
Reference in New Issue
Block a user