v1.2.83: BLE scan frequency made remote configurable

This commit is contained in:
Klaus K Wilting committed 2018-04-02 21:26:22 +02:00
1 parent da9ea6a35d
commit 7eef5a846e
7 files changed
+46 -21

No files matched your search

+16 -4
View File
@@ -28,10 +28,11 @@ void defaultConfig() {
cfg.rssilimit = 0; // threshold for rssilimiter, negative value!
cfg.wifiscancycle = SEND_SECS; // wifi scan cycle [seconds/2]
cfg.wifichancycle = WIFI_CHANNEL_SWITCH_INTERVAL; // wifi channel switch cycle [seconds/100]
cfg.blescancycle = BLESCANTIME; // BLE scan cycle [seconds]
cfg.blescantime = BLESCANTIME; // BLE scan cycle duration [seconds]
cfg.blescancycle = BLESCANCYCLE; // do a BLE scan after [BLESCANCYCLE] full Wifi scan cycles
cfg.blescan = 1; // 0=disabled, 1=enabled
cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0 100%)
cfg.rgblum = RGBLUMINOSITY; // RGB Led luminosity (0..100%)
strncpy( cfg.version, PROGVERSION, sizeof(cfg.version)-1 );
}
@@ -105,8 +106,11 @@ void saveConfig() {
if( nvs_get_i8(my_handle, "wifichancycle", &flash8) != ESP_OK || flash8 != cfg.wifichancycle )
nvs_set_i8(my_handle, "wifichancycle", cfg.wifichancycle);
if( nvs_get_i8(my_handle, "blescantime", &flash8) != ESP_OK || flash8 != cfg.blescantime )
nvs_set_i8(my_handle, "blescantime", cfg.blescantime);
if( nvs_get_i8(my_handle, "blescancycle", &flash8) != ESP_OK || flash8 != cfg.blescancycle )
nvs_set_i8(my_handle, "blescancycle", cfg.blescancycle);
nvs_set_i8(my_handle, "blescantime", cfg.blescancycle);
if( nvs_get_i8(my_handle, "blescanmode", &flash8) != ESP_OK || flash8 != cfg.blescan )
nvs_set_i8(my_handle, "blescanmode", cfg.blescan);
@@ -249,11 +253,19 @@ void loadConfig() {
saveConfig();
}
if( nvs_get_i8(my_handle, "blescantime", &flash8) == ESP_OK ) {
cfg.blescantime = flash8;
ESP_LOGI(TAG, "blescantime = %i", flash8);
} else {
ESP_LOGI(TAG, "BLEscantime set to default %i", cfg.blescantime);
saveConfig();
}
if( nvs_get_i8(my_handle, "blescancycle", &flash8) == ESP_OK ) {
cfg.blescancycle = flash8;
ESP_LOGI(TAG, "blescancycle = %i", flash8);
} else {
ESP_LOGI(TAG, "BLEscan cycle set to default %i", cfg.blescancycle);
ESP_LOGI(TAG, "BLEscancycle set to default %i", cfg.blescancycle);
saveConfig();
}
+2 -1
View File
@@ -30,7 +30,8 @@ typedef struct {
int16_t rssilimit; // threshold for rssilimiter, negative value!
int8_t wifiscancycle; // wifi scan cycle [seconds/2]
int8_t wifichancycle; // wifi channel switch cycle [seconds/100]
int8_t blescancycle; // BLE scan cycle [seconds]
int8_t blescantime; // BLE scan cycle duration [seconds]
int8_t blescancycle; // BLE scan frequency, once after [blescancycle] full wifi scans
int8_t blescan; // 0=disabled, 1=enabled
int8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4)
int8_t rgblum; // RGB Led luminosity (0 100%)
+1 -1
View File
@@ -100,7 +100,7 @@ void BLECount() {
BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
BLEScanResults foundDevices = pBLEScan->start(cfg.blescancycle);
BLEScanResults foundDevices = pBLEScan->start(cfg.blescantime);
blenum=foundDevices.getCount();
u8x8.clearLine(3);
u8x8.setCursor(0,3);
+1 -1
View File
@@ -309,7 +309,7 @@ void wifi_sniffer_loop(void * pvParameters) {
} // end of send data cycle
else {
#ifdef BLECOUNTER // execute BLE count if BLE function is enabled
if (nloop % (WIFI_CHANNEL_MAX * BLESCANCYCLE) == 0 ) { // once after BLESCANCYCLE Wifi scans, do a BLE scan
if (nloop % (WIFI_CHANNEL_MAX * cfg.blescancycle) == 0 ) { // once after cfg.blescancycle Wifi scans, do a BLE scan
if (cfg.blescan) // execute BLE count if BLE function is enabled
BLECount();
}
+1 -1
View File
@@ -1,5 +1,5 @@
// program version
#define PROGVERSION "1.2.81" // use max 10 chars here!
#define PROGVERSION "1.2.83" // use max 10 chars here!
#define PROGNAME "PAXCNT"
// Verbose enables serial output
+12 -6
View File
@@ -104,10 +104,15 @@ void set_wifichancycle(int val) {
ESP_LOGI(TAG, "Remote command: set Wifi channel switch interval to %i seconds", cfg.wifichancycle/100);
};
void set_blescantime(int val) {
cfg.blescantime = val;
ESP_LOGI(TAG, "Remote command: set BLE scan time to %i seconds", cfg.blescantime);
};
void set_blescancycle(int val) {
cfg.blescancycle = val;
ESP_LOGI(TAG, "Remote command: set Wifi channel cycle duration to %i seconds", cfg.blescancycle);
};
ESP_LOGI(TAG, "Remote command: set BLE scan cycle to %i", cfg.blescancycle);
};
void set_countmode(int val) {
switch (val) {
@@ -244,10 +249,11 @@ cmd_t table[] = {
{0x09, set_reset, false},
{0x0a, set_wifiscancycle, true},
{0x0b, set_wifichancycle, true},
{0x0c, set_blescancycle, true},
{0x0d, set_blescan, true},
{0x0e, set_wifiant, true},
{0x0f, set_rgblum, true},
{0x0c, set_blescantime, true},
{0x0d, set_blescancycle, true},
{0x0e, set_blescan, true},
{0x0f, set_wifiant, true},
{0x10, set_rgblum, true},
{0x80, get_config, false},
{0x81, get_uptime, false},
{0x82, get_cputemp, false}