Skip to content

Commit

Permalink
Merge pull request #51 from cyberman54/development
Browse files Browse the repository at this point in the history
v1.3.22
  • Loading branch information
cyberman54 authored Apr 26, 2018
2 parents 413b5f3 + bf14b06 commit 0dd8137
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 91 deletions.
8 changes: 6 additions & 2 deletions src/blecsan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ void bt_loop(void * pvParameters)
// Initialize BT controller to allocate task and other resource.
ESP_LOGI(TAG, "Enabling Bluetooth Controller");
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)
{
ESP_LOGE(TAG, "Bluetooth controller initialize failed");
Expand All @@ -254,7 +256,9 @@ void bt_loop(void * pvParameters)
ESP_LOGE(TAG, "Bluetooth controller enable failed");
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
ESP_LOGI(TAG, "Init Bluetooth stack");
status = esp_bluedroid_init();
Expand Down Expand Up @@ -282,7 +286,7 @@ void bt_loop(void * pvParameters)

while(1)
{
vTaskDelay(500/portTICK_PERIOD_MS);
vTaskDelay(10/portTICK_PERIOD_MS);
yield();
}

Expand Down
11 changes: 6 additions & 5 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

// std::set for unified array functions
#include <set>
//#include <array>
//#include <algorithm>
#include <array>
#include <algorithm>

// OLED Display
#ifdef HAS_DISPLAY
// OLED Display
#include <U8x8lib.h>
#endif

Expand Down Expand Up @@ -46,13 +46,14 @@ typedef struct {
extern configData_t cfg;
extern uint8_t mydata[];
extern uint64_t uptimecounter;
extern uint32_t currentMillis ;
extern unsigned long currentMillis ;
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 uint16_t macs_total, macs_wifi, macs_ble; // MAC counters
extern bool joinstate;
extern std::set<uint16_t> macs;
extern const uint32_t heapmem;

#ifdef HAS_DISPLAY
extern HAS_DISPLAY u8x8;
Expand Down
24 changes: 16 additions & 8 deletions src/macsniff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
bool added = false;
uint32_t addr2int, vendor2int; // temporary buffer for MAC and Vendor OUI
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
// but since it's uint32 we take 4 bytes to avoid 1st value to be 0
Expand All @@ -50,25 +51,32 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {

// Count only if MAC was not yet seen
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 ) {
macs_wifi++; // increment Wifi MACs counter
if (joinstate)
blink_LED(COLOR_GREEN, 50, 0);
}
#if (HAS_LED != NOT_A_PIN) || defined (HAS_RGB_LED)
blink_LED(COLOR_GREEN, 50);
#endif
}
#ifdef BLECOUNTER
else if (sniff_type == MAC_SNIFF_BLE ) {
macs_ble++; // increment BLE Macs counter
if (joinstate)
blink_LED(COLOR_MAGENTA, 50, 0);
}
#if (HAS_LED != NOT_A_PIN) || defined (HAS_RGB_LED)
blink_LED(COLOR_MAGENTA, 50);
#endif
}
#endif
}

// 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",
rssi, buff, hashedmac, macs_wifi, macs_ble,
added ? "new" : "known");
added ? "new " : "known",
ESP.getFreeHeap());

#ifdef VENDORFILTER
} else {
Expand Down
Loading

0 comments on commit 0dd8137

Please sign in to comment.