Updates #1
+9
-7
@@ -4,11 +4,12 @@
|
|||||||
// Flag to signal that a new reading is ready to be processed
|
// Flag to signal that a new reading is ready to be processed
|
||||||
volatile bool newReadingAvailable = false;
|
volatile bool newReadingAvailable = false;
|
||||||
volatile int lastReadFPS = 0;
|
volatile int lastReadFPS = 0;
|
||||||
|
static NimBLEScan* pScan;
|
||||||
static NimBLEClient* _pClient = nullptr;
|
static NimBLEClient* _pClient = nullptr;
|
||||||
static ChronoBLE::ConnectionState currentState;
|
static ChronoBLE::ConnectionState currentState;
|
||||||
static const NimBLEAdvertisedDevice* advDevice = nullptr;
|
static const NimBLEAdvertisedDevice* advDevice = nullptr;
|
||||||
static uint32_t scanTimeMs = 5000;
|
static uint32_t scanTimeMs = 1000; //5000
|
||||||
|
static uint32_t scanTimeoutMs = 1000;
|
||||||
static NimBLEUUID deviceUUID("0000180a-0000-1000-8000-00805f9b34fb");
|
static NimBLEUUID deviceUUID("0000180a-0000-1000-8000-00805f9b34fb");
|
||||||
static NimBLEUUID serviceUUID("00001623-88EC-688C-644B-3FA706C0BB75");
|
static NimBLEUUID serviceUUID("00001623-88EC-688C-644B-3FA706C0BB75");
|
||||||
static NimBLEUUID speedCharacteristicUUID("00001624-88EC-688C-644B-3FA706C0BB75");
|
static NimBLEUUID speedCharacteristicUUID("00001624-88EC-688C-644B-3FA706C0BB75");
|
||||||
@@ -58,7 +59,8 @@ class ScanCallbacks : public NimBLEScanCallbacks {
|
|||||||
/** Callback to process the results of the completed scan or restart it */
|
/** Callback to process the results of the completed scan or restart it */
|
||||||
void onScanEnd(const NimBLEScanResults& results, int reason) override {
|
void onScanEnd(const NimBLEScanResults& results, int reason) override {
|
||||||
//Serial.printf("Scan Ended, reason: %d, device count: %d; Restarting scan\n", reason, results.getCount());
|
//Serial.printf("Scan Ended, reason: %d, device count: %d; Restarting scan\n", reason, results.getCount());
|
||||||
NimBLEDevice::getScan()->start(scanTimeMs, false, true);
|
delay(scanTimeoutMs);
|
||||||
|
pScan->start(scanTimeMs, false, false);
|
||||||
}
|
}
|
||||||
} scanCallbacks;
|
} scanCallbacks;
|
||||||
|
|
||||||
@@ -94,11 +96,11 @@ ChronoBLE::ChronoBLE() {
|
|||||||
void ChronoBLE::init() {
|
void ChronoBLE::init() {
|
||||||
NimBLEDevice::init("FX-Chrono-Client");
|
NimBLEDevice::init("FX-Chrono-Client");
|
||||||
NimBLEDevice::setPower(3); /** 3dbm */
|
NimBLEDevice::setPower(3); /** 3dbm */
|
||||||
NimBLEScan* pScan = NimBLEDevice::getScan();
|
pScan = NimBLEDevice::getScan();
|
||||||
pScan->setScanCallbacks(&scanCallbacks, false);
|
pScan->setScanCallbacks(&scanCallbacks, false);
|
||||||
pScan->setInterval(100);
|
pScan->setInterval(100);
|
||||||
pScan->setWindow(100);
|
pScan->setWindow(99);
|
||||||
pScan->setActiveScan(true);
|
pScan->setActiveScan(false);
|
||||||
}
|
}
|
||||||
void ChronoBLE::_setState(ConnectionState state){
|
void ChronoBLE::_setState(ConnectionState state){
|
||||||
currentState=state;
|
currentState=state;
|
||||||
@@ -122,7 +124,7 @@ bool ChronoBLE::foundDevice(){if (advDevice!=nullptr){return true;}return false;
|
|||||||
void ChronoBLE::startScan(){
|
void ChronoBLE::startScan(){
|
||||||
Serial.println("starting scan!!!");
|
Serial.println("starting scan!!!");
|
||||||
_setState(SCANNING);
|
_setState(SCANNING);
|
||||||
NimBLEDevice::getScan()->start(scanTimeMs, false, true);
|
pScan->start(scanTimeMs, false, false);
|
||||||
}
|
}
|
||||||
void ChronoBLE::_disconnectDevice(){
|
void ChronoBLE::_disconnectDevice(){
|
||||||
_setState(IDLE);
|
_setState(IDLE);
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
+180
-203
File diff suppressed because one or more lines are too long
@@ -6,6 +6,7 @@
|
|||||||
#include <NetworkClient.h>
|
#include <NetworkClient.h>
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
#include <Update.h>
|
#include <Update.h>
|
||||||
|
#include <Preferences.h>
|
||||||
#include <ChronoBLE.h>
|
#include <ChronoBLE.h>
|
||||||
#include <GunProfile.h>
|
#include <GunProfile.h>
|
||||||
#include "ChronoVersion.h"
|
#include "ChronoVersion.h"
|
||||||
@@ -36,6 +37,10 @@ class ChronoWebServer {
|
|||||||
static void _handleTestMode();
|
static void _handleTestMode();
|
||||||
static void _handleOta();
|
static void _handleOta();
|
||||||
static void _handleVersion();
|
static void _handleVersion();
|
||||||
|
static void _handleWifi();
|
||||||
|
static void _handleWifiSave();
|
||||||
|
static void _handleClearWifi();
|
||||||
|
static void _handleWifiMode();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user