v1.2.83: BLE scan frequency made remote configurable
This commit is contained in:
parent
da9ea6a35d
commit
7eef5a846e
20
README.md
20
README.md
@ -155,17 +155,22 @@ 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. 30 -> 1 cycle runs for 30 seconds
|
e.g. 30 -> 1 cycle runs for 30 seconds
|
||||||
|
|
||||||
0x0D set BLE scan mode
|
0x0D set BLE scan cycle frequency
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
0 = disabled [default]
|
0 = disabled [default]
|
||||||
1 = enabled
|
1 = enabled
|
||||||
|
|
||||||
0x0E set WIFI antenna switch (works on LoPy/LoPy4 only)
|
0x0F set WIFI antenna switch (works on LoPy/LoPy4 only)
|
||||||
|
|
||||||
0 = internal antenna [default]
|
0 = internal antenna [default]
|
||||||
1 = external antenna
|
1 = external antenna
|
||||||
|
|
||||||
0x0F set RGB led luminosity (works on LoPy/LoPy4 and LoRaNode32 shield only)
|
0x10 set RGB led luminosity (works on LoPy/LoPy4 and LoRaNode32 shield only)
|
||||||
|
|
||||||
0 ... 100 percentage of luminosity (100% = full light)
|
0 ... 100 percentage of luminosity (100% = full light)
|
||||||
e.g. 40 -> 40% of luminosity
|
e.g. 40 -> 40% of luminosity
|
||||||
@ -184,10 +189,11 @@ Note: all settings are stored in NVRAM and will be reloaded when device starts.
|
|||||||
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 mode (1=on, 0=0ff)
|
byte 12: BLE scan frequency, do once after (0..255) full wifi scans
|
||||||
byte 13: Wifi antenna switch (0=internal, 1=external)
|
byte 13: BLE scan mode (1=on, 0=0ff)
|
||||||
byte 14: RGB LED luminosity (0..100 %)
|
byte 14: Wifi antenna switch (0=internal, 1=external)
|
||||||
bytes 15-24: Software version (ASCII format)
|
byte 15: RGB LED luminosity (0..100 %)
|
||||||
|
bytes 16-25: Software version (ASCII format)
|
||||||
|
|
||||||
0x81 get device uptime
|
0x81 get device uptime
|
||||||
|
|
||||||
|
@ -28,10 +28,11 @@ void defaultConfig() {
|
|||||||
cfg.rssilimit = 0; // threshold for rssilimiter, negative value!
|
cfg.rssilimit = 0; // threshold for rssilimiter, negative value!
|
||||||
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.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.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%)
|
||||||
|
|
||||||
strncpy( cfg.version, PROGVERSION, sizeof(cfg.version)-1 );
|
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 )
|
if( nvs_get_i8(my_handle, "wifichancycle", &flash8) != ESP_OK || flash8 != cfg.wifichancycle )
|
||||||
nvs_set_i8(my_handle, "wifichancycle", 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 )
|
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 )
|
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);
|
||||||
@ -249,6 +253,14 @@ void loadConfig() {
|
|||||||
saveConfig();
|
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 ) {
|
if( nvs_get_i8(my_handle, "blescancycle", &flash8) == ESP_OK ) {
|
||||||
cfg.blescancycle = flash8;
|
cfg.blescancycle = flash8;
|
||||||
ESP_LOGI(TAG, "blescancycle = %i", flash8);
|
ESP_LOGI(TAG, "blescancycle = %i", flash8);
|
||||||
|
@ -30,7 +30,8 @@ typedef struct {
|
|||||||
int16_t rssilimit; // threshold for rssilimiter, negative value!
|
int16_t rssilimit; // threshold for rssilimiter, negative value!
|
||||||
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 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 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%)
|
||||||
|
@ -100,7 +100,7 @@ void BLECount() {
|
|||||||
BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan
|
BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan
|
||||||
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
|
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
|
||||||
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
|
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();
|
blenum=foundDevices.getCount();
|
||||||
u8x8.clearLine(3);
|
u8x8.clearLine(3);
|
||||||
u8x8.setCursor(0,3);
|
u8x8.setCursor(0,3);
|
||||||
|
@ -309,7 +309,7 @@ void wifi_sniffer_loop(void * pvParameters) {
|
|||||||
} // end of send data cycle
|
} // end of send data cycle
|
||||||
else {
|
else {
|
||||||
#ifdef BLECOUNTER // execute BLE count if BLE function is enabled
|
#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
|
if (cfg.blescan) // execute BLE count if BLE function is enabled
|
||||||
BLECount();
|
BLECount();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// program version
|
// 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"
|
#define PROGNAME "PAXCNT"
|
||||||
|
|
||||||
// Verbose enables serial output
|
// Verbose enables serial output
|
||||||
|
@ -104,9 +104,14 @@ void set_wifichancycle(int val) {
|
|||||||
ESP_LOGI(TAG, "Remote command: set Wifi channel switch interval to %i seconds", cfg.wifichancycle/100);
|
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) {
|
void set_blescancycle(int val) {
|
||||||
cfg.blescancycle = 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) {
|
void set_countmode(int val) {
|
||||||
@ -244,10 +249,11 @@ cmd_t table[] = {
|
|||||||
{0x09, set_reset, false},
|
{0x09, set_reset, false},
|
||||||
{0x0a, set_wifiscancycle, true},
|
{0x0a, set_wifiscancycle, true},
|
||||||
{0x0b, set_wifichancycle, true},
|
{0x0b, set_wifichancycle, true},
|
||||||
{0x0c, set_blescancycle, true},
|
{0x0c, set_blescantime, true},
|
||||||
{0x0d, set_blescan, true},
|
{0x0d, set_blescancycle, true},
|
||||||
{0x0e, set_wifiant, true},
|
{0x0e, set_blescan, true},
|
||||||
{0x0f, set_rgblum, true},
|
{0x0f, set_wifiant, true},
|
||||||
|
{0x10, set_rgblum, true},
|
||||||
{0x80, get_config, false},
|
{0x80, get_config, false},
|
||||||
{0x81, get_uptime, false},
|
{0x81, get_uptime, false},
|
||||||
{0x82, get_cputemp, false}
|
{0x82, get_cputemp, false}
|
||||||
|
Loading…
Reference in New Issue
Block a user