-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBLE.h
65 lines (48 loc) · 1.27 KB
/
BLE.h
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef _BLE_H_
#define _BLE_H_
#include "Arduino.h"
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
#include "esp_ota_ops.h"
#define SOFTWARE_VERSION_MAJOR 0
#define SOFTWARE_VERSION_MINOR 1
#define SOFTWARE_VERSION_PATCH 2
#define HARDWARE_VERSION_MAJOR 1
#define HARDWARE_VERSION_MINOR 2
class BLE; // forward declaration
class BLECustomServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
// deviceConnected = true;
// // code here for when device connects
};
void onDisconnect(BLEServer* pServer) {
// deviceConnected = false;
// // code here for when device disconnects
}
};
class otaCallback: public BLECharacteristicCallbacks {
public:
otaCallback(BLE* ble) {
_p_ble = ble;
}
BLE* _p_ble;
void onWrite(BLECharacteristic *pCharacteristic);
};
class BLE
{
public:
BLE(void);
~BLE(void);
bool begin(const char* localName);
private:
String local_name;
BLEServer *pServer = NULL;
BLEService *pESPOTAService = NULL;
BLECharacteristic * pESPOTAIdCharacteristic = NULL;
BLEService *pService = NULL;
BLECharacteristic * pVersionCharacteristic = NULL;
BLECharacteristic * pOtaCharacteristic = NULL;
};
#endif