45 lines
1010 B
C++
45 lines
1010 B
C++
#ifndef ChronoBLE_H
|
|
#define ChronoBLE_H
|
|
|
|
#include <Arduino.h>
|
|
#include <NimBLEDevice.h>
|
|
#include <GunProfile.h>
|
|
|
|
// Flag to signal that a new reading is ready to be processed
|
|
extern volatile bool newReadingAvailable;
|
|
extern volatile int lastReadFPS;
|
|
|
|
typedef void (*CallbackFunction)();
|
|
|
|
class ChronoBLE {
|
|
public:
|
|
enum ConnectionState {
|
|
IDLE,
|
|
SCANNING,
|
|
DEVICE_FOUND,
|
|
CONNECTING,
|
|
CONNECTED
|
|
};
|
|
|
|
// Constructor: Called when a ChronoBLE object is created
|
|
ChronoBLE();
|
|
|
|
// Public methods
|
|
ConnectionState currentState;
|
|
void init();
|
|
void startScan();
|
|
bool isIdle();
|
|
bool isConnected();
|
|
bool foundDevice();
|
|
bool connectToDevice();
|
|
static void setDevice(const NimBLEAdvertisedDevice* device);
|
|
static bool changeGunType(int type);
|
|
void setSpeedCallback(void (*pFunc)(int speed));
|
|
bool setSpeedProfile(uint8_t low, uint8_t high);
|
|
|
|
private:
|
|
void _setState(ConnectionState state);
|
|
void _disconnectDevice();
|
|
};
|
|
|
|
#endif |