Merge pull request #32 from hallard/master

Fixed display bug
This commit is contained in:
Verkehrsrot 2018-04-05 21:16:24 +02:00 committed by GitHub
commit 5763606bee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 111 additions and 133 deletions

View File

@ -81,8 +81,8 @@ Paxcounter generates identifiers for sniffed MAC adresses and collects them temp
FPort1: FPort1:
byte 1: 16-bit Wifi counter, MSB byte 1: 16-bit Total Wifi+BLE counter, MSB
byte 2: 16-bit Wifi counter, LSB byte 2: 16-bit Total Wifi+BLE counter, LSB
byte 3: 16-bit BLE counter, MSB byte 3: 16-bit BLE counter, MSB
byte 4: 16-bit BLE counter, LSB byte 4: 16-bit BLE counter, LSB

View File

@ -37,6 +37,7 @@ build_flags =
-std=c++11 -std=c++11
;override lora settings from LMiC library in lmic/config.h and use main.h instead ;override lora settings from LMiC library in lmic/config.h and use main.h instead
-D_lmic_config_h_ -D_lmic_config_h_
-Dheltec_wifi_lora_32
-include "src/main.h" -include "src/main.h"
-include "src/hal/heltec.h" -include "src/hal/heltec.h"
;FreeRTOS single core operation, switches off core 1 (see arduino-esp32/cores/esp32/main.cpp) ;FreeRTOS single core operation, switches off core 1 (see arduino-esp32/cores/esp32/main.cpp)
@ -47,7 +48,9 @@ platform = espressif32
board = esp32dev board = esp32dev
framework = arduino framework = arduino
monitor_baud = 115200 monitor_baud = 115200
; On my V1, upload does not works over default 115200
upload_speed = 921600 upload_speed = 921600
;upload_port = COM15
lib_deps = lib_deps =
U8g2 U8g2
ESP32 BLE Arduino@>=0.4.9 ESP32 BLE Arduino@>=0.4.9
@ -60,6 +63,7 @@ build_flags =
-fexceptions -fexceptions
-std=c++11 -std=c++11
;override lora settings from LMiC library in lmic/config.h and use main.h instead ;override lora settings from LMiC library in lmic/config.h and use main.h instead
-Dttgov1
-D_lmic_config_h_ -D_lmic_config_h_
-include "src/main.h" -include "src/main.h"
-include "src/hal/ttgov1.h" -include "src/hal/ttgov1.h"
@ -86,6 +90,7 @@ build_flags =
-std=c++11 -std=c++11
;override lora settings from LMiC library in lmic/config.h and use main.h instead ;override lora settings from LMiC library in lmic/config.h and use main.h instead
-D_lmic_config_h_ -D_lmic_config_h_
-Dttgov2
-include "src/main.h" -include "src/main.h"
-include "src/hal/ttgov2.h" -include "src/hal/ttgov2.h"
;FreeRTOS single core operation, switches off core 1 (see arduino-esp32/cores/esp32/main.cpp) ;FreeRTOS single core operation, switches off core 1 (see arduino-esp32/cores/esp32/main.cpp)
@ -110,6 +115,7 @@ build_flags =
-fexceptions -fexceptions
-std=c++11 -std=c++11
;override lora settings from LMiC library in lmic/config.h and use main.h instead ;override lora settings from LMiC library in lmic/config.h and use main.h instead
-Dlopy
-D_lmic_config_h_ -D_lmic_config_h_
-include "src/main.h" -include "src/main.h"
-include "src/hal/lopy.h" -include "src/hal/lopy.h"
@ -136,6 +142,7 @@ build_flags =
-std=c++11 -std=c++11
;override lora settings from LMiC library in lmic/config.h and use main.h instead ;override lora settings from LMiC library in lmic/config.h and use main.h instead
-D_lmic_config_h_ -D_lmic_config_h_
-Dlopy4
-include "src/main.h" -include "src/main.h"
-include "src/hal/lopy4.h" -include "src/hal/lopy4.h"
;FreeRTOS single core operation, switches off core 1 (see arduino-esp32/cores/esp32/main.cpp) ;FreeRTOS single core operation, switches off core 1 (see arduino-esp32/cores/esp32/main.cpp)
@ -161,6 +168,7 @@ build_flags =
-std=c++11 -std=c++11
;override lora settings from LMiC library in lmic/config.h and use main.h instead ;override lora settings from LMiC library in lmic/config.h and use main.h instead
-D_lmic_config_h_ -D_lmic_config_h_
-Dlolin32lite_lora
-include "src/main.h" -include "src/main.h"
-include "src/hal/lolin32lite_lora.h" -include "src/hal/lolin32lite_lora.h"
;FreeRTOS single core operation, switches off core 1 (see arduino-esp32/cores/esp32/main.cpp) ;FreeRTOS single core operation, switches off core 1 (see arduino-esp32/cores/esp32/main.cpp)
@ -186,6 +194,7 @@ build_flags =
-std=c++11 -std=c++11
;override lora settings from LMiC library in lmic/config.h and use main.h instead ;override lora settings from LMiC library in lmic/config.h and use main.h instead
-D_lmic_config_h_ -D_lmic_config_h_
-Dlolin32_lora
-include "src/main.h" -include "src/main.h"
-include "src/hal/lolin32_lora.h" -include "src/hal/lolin32_lora.h"
;FreeRTOS single core operation, switches off core 1 (see arduino-esp32/cores/esp32/main.cpp) ;FreeRTOS single core operation, switches off core 1 (see arduino-esp32/cores/esp32/main.cpp)

