memory display & reduced task stack sizes & reduced bt loop pause
This commit is contained in:
parent
e9da68885e
commit
244eb10c29
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,11 +48,12 @@ extern uint8_t mydata[];
|
|||||||
extern uint64_t uptimecounter;
|
extern uint64_t uptimecounter;
|
||||||
extern uint32_t currentMillis ;
|
extern uint32_t 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
|
||||||
|
uint16_t 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
|
||||||
@ -64,11 +65,16 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Display heap memory left
|
||||||
|
memlevel = 1 - (ESP.getFreeHeap() / heapmem);
|
||||||
|
sprintf(display_mem, "%d.1%%", memlevel);
|
||||||
|
|
||||||
// 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 {
|
||||||
|
16
src/main.cpp
16
src/main.cpp
@ -47,9 +47,10 @@ uint8_t DisplayState = 0; // globals for state machine
|
|||||||
uint16_t LEDBlinkduration = 0, LEDInterval = 0, color = COLOR_NONE; // state machine variables
|
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
|
enum states LEDState = LED_OFF, previousLEDState = LED_OFF; // LED state global for state machine
|
||||||
bool joinstate = false; // LoRa network joined? global flag
|
bool joinstate = false; // LoRa network joined? global flag
|
||||||
|
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)
|
||||||
|
|
||||||
@ -310,7 +311,7 @@ uint64_t uptime() {
|
|||||||
esp_chip_info_t chip_info;
|
esp_chip_info_t chip_info;
|
||||||
esp_chip_info(&chip_info);
|
esp_chip_info(&chip_info);
|
||||||
u8x8.printf("ESP32 %d cores\nWiFi%s%s\n",
|
u8x8.printf("ESP32 %d cores\nWiFi%s%s\n",
|
||||||
chip_info.cores,
|
chip_info.cores,
|
||||||
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
|
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
|
||||||
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
|
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
|
||||||
u8x8.printf("ESP Rev.%d\n", chip_info.revision);
|
u8x8.printf("ESP Rev.%d\n", chip_info.revision);
|
||||||
@ -344,6 +345,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);
|
||||||
@ -500,6 +505,7 @@ 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
|
||||||
|
|
||||||
@ -521,12 +527,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", 2048, ( void * ) 1, 1, NULL, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -547,7 +553,7 @@ 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
|
#ifdef HAS_LED
|
||||||
switchLEDstate();
|
switchLEDstate();
|
||||||
|
Loading…
Reference in New Issue
Block a user