feat(client): add scan constants, NVS addr key, and state globals
This commit is contained in:
parent
3be06b7469
commit
f07d305621
1 changed files with 10 additions and 3 deletions
|
|
@ -29,9 +29,11 @@ CRGB leds[NUM_LEDS];
|
|||
#define NVS_PSK_NAME "psk"
|
||||
#define NVS_UUID_NAME "uuid"
|
||||
#define NVS_SERVER_NAME "server"
|
||||
#define NVS_ADDR_NAME "addr"
|
||||
#define DEBOUNCE_MS 50
|
||||
#define SCAN_INTERVAL 6000
|
||||
#define SCAN_TIMEOUT 5000
|
||||
#define SCAN_DURATION_MS 5000
|
||||
#define SCAN_INTERVAL_MS 8000
|
||||
#define RECONNECT_DELAY_MS 1000
|
||||
|
||||
uint8_t psk[PSK_LEN];
|
||||
uint8_t deviceUuid[ESP_UUID_LEN];
|
||||
|
|
@ -40,6 +42,8 @@ bool pskProvisioned = false;
|
|||
bool uuidProvisioned = false;
|
||||
bool serverProvisioned = false;
|
||||
bool allProvisioned = false;
|
||||
bool serverAddrStored = false;
|
||||
NimBLEAddress storedServerAddr;
|
||||
Preferences preferences;
|
||||
|
||||
static bool connected = false;
|
||||
|
|
@ -62,6 +66,9 @@ bool otaEnded = false;
|
|||
static bool bleReady = false;
|
||||
static bool serverFound = false;
|
||||
static NimBLEAddress serverAddress;
|
||||
static bool scanning = false;
|
||||
static uint32_t scanStarted = 0;
|
||||
static uint32_t disconnectTime = 0;
|
||||
|
||||
static bool ecdhNotifyReceived = false;
|
||||
static uint8_t ecdhNotifyBuf[ECDH_PKT_SIZE];
|
||||
|
|
@ -548,7 +555,7 @@ void loop() {
|
|||
}
|
||||
|
||||
if (!connected && bleReady) {
|
||||
if (millis() - lastConnectAttempt > SCAN_INTERVAL) {
|
||||
if (millis() - lastConnectAttempt > SCAN_INTERVAL_MS) {
|
||||
ESP_LOGI(TAG, "BLE: connecting to server...");
|
||||
if (pClient == nullptr) {
|
||||
pClient = NimBLEDevice::createClient();
|
||||
|
|
|
|||
Loading…
Reference in a new issue