View File

@ -1,6 +1,5 @@
/* configmanager persists runtime configuration using NVRAM of ESP32*/ /* configmanager persists runtime configuration using NVRAM of ESP32*/
#include "main.h"
#include "globals.h" #include "globals.h"
#include <nvs.h> #include <nvs.h>
#include <nvs_flash.h> #include <nvs_flash.h>

View File

@ -14,7 +14,15 @@
// Note: Use same format as in TTN console (cut & paste, for your convenience) // Note: Use same format as in TTN console (cut & paste, for your convenience)
// *** Take care : If Using a board with Microchip 24AA02E64 Uinique ID for deveui, ** // *** Take care : If Using a board with Microchip 24AA02E64 Uinique ID for deveui, **
// *** this DEVEUI will be overwriten by the one contained in the Microchip module *** // *** this DEVEUI will be overwriten by the one contained in the Microchip module ***
#if defined (ttgov2)
static const u1_t DEVEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 };
#elif defined (ttgov1)
static const u1_t DEVEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
#elif defined (heltec_wifi_lora_32)
static const u1_t DEVEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32 };
#else
static const u1_t DEVEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const u1_t DEVEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
#endif
// Note: Use msb format for APPEUI as in TTN console (cut & paste, for your convenience) // Note: Use msb format for APPEUI as in TTN console (cut & paste, for your convenience)
// For TTN, APPEUI always starts with 0x70, 0xB3, 0xD5 // For TTN, APPEUI always starts with 0x70, 0xB3, 0xD5

View File

