Sentinel
Loading...
Searching...
No Matches
bluetooth.h
Go to the documentation of this file.
1
8
9#ifndef BLUETOOTH_H
10#define BLUETOOTH_H
11
12#include <NimBLEDevice.h>
13
14
19
20class BluetoothClient : public NimBLEClientCallbacks
21{
22public:
24 void begin();
25 void loop();
26
27 uint8_t getHeartRate() const;
28
29 void onConnect(NimBLEClient *pClient) override;
30 void onDisconnect(NimBLEClient *pClient, int reason) override;
31 void setConnectFlag(const NimBLEAdvertisedDevice *device);
32
33private:
34 void onHeartRateNotify(NimBLERemoteCharacteristic *, uint8_t *, size_t, bool);
35
36 uint8_t heartRate = -1;
37 bool doConnect = false;
38 const NimBLEAdvertisedDevice *advDevice = nullptr;
39};
40
45class ScanCallbacks : public NimBLEScanCallbacks
46{
47public:
48 ScanCallbacks(BluetoothClient *client) : client(client) {}
49 void onResult(const NimBLEAdvertisedDevice *advertisedDevice) override;
50
51private:
52 BluetoothClient *client;
53};
54
55#endif
Class to handle Bluetooth client operations.
Definition bluetooth.h:21
void setConnectFlag(const NimBLEAdvertisedDevice *device)
Set the connect flag for the Bluetooth client.
Definition bluetooth.cpp:36
BluetoothClient()
Construct a new Bluetooth Client object.
Definition bluetooth.cpp:23
void begin()
Initialize the Bluetooth client.
Definition bluetooth.cpp:47
void onConnect(NimBLEClient *pClient) override
Callback function for when the client connects to a device.
Definition bluetooth.cpp:111
void loop()
Loop function for the Bluetooth client.
Definition bluetooth.cpp:64
uint8_t getHeartRate() const
Get the heart rate value.
Definition bluetooth.cpp:144
void onDisconnect(NimBLEClient *pClient, int reason) override
Callback function for when the client disconnects from a device.
Definition bluetooth.cpp:125
void onResult(const NimBLEAdvertisedDevice *advertisedDevice) override
Callback function for scan results.
Definition bluetooth.cpp:185