change default to bluetooth disabled
This commit is contained in:
1 parent
8d22695114
commit
decb8b7181
18 files changed
+163
-49
No files matched your search
@@ -4,9 +4,16 @@
|
||||
function Converter(decoded, port) {
|
||||
|
||||
var converted = decoded;
|
||||
var pax = 0;
|
||||
|
||||
if (port === 1) {
|
||||
converted.pax = converted.ble + converted.wifi;
|
||||
|
||||
for (var x in converted) {
|
||||
pax += converted[x];
|
||||
}
|
||||
|
||||
converted.pax = pax;
|
||||
|
||||
}
|
||||
|
||||
if (port === 2) {
|
||||
|
||||
@@ -6,7 +6,11 @@ function Decoder(bytes, port) {
|
||||
var decoded = {};
|
||||
|
||||
if (port === 1) {
|
||||
// only counter data, no gps
|
||||
// only wifi counter data, no gps
|
||||
if (bytes.length === 2) {
|
||||
return decode(bytes, [uint16], ['wifi']);
|
||||
}
|
||||
// wifi + ble counter data, no gps
|
||||
if (bytes.length === 4) {
|
||||
return decode(bytes, [uint16, uint16], ['wifi', 'ble']);
|
||||
}
|
||||
|
||||
@@ -7,8 +7,11 @@ function Decoder(bytes, port) {
|
||||
if (port === 1) {
|
||||
var i = 0;
|
||||
|
||||
decoded.wifi = (bytes[i++] << 8) | bytes[i++];
|
||||
decoded.ble = (bytes[i++] << 8) | bytes[i++];
|
||||
if (bytes.length >= 2) {
|
||||
decoded.wifi = (bytes[i++] << 8) | bytes[i++];}
|
||||
|
||||
if (bytes.length >= 4) {
|
||||
decoded.ble = (bytes[i++] << 8) | bytes[i++];}
|
||||
|
||||
if (bytes.length > 4) {
|
||||
decoded.latitude = ((bytes[i++] << 24) | (bytes[i++] << 16) | (bytes[i++] << 8) | bytes[i++]);
|
||||
|
||||
+6
-2
@@ -243,7 +243,10 @@ esp_err_t register_ble_callback(void) {
|
||||
|
||||
} // register_ble_callback
|
||||
|
||||
#endif // BLECOUNTER
|
||||
|
||||
void start_BLEscan(void) {
|
||||
#ifdef BLECOUNTER
|
||||
ESP_LOGI(TAG, "Initializing bluetooth scanner ...");
|
||||
|
||||
// Initialize BT controller to allocate task and other resource.
|
||||
@@ -255,15 +258,16 @@ void start_BLEscan(void) {
|
||||
ESP_ERROR_CHECK(register_ble_callback());
|
||||
|
||||
ESP_LOGI(TAG, "Bluetooth scanner started");
|
||||
#endif // BLECOUNTER
|
||||
} // start_BLEscan
|
||||
|
||||
void stop_BLEscan(void) {
|
||||
#ifdef BLECOUNTER
|
||||
ESP_LOGI(TAG, "Shutting down bluetooth scanner ...");
|
||||
ESP_ERROR_CHECK(esp_ble_gap_register_callback(NULL));
|
||||
ESP_ERROR_CHECK(esp_bluedroid_disable());
|
||||
ESP_ERROR_CHECK(esp_bluedroid_deinit());
|
||||
btStop(); // disable & deinit bt_controller
|
||||
ESP_LOGI(TAG, "Bluetooth scanner stopped");
|
||||
} // stop_BLEscan
|
||||
|
||||
#endif // BLECOUNTER
|
||||
} // stop_BLEscan
|
||||
@@ -25,7 +25,7 @@ void defaultConfig() {
|
||||
cfg.blescantime =
|
||||
BLESCANINTERVAL /
|
||||
10; // BT channel scan cycle [seconds/100], default 1 (= 10ms)
|
||||
cfg.blescan = 1; // 0=disabled, 1=enabled
|
||||
cfg.blescan = 0; // 0=disabled, 1=enabled
|
||||
cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
|
||||
cfg.vendorfilter = 1; // 0=disabled, 1=enabled
|
||||
cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)
|
||||
|
||||
@@ -106,6 +106,7 @@ void setup() {
|
||||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded"
|
||||
: "external");
|
||||
ESP_LOGI(TAG, "ESP32 SDK: %s", ESP.getSdkVersion());
|
||||
ESP_LOGI(TAG, "Wifi/BT software coexist version: %s", esp_coex_version_get());
|
||||
ESP_LOGI(TAG, "Free RAM: %d bytes", ESP.getFreeHeap());
|
||||
|
||||
#ifdef HAS_GPS
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@
|
||||
|
||||
// Set this to include BLE counting and vendor filter functions
|
||||
#define VENDORFILTER 1 // comment out if you want to count things, not people
|
||||
#define BLECOUNTER 1 // comment out if you don't want BLE count, saves power & memory
|
||||
//#define BLECOUNTER 1 // activate if you want BLE count, at expense of power & memory
|
||||
|
||||
// BLE scan parameters
|
||||
#define BLESCANTIME 0 // [seconds] scan duration, 0 means infinite [default], see note below
|
||||
@@ -74,7 +74,7 @@
|
||||
#define BME_TEMP_OFFSET 5.0f // Offset sensor on chip temp <-> ambient temp [default = 5°C]
|
||||
|
||||
// OTA settings
|
||||
//#define USE_OTA 1 // Comment out to disable OTA update
|
||||
#define USE_OTA 1 // Comment out to disable OTA update
|
||||
#define WIFI_MAX_TRY 5 // maximum number of wifi connect attempts for OTA update [default = 20]
|
||||
#define OTA_MAX_TRY 5 // maximum number of attempts for OTA download and write to flash [default = 3]
|
||||
#define OTA_MIN_BATT 3600 // minimum battery level for OTA [millivolt]
|
||||
|
||||
+22
-21
@@ -18,11 +18,9 @@ uint8_t *PayloadConvert::getBuffer(void) { return buffer; }
|
||||
|
||||
#if PAYLOAD_ENCODER == 1
|
||||
|
||||
void PayloadConvert::addCount(uint16_t value1, uint16_t value2) {
|
||||
buffer[cursor++] = highByte(value1);
|
||||
buffer[cursor++] = lowByte(value1);
|
||||
buffer[cursor++] = highByte(value2);
|
||||
buffer[cursor++] = lowByte(value2);
|
||||
void PayloadConvert::addCount(uint16_t value, uint8_t snifftype) {
|
||||
buffer[cursor++] = highByte(value);
|
||||
buffer[cursor++] = lowByte(value);
|
||||
}
|
||||
|
||||
void PayloadConvert::addAlarm(int8_t rssi, uint8_t msg) {
|
||||
@@ -135,10 +133,7 @@ void PayloadConvert::addButton(uint8_t value) {
|
||||
|
||||
#elif PAYLOAD_ENCODER == 2
|
||||
|
||||
void PayloadConvert::addCount(uint16_t value1, uint16_t value2) {
|
||||
writeUint16(value1);
|
||||
writeUint16(value2);
|
||||
}
|
||||
void PayloadConvert::addCount(uint16_t value, uint8_t snifftype) { writeUint16(value); }
|
||||
|
||||
void PayloadConvert::addAlarm(int8_t rssi, uint8_t msg) {
|
||||
writeUint8(rssi);
|
||||
@@ -286,21 +281,27 @@ void PayloadConvert::writeBitmap(bool a, bool b, bool c, bool d, bool e, bool f,
|
||||
|
||||
#elif (PAYLOAD_ENCODER == 3 || PAYLOAD_ENCODER == 4)
|
||||
|
||||
void PayloadConvert::addCount(uint16_t value1, uint16_t value2) {
|
||||
void PayloadConvert::addCount(uint16_t value, uint8_t snifftype) {
|
||||
select(snifftype) {
|
||||
case MAC_SNIFF_WIFI:
|
||||
#if (PAYLOAD_ENCODER == 3)
|
||||
buffer[cursor++] = LPP_COUNT_WIFI_CHANNEL;
|
||||
buffer[cursor++] = LPP_COUNT_WIFI_CHANNEL;
|
||||
#endif
|
||||
buffer[cursor++] =
|
||||
LPP_LUMINOSITY; // workaround since cayenne has no data type meter
|
||||
buffer[cursor++] = highByte(value1);
|
||||
buffer[cursor++] = lowByte(value1);
|
||||
buffer[cursor++] =
|
||||
LPP_LUMINOSITY; // workaround since cayenne has no data type meter
|
||||
buffer[cursor++] = highByte(value);
|
||||
buffer[cursor++] = lowByte(value);
|
||||
break;
|
||||
case MAC_SNIFF_BLE:
|
||||
#if (PAYLOAD_ENCODER == 3)
|
||||
buffer[cursor++] = LPP_COUNT_BLE_CHANNEL;
|
||||
buffer[cursor++] = LPP_COUNT_BLE_CHANNEL;
|
||||
#endif
|
||||
buffer[cursor++] =
|
||||
LPP_LUMINOSITY; // workaround since cayenne has no data type meter
|
||||
buffer[cursor++] = highByte(value2);
|
||||
buffer[cursor++] = lowByte(value2);
|
||||
buffer[cursor++] =
|
||||
LPP_LUMINOSITY; // workaround since cayenne has no data type meter
|
||||
buffer[cursor++] = highByte(value);
|
||||
buffer[cursor++] = lowByte(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PayloadConvert::addAlarm(int8_t rssi, uint8_t msg) {
|
||||
@@ -317,7 +318,7 @@ void PayloadConvert::addAlarm(int8_t rssi, uint8_t msg) {
|
||||
}
|
||||
|
||||
void PayloadConvert::addVoltage(uint16_t value) {
|
||||
uint16_t volt = value / 10;
|
||||
uint16_t volt = value / 10;
|
||||
#if (PAYLOAD_ENCODER == 3)
|
||||
buffer[cursor++] = LPP_BATT_CHANNEL;
|
||||
#endif
|
||||
|
||||
@@ -79,13 +79,11 @@ void set_blescantime(uint8_t val[]) {
|
||||
cfg.blescantime = val[0];
|
||||
ESP_LOGI(TAG, "Remote command: set BLE scan time to %.1f seconds",
|
||||
cfg.blescantime / float(100));
|
||||
#ifdef BLECOUNTER
|
||||
// stop & restart BLE scan task to apply new parameter
|
||||
if (cfg.blescan) {
|
||||
stop_BLEscan();
|
||||
start_BLEscan();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void set_countmode(uint8_t val[]) {
|
||||
@@ -193,14 +191,12 @@ void set_loraadr(uint8_t val[]) {
|
||||
void set_blescan(uint8_t val[]) {
|
||||
ESP_LOGI(TAG, "Remote command: set BLE scanner to %s", val[0] ? "on" : "off");
|
||||
cfg.blescan = val[0] ? 1 : 0;
|
||||
#ifdef BLECOUNTER
|
||||
if (cfg.blescan)
|
||||
start_BLEscan();
|
||||
else {
|
||||
macs_ble = 0; // clear BLE counter
|
||||
stop_BLEscan();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void set_wifiant(uint8_t val[]) {
|
||||
|
||||
+3
-1
@@ -40,7 +40,9 @@ void sendCounter() {
|
||||
|
||||
case COUNT_DATA:
|
||||
payload.reset();
|
||||
payload.addCount(macs_wifi, cfg.blescan ? macs_ble : 0);
|
||||
payload.addCount(macs_wifi, MAC_SNIFF_WIFI);
|
||||
if (cfg.blescan)
|
||||
payload.addCount(macs_ble, MAC_SNIFF_BLE);
|
||||
SendPayload(COUNTERPORT);
|
||||
// clear counter if not in cumulative counter mode
|
||||
if (cfg.countermode != 1) {
|
||||
|
||||
+18
-1
@@ -1,6 +1,8 @@
|
||||
// Basic Config
|
||||
#include "globals.h"
|
||||
#include "wifiscan.h"
|
||||
#include <esp_coexist.h>
|
||||
#include "coexist_internal.h"
|
||||
|
||||
// Local logging tag
|
||||
static const char TAG[] = "wifi";
|
||||
@@ -9,6 +11,8 @@ static wifi_country_t wifi_country = {WIFI_MY_COUNTRY, WIFI_CHANNEL_MIN,
|
||||
WIFI_CHANNEL_MAX, 100,
|
||||
WIFI_COUNTRY_POLICY_MANUAL};
|
||||
|
||||
esp_coex_prefer_t coexist_config = ESP_COEX_PREFER_BALANCE;
|
||||
|
||||
typedef struct {
|
||||
unsigned frame_ctrl : 16;
|
||||
unsigned duration_id : 16;
|
||||
@@ -27,7 +31,7 @@ typedef struct {
|
||||
// using IRAM_:ATTR here to speed up callback function
|
||||
IRAM_ATTR void wifi_sniffer_packet_handler(void *buff,
|
||||
wifi_promiscuous_pkt_type_t type) {
|
||||
|
||||
|
||||
const wifi_promiscuous_pkt_t *ppkt = (wifi_promiscuous_pkt_t *)buff;
|
||||
const wifi_ieee80211_packet_t *ipkt =
|
||||
(wifi_ieee80211_packet_t *)ppkt->payload;
|
||||
@@ -41,6 +45,12 @@ IRAM_ATTR void wifi_sniffer_packet_handler(void *buff,
|
||||
mac_add((uint8_t *)hdr->addr2, ppkt->rx_ctrl.rssi, MAC_SNIFF_WIFI);
|
||||
}
|
||||
|
||||
const char *esp_coex_version_get(void) { return coex_version_get(); }
|
||||
|
||||
esp_err_t esp_coex_preference_set(esp_coex_prefer_t prefer) {
|
||||
return coex_preference_set((coex_prefer_t)prefer);
|
||||
}
|
||||
|
||||
void wifi_sniffer_init(void) {
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
cfg.nvs_enable = 0; // we don't need any wifi settings from NVRAM
|
||||
@@ -49,6 +59,13 @@ void wifi_sniffer_init(void) {
|
||||
// .filter_mask = WIFI_PROMIS_FILTER_MASK_MGMT}; // only MGMT frames
|
||||
.filter_mask = WIFI_PROMIS_FILTER_MASK_ALL}; // we use all frames
|
||||
|
||||
coex_pause();
|
||||
ESP_ERROR_CHECK(
|
||||
esp_coex_preference_set(coexist_config)); // configure Wifi/BT coexist lib
|
||||
coex_resume();
|
||||
|
||||
//coex_deinit();
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg)); // configure Wifi with cfg
|
||||
ESP_ERROR_CHECK(
|
||||
esp_wifi_set_country(&wifi_country)); // set locales for RF and channels
|
||||
|
||||
Reference in new issue
Block a user