-
Notifications
You must be signed in to change notification settings - Fork 0
/
Handlers.cpp
45 lines (42 loc) · 1.03 KB
/
Handlers.cpp
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
#include "State.h"
#include "Handlers.h"
#include "Constants.h"
void blePeripheralConnectHandler(BLEDevice central)
{
// central connected event handler
if (Serial)
{
Serial.print("Connected event, central: ");
Serial.println(central.address());
}
}
void blePeripheralDisconnectHandler(BLEDevice central)
{
// central disconnected event handler
if (Serial)
{
Serial.print("Disconnected event, central: ");
Serial.println(central.address());
}
}
void characteristicWrittenHandler(BLEDevice central, BLECharacteristic characteristic)
{
if (strcmp(characteristic.uuid(), DIR_UUID) == 0)
{
float floatValue;
characteristic.readValue(&floatValue, 4);
direction = floatValue;
}
else if (strcmp(characteristic.uuid(), SPEED_UUID) == 0)
{
float floatValue;
characteristic.readValue(&floatValue, 4);
speed = floatValue;
}
else if (strcmp(characteristic.uuid(), ROTATION_UUID) == 0)
{
float floatValue;
characteristic.readValue(&floatValue, 4);
rotation = floatValue;
}
}