minor code sanitizations
This commit is contained in:
parent
6fbc80f93a
commit
3912322c9e
@ -257,7 +257,7 @@ void bt_loop(void * pvParameters)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_bt_controller_mem_release(ESP_BT_MODE_BTDM); // gives 30KB more RAM for heap
|
//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");
|
||||||
|
27
src/main.cpp
27
src/main.cpp
@ -47,14 +47,13 @@ uint8_t DisplayState = 0; // globals for state machine
|
|||||||
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_mem[16]; // display buffers
|
char display_lora[16], display_lmic[16], display_mem[16]; // display buffers
|
||||||
led_states LEDState = 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
|
led_states previousLEDState = LED_ON; // This will force LED to be off at boot since State is OFF
|
||||||
unsigned long LEDBlinkSarted = 0; // When (in millis() led blink started)
|
unsigned long LEDBlinkStarted = 0; // When (in millis() led blink started)
|
||||||
uint16_t LEDBlinkDuration = 0; // How long the blink need to be
|
uint16_t LEDBlinkDuration = 0; // How long the blink need to be
|
||||||
//uint16_t LEDBlinkduration = 0, LEDInterval = 0, color = COLOR_NONE; // state machine variables
|
uint16_t LEDColor = COLOR_NONE; // state machine variable to set RGB LED color
|
||||||
uint16_t LEDColor = COLOR_NONE; // state machine variables
|
|
||||||
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
|
bool blinkdone = true; // flag for state machine for blinking LED once
|
||||||
const uint32_t heapmem = ESP.getFreeHeap(); // free heap memory after start (:= 100%)
|
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)
|
||||||
@ -381,21 +380,21 @@ uint64_t uptime() {
|
|||||||
void blink_LED(uint16_t set_color, uint16_t set_blinkduration) {
|
void blink_LED(uint16_t set_color, uint16_t set_blinkduration) {
|
||||||
LEDColor = set_color; // set color for RGB LED
|
LEDColor = set_color; // set color for RGB LED
|
||||||
LEDBlinkDuration = set_blinkduration; // duration
|
LEDBlinkDuration = set_blinkduration; // duration
|
||||||
LEDBlinkSarted = millis(); // Time Start here
|
LEDBlinkStarted = millis(); // Time Start here
|
||||||
LEDState = LED_ON; // Let main set LED on
|
LEDState = LED_ON; // Let main set LED on
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_loop() {
|
void led_loop() {
|
||||||
// Custom blink running always have priority other LoRaWAN led management
|
// Custom blink running always have priority other LoRaWAN led management
|
||||||
if ( LEDBlinkSarted && LEDBlinkDuration) {
|
if ( LEDBlinkStarted && LEDBlinkDuration) {
|
||||||
|
|
||||||
//ESP_LOGI(TAG, "Start=%ld for %g",LEDBlinkSarted, LEDBlinkDuration );
|
//ESP_LOGI(TAG, "Start=%ld for %g",LEDBlinkStarted, LEDBlinkDuration );
|
||||||
|
|
||||||
// Custom blink is finished, let this order, avoid millis() overflow
|
// Custom blink is finished, let this order, avoid millis() overflow
|
||||||
if ( (millis() - LEDBlinkSarted) >= LEDBlinkDuration) {
|
if ( (millis() - LEDBlinkStarted) >= LEDBlinkDuration) {
|
||||||
// Led besomes off, and stop blink
|
// Led becomes off, and stop blink
|
||||||
LEDState = LED_OFF;
|
LEDState = LED_OFF;
|
||||||
LEDBlinkSarted = 0;
|
LEDBlinkStarted = 0;
|
||||||
LEDBlinkDuration = 0;
|
LEDBlinkDuration = 0;
|
||||||
LEDColor = COLOR_NONE ;
|
LEDColor = COLOR_NONE ;
|
||||||
} else {
|
} else {
|
||||||
@ -574,7 +573,7 @@ xTaskCreatePinnedToCore(sniffer_loop, "wifisniffer", 2048, ( void * ) 1, 1, NULL
|
|||||||
#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", 2048, ( void * ) 1, 1, NULL, 0);
|
xTaskCreatePinnedToCore(bt_loop, "btscan", 4096, ( void * ) 1, 1, NULL, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// 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.21" // use max 10 chars here!
|
#define PROGVERSION "1.3.22" // use max 10 chars here!
|
||||||
#define PROGNAME "PAXCNT"
|
#define PROGNAME "PAXCNT"
|
||||||
|
|
||||||
//--- Declarations ---
|
//--- Declarations ---
|
||||||
@ -13,7 +13,6 @@ enum led_states {
|
|||||||
//--- Prototypes ---
|
//--- Prototypes ---
|
||||||
|
|
||||||
// defined in main.cpp
|
// defined in main.cpp
|
||||||
void reset_counters();
|
|
||||||
void reset_counters(void);
|
void reset_counters(void);
|
||||||
void blink_LED(uint16_t set_color, uint16_t set_blinkduration);
|
void blink_LED(uint16_t set_color, uint16_t set_blinkduration);
|
||||||
void led_loop(void);
|
void led_loop(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user