@ -1,5 +1,4 @@
// Basic Config // Basic Config
#include "main.h"
#include "globals.h" #include "globals.h"
// LMIC-Arduino LoRaWAN Stack // LMIC-Arduino LoRaWAN Stack
@ -11,8 +10,6 @@
#include <Wire.h> // Needed for 24AA02E64, does not hurt anything if included and not used #include <Wire.h> // Needed for 24AA02E64, does not hurt anything if included and not used
#endif #endif
uint8_t mydata[] = "0000";
// Local logging Tag // Local logging Tag
static const char *TAG = "lorawan"; static const char *TAG = "lorawan";
@ -114,6 +111,7 @@ void printKeys(void) {
#endif // VERBOSE #endif // VERBOSE
void do_send(osjob_t* j){ void do_send(osjob_t* j){
uint8_t mydata[4];
uint16_t data; uint16_t data;
// Total BLE+WIFI unique MACs seen // Total BLE+WIFI unique MACs seen
data = (uint16_t) macs.size(); data = (uint16_t) macs.size();
@ -132,52 +130,40 @@ void do_send(osjob_t* j){
//mydata[5] = data & 0xff; //mydata[5] = data & 0xff;
// Check if there is not a current TX/RX job running // Check if there is not a current TX/RX job running
u8x8.clearLine(7);
if (LMIC.opmode & OP_TXRXPEND) { if (LMIC.opmode & OP_TXRXPEND) {
ESP_LOGI(TAG, "OP_TXRXPEND, not sending"); ESP_LOGI(TAG, "OP_TXRXPEND, not sending");
u8x8.clearLine(7);
u8x8.drawString(0, 7, "LORA BUSY"); u8x8.drawString(0, 7, "LORA BUSY");
} else { } else {
// Prepare upstream data transmission at the next possible time. // Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, mydata, sizeof(mydata)-1, (cfg.countermode & 0x02)); LMIC_setTxData2(1, mydata, sizeof(mydata), (cfg.countermode & 0x02));
ESP_LOGI(TAG, "Packet queued"); ESP_LOGI(TAG, "Packet queued");
u8x8.clearLine(7);
u8x8.drawString(0, 7, "PACKET QUEUED"); u8x8.drawString(0, 7, "PACKET QUEUED");
} }
// Next TX is scheduled after TX_COMPLETE event. // Next TX is scheduled after TX_COMPLETE event.
} }
void onEvent (ev_t ev) { void onEvent (ev_t ev) {
char buff[24]="";
switch(ev) { switch(ev) {
case EV_SCAN_TIMEOUT: case EV_SCAN_TIMEOUT: strcpy_P(buff, PSTR("SCAN TIMEOUT")); break;
ESP_LOGI(TAG, "EV_SCAN_TIMEOUT"); case EV_BEACON_FOUND: strcpy_P(buff, PSTR("BEACON FOUND")); break;
u8x8.clearLine(7); case EV_BEACON_MISSED: strcpy_P(buff, PSTR( "BEACON MISSED")); break;
u8x8.drawString(0, 7, "SCAN TIMEOUT"); case EV_BEACON_TRACKED: strcpy_P(buff, PSTR("BEACON TRACKED")); break;
break; case EV_JOINING: strcpy_P(buff, PSTR("JOINING")); break;
case EV_BEACON_FOUND: case EV_LOST_TSYNC: strcpy_P(buff, PSTR("LOST TSYNC")); break;
ESP_LOGI(TAG, "EV_BEACON_FOUND"); case EV_RESET: strcpy_P(buff, PSTR("RESET")); break;
u8x8.clearLine(7); case EV_RXCOMPLETE: strcpy_P(buff, PSTR("RX COMPLETE")); break;
u8x8.drawString(0, 7, "BEACON FOUND"); case EV_LINK_DEAD: strcpy_P(buff, PSTR("LINK DEAD")); break;
break; case EV_LINK_ALIVE: strcpy_P(buff, PSTR("LINK ALIVE")); break;
case EV_BEACON_MISSED: case EV_RFU1: strcpy_P(buff, PSTR("RFUI")); break;
ESP_LOGI(TAG, "EV_BEACON_MISSED"); case EV_JOIN_FAILED: strcpy_P(buff, PSTR("JOIN FAILED")); break;
u8x8.clearLine(7); case EV_REJOIN_FAILED: strcpy_P(buff, PSTR("REJOIN FAILED")); break;
u8x8.drawString(0, 7, "BEACON MISSED");
break;
case EV_BEACON_TRACKED:
ESP_LOGI(TAG, "EV_BEACON_TRACKED");
u8x8.clearLine(7);
u8x8.drawString(0, 7, "BEACON TRACKED");
break;
case EV_JOINING:
ESP_LOGI(TAG, "EV_JOINING");
u8x8.clearLine(7);
u8x8.drawString(0, 7, "JOINING");
break;
case EV_JOINED: case EV_JOINED:
ESP_LOGI(TAG, "EV_JOINED"); strcpy_P(buff, PSTR("JOINED"));
u8x8.clearLine(6); // erase "Join Wait" message from display, see main.cpp u8x8.clearLine(6); // erase "Join Wait" message from display, see main.cpp
u8x8.clearLine(7);
u8x8.drawString(0, 7, "JOINED");
// Disable link check validation (automatically enabled // Disable link check validation (automatically enabled
// during join, but not supported by TTN at this time). // during join, but not supported by TTN at this time).
LMIC_setLinkCheckMode(0); LMIC_setLinkCheckMode(0);
@ -189,35 +175,20 @@ void onEvent (ev_t ev) {
// show effective LoRa parameters after join // show effective LoRa parameters after join
ESP_LOGI(TAG, "ADR=%i, SF=%i, TXPOWER=%i", cfg.adrmode, cfg.lorasf, cfg.txpower); ESP_LOGI(TAG, "ADR=%i, SF=%i, TXPOWER=%i", cfg.adrmode, cfg.lorasf, cfg.txpower);
break; break;
case EV_RFU1:
ESP_LOGI(TAG, "EV_RFU1");
u8x8.clearLine(7);
u8x8.drawString(0, 7, "RFUI");
break;
case EV_JOIN_FAILED:
ESP_LOGI(TAG, "EV_JOIN_FAILED");
u8x8.clearLine(7);
u8x8.drawString(0, 7, "JOIN FAILED");
break;
case EV_REJOIN_FAILED:
ESP_LOGI(TAG, "EV_REJOIN_FAILED");
u8x8.clearLine(7);
u8x8.drawString(0, 7, "REJOIN FAILED");
break;
case EV_TXCOMPLETE: case EV_TXCOMPLETE:
ESP_LOGI(TAG, "EV_TXCOMPLETE (includes waiting for RX windows)"); ESP_LOGI(TAG, "EV_TXCOMPLETE (includes waiting for RX windows)");
u8x8.clearLine(7); u8x8.clearLine(7);
u8x8.drawString(0, 7, "TX COMPLETE");
if (LMIC.txrxFlags & TXRX_ACK) { if (LMIC.txrxFlags & TXRX_ACK) {
ESP_LOGI(TAG, "Received ack"); ESP_LOGI(TAG, "Received ack");
u8x8.clearLine(7);
u8x8.drawString(0, 7, "RECEIVED ACK"); u8x8.drawString(0, 7, "RECEIVED ACK");
} else {
u8x8.drawString(0, 7, "TX COMPLETE");
} }
if (LMIC.dataLen) { if (LMIC.dataLen) {
ESP_LOGI(TAG, "Received %i bytes of payload", LMIC.dataLen); ESP_LOGI(TAG, "Received %d bytes of payload", LMIC.dataLen);
u8x8.clearLine(6); u8x8.clearLine(6);
u8x8.setCursor(0, 6); u8x8.setCursor(0, 6);
u8x8.printf("Rcvd %i bytes", LMIC.dataLen); u8x8.printf("Rcvd %d bytes", LMIC.dataLen);
u8x8.clearLine(7); u8x8.clearLine(7);
u8x8.setCursor(0, 7); u8x8.setCursor(0, 7);
// LMIC.snr = SNR twos compliment [dB] * 4 // LMIC.snr = SNR twos compliment [dB] * 4
@ -235,38 +206,16 @@ void onEvent (ev_t ev) {
} }
} }
break; break;
case EV_LOST_TSYNC: default: sprintf_P(buff, PSTR("UNKNOWN EVENT %d"), ev); break;
ESP_LOGI(TAG, "EV_LOST_TSYNC"); }
u8x8.clearLine(7);
u8x8.drawString(0, 7, "LOST TSYNC"); // Log & Display if asked
break; if (*buff) {
case EV_RESET: ESP_LOGI(TAG, "EV_%s", buff);
ESP_LOGI(TAG, "EV_RESET"); u8x8.clearLine(7);
u8x8.clearLine(7); u8x8.drawString(0, 7, buff);
u8x8.drawString(0, 7, "RESET"); }
break;
case EV_RXCOMPLETE:
// data received in ping slot
ESP_LOGI(TAG, "EV_RXCOMPLETE");
u8x8.clearLine(7);
u8x8.drawString(0, 7, "RX COMPLETE");
break;
case EV_LINK_DEAD:
ESP_LOGI(TAG, "EV_LINK_DEAD");
u8x8.clearLine(7);
u8x8.drawString(0, 7, "LINK DEAD");
break;
case EV_LINK_ALIVE:
ESP_LOGI(TAG, "EV_LINK_ALIVE");
u8x8.clearLine(7);
u8x8.drawString(0, 7, "LINK ALIVE");
break;
default:
ESP_LOGI(TAG, "Unknown event");
u8x8.clearLine(7);
u8x8.setCursor(0, 7);
u8x8.printf("UNKNOWN EVENT %d", ev);
break;
}
} }

View File

@ -1,6 +1,5 @@
// Basic Config // Basic Config
#include "main.h"
#include "globals.h" #include "globals.h"
#ifdef BLECOUNTER #ifdef BLECOUNTER
@ -31,15 +30,15 @@ uint16_t salt_reset(void) {
bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) { bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
char buff[32]; // temporary buffer for printf char buff[16]; // temporary buffer for printf
char typebuff[8];
bool added = false; bool added = false;
uint32_t addr2int; uint32_t addr2int;
uint32_t vendor2int; uint32_t vendor2int;
uint16_t hashedmac; uint16_t hashedmac;
// Only last 3 MAC Address bytes are used bay MAC Address Anonymization // Only last 3 MAC Address bytes are used bay MAC Address Anonymization
addr2int = ( (uint32_t)paddr[3] ) | ( (uint32_t)paddr[4] << 8 ) | ( (uint32_t)paddr[5] << 16 ); // but since it's uint32 we take 4 bytes to avoid 1st value to be 0
addr2int = ( (uint32_t)paddr[2] ) | ( (uint32_t)paddr[3] << 8 ) | ( (uint32_t)paddr[4] << 16 ) | ( (uint32_t)paddr[5] << 24 );
#ifdef VENDORFILTER #ifdef VENDORFILTER
vendor2int = ( (uint32_t)paddr[2] ) | ( (uint32_t)paddr[1] << 8 ) | ( (uint32_t)paddr[0] << 16 ); vendor2int = ( (uint32_t)paddr[2] ) | ( (uint32_t)paddr[1] << 8 ) | ( (uint32_t)paddr[0] << 16 );
@ -50,33 +49,31 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
// salt and hash MAC, and if new unique one, store identifier in container and increment counter on display // salt and hash MAC, and if new unique one, store identifier in container and increment counter on display
// https://en.wikipedia.org/wiki/MAC_Address_Anonymization // https://en.wikipedia.org/wiki/MAC_Address_Anonymization
addr2int += (uint32_t) salt << 16; // add 16-bit salt to 24-bit MAC addr2int += (uint32_t) salt; // add 16-bit salt to pseudo MAC
snprintf(buff, sizeof(buff), "%08X", addr2int); // convert unsigned 32-bit salted MAC to 8 digit hex string snprintf(buff, sizeof(buff), "%08X", addr2int); // convert unsigned 32-bit salted MAC to 8 digit hex string
hashedmac = rokkit(buff, 5); // hash MAC string, use 5 chars to fit hash in uint16_t container hashedmac = rokkit(&buff[3], 5); // hash MAC last string value, use 5 chars to fit hash in uint16_t container
auto newmac = macs.insert(hashedmac); // add hashed MAC to total container if new unique auto newmac = macs.insert(hashedmac); // add hashed MAC to total container if new unique
added = newmac.second ? true:false; // true if hashed MAC is unique in container added = newmac.second ? true:false; // true if hashed MAC is unique in container
// Insert only if it was not found on global count
if (added) {
if (sniff_type == MAC_SNIFF_WIFI ) { if (sniff_type == MAC_SNIFF_WIFI ) {
rgb_set_color(COLOR_GREEN); rgb_set_color(COLOR_GREEN);
wifis.insert(hashedmac); // add hashed MAC to wifi container if new unique wifis.insert(hashedmac); // add hashed MAC to wifi container if new unique
strcpy(typebuff, "WiFi");
rgb_set_color(COLOR_NONE);
} else if (sniff_type == MAC_SNIFF_BLE ) { } else if (sniff_type == MAC_SNIFF_BLE ) {
rgb_set_color(COLOR_MAGENTA); rgb_set_color(COLOR_MAGENTA);
bles.insert(hashedmac); // add hashed MAC to BLE container if new unique bles.insert(hashedmac); // add hashed MAC to BLE container if new unique
strcpy(typebuff, "BLE "); }
// Not sure user will have time to see the LED
// TBD do light off further in the code
rgb_set_color(COLOR_NONE); rgb_set_color(COLOR_NONE);
} }
if (added) { // first time seen this WIFI or BLE MAC ESP_LOGI(TAG, "%s RSSI %ddBi -> MAC %s -> Hash %04X -> WiFi:%d BLE:%d %s",
snprintf(buff, sizeof(buff), "PAX:%d", (int) macs.size()); // convert 16-bit MAC counter to decimal counter value sniff_type==MAC_SNIFF_WIFI ? "WiFi":"BLE ",
u8x8.draw2x2String(0, 0, buff); // display number on unique macs total Wifi + BLE rssi, buff, hashedmac,
ESP_LOGI(TAG, "%s RSSI %ddBi -> Hash %04X -> WiFi:%d BLE:%d %s", (int) wifis.size(), (int) bles.size(),
typebuff, rssi, hashedmac, added ? "New" : "Already seen");
(int) wifis.size(), (int) bles.size(), buff );
} else { // already seen WIFI or BLE MAC
ESP_LOGI(TAG, "%s RSSI %ddBi -> Hash %04X -> already seen", typebuff, rssi, hashedmac);
}
#ifdef VENDORFILTER #ifdef VENDORFILTER
} else { } else {
@ -93,11 +90,18 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks { class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
void onResult(BLEAdvertisedDevice advertisedDevice) { void onResult(BLEAdvertisedDevice advertisedDevice) {
int lastcount = (int) macs.size();
uint8_t *p = (uint8_t *) advertisedDevice.getAddress().getNative(); uint8_t *p = (uint8_t *) advertisedDevice.getAddress().getNative();
// Current devices seen on this scan session // Current devices seen on this scan session
currentScanDevice++; currentScanDevice++;
mac_add(p, advertisedDevice.getRSSI(), MAC_SNIFF_BLE); // add this device and refresh display if it was not previously added
if ( mac_add(p, advertisedDevice.getRSSI(), MAC_SNIFF_BLE) ) {
char buff[16];
snprintf(buff, sizeof(buff), "PAX:%d", (int) macs.size()); // convert 16-bit MAC counter to decimal counter value
u8x8.setCursor(0,0);
u8x8.draw2x2String(0, 0, buff); // display number on unique macs total Wifi + BLE
}
u8x8.setCursor(12,3); u8x8.setCursor(12,3);
u8x8.printf("%d", currentScanDevice); u8x8.printf("%d", currentScanDevice);
} }
@ -115,9 +119,6 @@ void BLECount() {
BLEScanResults foundDevices = pBLEScan->start(cfg.blescantime); BLEScanResults foundDevices = pBLEScan->start(cfg.blescantime);
int blenum=foundDevices.getCount(); int blenum=foundDevices.getCount();
ESP_LOGI(TAG, "BLE scan done, seen %d device(s)", blenum); ESP_LOGI(TAG, "BLE scan done, seen %d device(s)", blenum);
u8x8.clearLine(3);
u8x8.setCursor(0,3);
u8x8.printf("BLE#: %-4d %d", (int) bles.size(), currentScanDevice);
} }
#endif #endif

View File

@ -19,6 +19,8 @@ typedef struct {
uint8_t payload[0]; /* network data ended with 4 bytes csum (CRC32) */ uint8_t payload[0]; /* network data ended with 4 bytes csum (CRC32) */
} wifi_ieee80211_packet_t; } wifi_ieee80211_packet_t;
extern uint16_t currentScanDevice;
uint16_t salt_reset(void); uint16_t salt_reset(void);
void BLECount(); void BLECount();
void wifi_sniffer_init(void); void wifi_sniffer_init(void);

View File

@ -22,7 +22,6 @@ Refer to LICENSE.txt file in repository for more details.
*/ */
// Basic Config // Basic Config
#include "main.h"
#include "globals.h" #include "globals.h"
// std::set for unified array functions // std::set for unified array functions
@ -254,11 +253,12 @@ void wifi_sniffer_init(void);
void wifi_sniffer_set_channel(uint8_t channel); void wifi_sniffer_set_channel(uint8_t channel);
void wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type); void wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type);
//WiFi Sniffer Task // Sniffer Task
void wifi_sniffer_loop(void * pvParameters) { void sniffer_loop(void * pvParameters) {
configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check configASSERT( ( ( uint32_t ) pvParameters ) == 1 ); // FreeRTOS check
uint8_t channel=0; uint8_t channel=0;
char buff[16];
int nloop=0, lorawait=0; int nloop=0, lorawait=0;
while (true) { while (true) {
@ -270,12 +270,23 @@ void wifi_sniffer_loop(void * pvParameters) {
channel = (channel % WIFI_CHANNEL_MAX) + 1; // rotates variable channel 1..WIFI_CHANNEL_MAX channel = (channel % WIFI_CHANNEL_MAX) + 1; // rotates variable channel 1..WIFI_CHANNEL_MAX
wifi_sniffer_set_channel(channel); wifi_sniffer_set_channel(channel);
ESP_LOGI(TAG, "Wifi set channel %d", channel); ESP_LOGI(TAG, "Wifi set channel %d", channel);
u8x8.setCursor(0,5);
u8x8.printf(!cfg.rssilimit ? "RLIM: off" : "RLIM: %d", cfg.rssilimit); snprintf(buff, sizeof(buff), "PAX:%d", (int) macs.size()); // convert 16-bit MAC counter to decimal counter value
u8x8.setCursor(11,5); u8x8.setCursor(0,0);
u8x8.printf("ch:%02i", channel); u8x8.draw2x2String(0, 0, buff); // display number on unique macs total Wifi + BLE
u8x8.clearLine(3);
u8x8.setCursor(0,3);
// We just state out of BLE scanning
if (currentScanDevice) {
u8x8.printf("BLE#: %-4d %d", (int) bles.size(), currentScanDevice);
} else {
u8x8.printf("BLE#: %-4d", (int) bles.size());
}
u8x8.setCursor(0,4); u8x8.setCursor(0,4);
u8x8.printf("MAC#: %-5d", (int) wifis.size()); u8x8.printf("MAC#: %-5d", (int) wifis.size());
u8x8.setCursor(0,5);
u8x8.printf(!cfg.rssilimit ? "RLIM: off" : "RLIM: %-3d", cfg.rssilimit);
u8x8.printf(" ch:%02i", channel);
// duration of one wifi scan loop reached? then send data and begin new scan cycle // duration of one wifi scan loop reached? then send data and begin new scan cycle
if( nloop >= ( (100 / cfg.wifichancycle) * (cfg.wifiscancycle * 2)) +1 ) { if( nloop >= ( (100 / cfg.wifichancycle) * (cfg.wifiscancycle * 2)) +1 ) {
@ -358,7 +369,6 @@ void init_display(const char *Productname, const char *Version) {
u8x8.begin(); u8x8.begin();
u8x8.setFont(u8x8_font_chroma48medium8_r); u8x8.setFont(u8x8_font_chroma48medium8_r);
#ifdef HAS_DISPLAY #ifdef HAS_DISPLAY
Wire.setClock(100000); // experimental: reduce I2C bus speed to avoid display errors (must be done after begin)
uint8_t buf[32]; uint8_t buf[32];
u8x8.clear(); u8x8.clear();
u8x8.setFlipMode(0); u8x8.setFlipMode(0);
@ -503,7 +513,7 @@ salt_reset(); // get new 16bit for salting hashes
ESP_LOGI(TAG, "Starting Lora task on core 1"); 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(wifi_sniffer_loop, "wifisniffer", 4096, ( void * ) 1, 1, NULL, 0); xTaskCreatePinnedToCore(sniffer_loop, "wifisniffer", 4096, ( void * ) 1, 1, NULL, 0);
#endif #endif
// Finally: kickoff first sendjob and join, then send initial payload "0000" // Finally: kickoff first sendjob and join, then send initial payload "0000"

View File

@ -1,5 +1,7 @@
#pragma once
// 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.2.93" // use max 10 chars here! #define PROGVERSION "1.2.94" // use max 10 chars here!
#define PROGNAME "PAXCNT" #define PROGNAME "PAXCNT"
// Verbose enables serial output // Verbose enables serial output

View File

@ -3,7 +3,6 @@
// checks commands and executes each command with 1 argument per command // checks commands and executes each command with 1 argument per command
// Basic Config // Basic Config
#include "main.h"
#include "globals.h" #include "globals.h"
// LMIC-Arduino LoRaWAN Stack // LMIC-Arduino LoRaWAN Stack

View File

@ -1,5 +1,4 @@
// Basic Config // Basic Config
#include "main.h"
#include "globals.h" #include "globals.h"
#ifdef HAS_RGB_LED #ifdef HAS_RGB_LED