further fixes for refactoring BLE scan
This commit is contained in:
parent
c57e7b75f4
commit
d4c4f5b532
14
README.md
14
README.md
@ -163,10 +163,7 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
|
|||||||
0 ... 255 duration of a BLE scan cycle in seconds
|
0 ... 255 duration of a BLE scan cycle in seconds
|
||||||
e.g. 15 -> 1 cycle runs for 15 seconds [default]
|
e.g. 15 -> 1 cycle runs for 15 seconds [default]
|
||||||
|
|
||||||
0x0D set BLE scan cycle frequency
|
0x0D (unused)
|
||||||
|
|
||||||
run BLE scan once after 0 ... 255 full wifi scans
|
|
||||||
e.g. 2 -> BLE scan runs once after each 2nd wifi scan [default]
|
|
||||||
|
|
||||||
0x0E set BLE scan mode
|
0x0E set BLE scan mode
|
||||||
|
|
||||||
@ -197,11 +194,10 @@ device answers with it's current configuration. The configuration is a C structu
|
|||||||
byte 9: Wifi scan cycle duration in seconds/2 (0..255)
|
byte 9: Wifi scan cycle duration in seconds/2 (0..255)
|
||||||
byte 10: Wifi channel switch interval in seconds/100 (0..255)
|
byte 10: Wifi channel switch interval in seconds/100 (0..255)
|
||||||
byte 11: BLE scan cycle duration in seconds (0..255)
|
byte 11: BLE scan cycle duration in seconds (0..255)
|
||||||
byte 12: BLE scan frequency, do once after (0..255) full wifi scans
|
byte 12: BLE scan mode (1=on, 0=0ff)
|
||||||
byte 13: BLE scan mode (1=on, 0=0ff)
|
byte 13: Wifi antenna switch (0=internal, 1=external)
|
||||||
byte 14: Wifi antenna switch (0=internal, 1=external)
|
byte 14: RGB LED luminosity (0..100 %)
|
||||||
byte 15: RGB LED luminosity (0..100 %)
|
bytes 15-24: Software version (ASCII format)
|
||||||
bytes 16-25: Software version (ASCII format)
|
|
||||||
|
|
||||||
0x81 get device uptime
|
0x81 get device uptime
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ void defaultConfig() {
|
|||||||
cfg.wifiscancycle = SEND_SECS; // wifi scan cycle [seconds/2]
|
cfg.wifiscancycle = SEND_SECS; // wifi scan cycle [seconds/2]
|
||||||
cfg.wifichancycle = WIFI_CHANNEL_SWITCH_INTERVAL; // wifi channel switch cycle [seconds/100]
|
cfg.wifichancycle = WIFI_CHANNEL_SWITCH_INTERVAL; // wifi channel switch cycle [seconds/100]
|
||||||
cfg.blescantime = BLESCANTIME; // BLE scan cycle duration [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.blescan = 1; // 0=disabled, 1=enabled
|
||||||
cfg.wifiant = 0; // 0=internal, 1=external (for LoPy/LoPy4)
|
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%)
|
||||||
@ -108,9 +107,6 @@ void saveConfig() {
|
|||||||
if( nvs_get_i8(my_handle, "blescantime", &flash8) != ESP_OK || flash8 != cfg.blescantime )
|
if( nvs_get_i8(my_handle, "blescantime", &flash8) != ESP_OK || flash8 != cfg.blescantime )
|
||||||
nvs_set_i8(my_handle, "blescantime", 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);
|
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "blescanmode", &flash8) != ESP_OK || flash8 != cfg.blescan )
|
if( nvs_get_i8(my_handle, "blescanmode", &flash8) != ESP_OK || flash8 != cfg.blescan )
|
||||||
nvs_set_i8(my_handle, "blescanmode", cfg.blescan);
|
nvs_set_i8(my_handle, "blescanmode", cfg.blescan);
|
||||||
|
|
||||||
@ -260,14 +256,6 @@ void loadConfig() {
|
|||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "blescancycle", &flash8) == ESP_OK ) {
|
|
||||||
cfg.blescancycle = flash8;
|
|
||||||
ESP_LOGI(TAG, "blescancycle = %i", flash8);
|
|
||||||
} else {
|
|
||||||
ESP_LOGI(TAG, "BLEscancycle set to default %i", cfg.blescancycle);
|
|
||||||
saveConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( nvs_get_i8(my_handle, "blescanmode", &flash8) == ESP_OK ) {
|
if( nvs_get_i8(my_handle, "blescanmode", &flash8) == ESP_OK ) {
|
||||||
cfg.blescan = flash8;
|
cfg.blescan = flash8;
|
||||||
ESP_LOGI(TAG, "BLEscanmode = %i", flash8);
|
ESP_LOGI(TAG, "BLEscanmode = %i", flash8);
|
||||||
|
@ -33,7 +33,6 @@ typedef struct {
|
|||||||
int8_t wifiscancycle; // wifi scan cycle [seconds/2]
|
int8_t wifiscancycle; // wifi scan cycle [seconds/2]
|
||||||
int8_t wifichancycle; // wifi channel switch cycle [seconds/100]
|
int8_t wifichancycle; // wifi channel switch cycle [seconds/100]
|
||||||
int8_t blescantime; // BLE scan cycle duration [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 blescan; // 0=disabled, 1=enabled
|
||||||
int8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4)
|
int8_t wifiant; // 0=internal, 1=external (for LoPy/LoPy4)
|
||||||
int8_t rgblum; // RGB Led luminosity (0..100%)
|
int8_t rgblum; // RGB Led luminosity (0..100%)
|
||||||
|
24
src/main.cpp
24
src/main.cpp
@ -325,17 +325,7 @@ void sniffer_loop(void * pvParameters) {
|
|||||||
}
|
}
|
||||||
} // end of send data cycle
|
} // end of send data cycle
|
||||||
|
|
||||||
else {
|
} // end of infinite wifi channel rotation loop
|
||||||
/*
|
|
||||||
#ifdef BLECOUNTER
|
|
||||||
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(); // start BLE scan, this is a blocking call
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
} // end of channel rotation loop
|
|
||||||
} // end of infinite wifi scan loop
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* end wifi specific parts ------------------------------------------------------------ */
|
/* end wifi specific parts ------------------------------------------------------------ */
|
||||||
@ -512,8 +502,10 @@ salt_reset(); // get new 16bit for salting hashes
|
|||||||
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(wifi_sniffer_loop, "wifisniffer", 4096, ( void * ) 1, 1, NULL, 0);
|
||||||
#ifdef BLECOUNTER
|
#ifdef BLECOUNTER
|
||||||
ESP_LOGI(TAG, "Starting Bluetooth task on core 0");
|
if (cfg.blescan) { // start BLE task only if BLE function is enabled in NVRAM configuration
|
||||||
xTaskCreatePinnedToCore(bt_loop, "btscan", 2048, NULL, 5, NULL, 0);
|
ESP_LOGI(TAG, "Starting Bluetooth task on core 1");
|
||||||
|
xTaskCreatePinnedToCore(bt_loop, "btscan", 2048, NULL, 5, NULL, 0);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
// to come here: code for switching off core 1
|
// to come here: code for switching off core 1
|
||||||
#else // run wifi task on core 0 and lora task on core 1 and bt task on core 1
|
#else // run wifi task on core 0 and lora task on core 1 and bt task on core 1
|
||||||
@ -522,8 +514,10 @@ salt_reset(); // get new 16bit for salting hashes
|
|||||||
ESP_LOGI(TAG, "Starting Wifi task on core 0");
|
ESP_LOGI(TAG, "Starting Wifi task on core 0");
|
||||||
xTaskCreatePinnedToCore(sniffer_loop, "wifisniffer", 4096, ( void * ) 1, 1, NULL, 0);
|
xTaskCreatePinnedToCore(sniffer_loop, "wifisniffer", 4096, ( void * ) 1, 1, NULL, 0);
|
||||||
#ifdef BLECOUNTER
|
#ifdef BLECOUNTER
|
||||||
ESP_LOGI(TAG, "Starting Bluetooth task on core 1");
|
if (cfg.blescan) { // start BLE task only if BLE function is enabled in NVRAM configuration
|
||||||
xTaskCreatePinnedToCore(bt_loop, "btscan", 2048, NULL, 5, NULL, 1);
|
ESP_LOGI(TAG, "Starting Bluetooth task on core 1");
|
||||||
|
xTaskCreatePinnedToCore(bt_loop, "btscan", 2048, NULL, 5, NULL, 1);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#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.96" // use max 10 chars here!
|
#define PROGVERSION "1.2.97" // use max 10 chars here!
|
||||||
#define PROGNAME "PAXCNT"
|
#define PROGNAME "PAXCNT"
|
||||||
|
|
||||||
// Verbose enables serial output
|
// Verbose enables serial output
|
||||||
|
@ -110,11 +110,6 @@ void set_blescantime(int val) {
|
|||||||
ESP_LOGI(TAG, "Remote command: set BLE scan time to %i seconds", cfg.blescantime);
|
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 BLE scan cycle to %i", cfg.blescancycle);
|
|
||||||
};
|
|
||||||
|
|
||||||
void set_countmode(int val) {
|
void set_countmode(int val) {
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case 0: // cyclic unconfirmed
|
case 0: // cyclic unconfirmed
|
||||||
@ -251,7 +246,7 @@ cmd_t table[] = {
|
|||||||
{0x0a, set_wifiscancycle, true},
|
{0x0a, set_wifiscancycle, true},
|
||||||
{0x0b, set_wifichancycle, true},
|
{0x0b, set_wifichancycle, true},
|
||||||
{0x0c, set_blescantime, true},
|
{0x0c, set_blescantime, true},
|
||||||
{0x0d, set_blescancycle, true},
|
{0x0d, set_noop, false},
|
||||||
{0x0e, set_blescan, true},
|
{0x0e, set_blescan, true},
|
||||||
{0x0f, set_wifiant, true},
|
{0x0f, set_wifiant, true},
|
||||||
{0x10, set_rgblum, true},
|
{0x10, set_rgblum, true},
|
||||||
|
Loading…
Reference in New Issue
Block a user