-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbluetoothAdapter.h
More file actions
51 lines (42 loc) · 1.49 KB
/
Copy pathbluetoothAdapter.h
File metadata and controls
51 lines (42 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef BLUETOOTH_ADAPTER_H
#define BLUETOOTH_ADAPTER_H
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
#include <queue>
#include <string>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/timers.h>
class bluetoothAdapter {
private:
BLEServer* pServer;
BLEService* pService;
BLECharacteristic* pCarLinkWriteCharacteristic;
BLECharacteristic* pCarLinkReadCharacteristic;
static std::queue<std::string> commandsQueue;
static StaticSemaphore_t deviceConnectionSemaphoreBuffer;
static SemaphoreHandle_t deviceConnectionSemaphore;
static StaticSemaphore_t readSemaphoreBuffer;
static SemaphoreHandle_t readSemaphore;
static StaticSemaphore_t queueSemaphoreBuffer;
static SemaphoreHandle_t queueSemaphore; // mutex to from queue being incorrect
static int connectedDevices;
class MyServerCallbacks : public BLEServerCallbacks {
void onConnect(BLEServer* pServer);
void onDisconnect(BLEServer* pServer);
};
class MyCharacteristicWriteCallbacks : public BLECharacteristicCallbacks {
void onWrite(BLECharacteristic* carDataCharacteristics);
};
class MyCharacteristicReadCallbacks : public BLECharacteristicCallbacks {
void onRead(BLECharacteristic* carDataCharacteristics);
};
public:
bluetoothAdapter();
static bool isDeviceConnected;
std::string getCommand();
void updateState(const char* state);
};
#endif // BLUETOOTH_ADAPTER_H