-
Notifications
You must be signed in to change notification settings - Fork 2
/
RaceChrono.h
47 lines (33 loc) · 1.3 KB
/
RaceChrono.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
#ifndef __RACECHRONO_H
#define __RACECHRONO_H
#include "RaceChronoPidMap.h"
class RaceChronoBleCanHandler {
public:
virtual ~RaceChronoBleCanHandler() {}
virtual void allowAllPids(uint16_t updateIntervalMs);
virtual void denyAllPids();
virtual void allowPid(uint32_t pid, uint16_t updateIntervalMs);
void handlePidRequest(const uint8_t *data, uint16_t len);
};
class RaceChronoBleAgent {
public:
// Seems like the length limit for 'bluetoothName' is 19 visible characters.
virtual void setUp(
const char *bluetoothName, RaceChronoBleCanHandler *handler) = 0;
virtual void startAdvertising() = 0;
// Returns true on success, false on failure.
bool waitForConnection(uint32_t timeoutMs);
virtual bool isConnected() const = 0;
virtual void sendCanData(uint32_t pid, const uint8_t *data, uint8_t len) = 0;
protected:
static const uint16_t RACECHRONO_SERVICE_UUID = 0x1ff8;
// RaceChrono uses two BLE characteristics:
// 1) 0x02 to request which PIDs to send, and how frequently
// 2) 0x01 to be notified of data received for those PIDs
static const uint16_t PID_CHARACTERISTIC_UUID = 0x2;
static const uint16_t CAN_BUS_CHARACTERISTIC_UUID = 0x1;
};
#if defined(ARDUINO_ARCH_NRF52)
#endif // ARDUINO_ARCH_NRF52
extern RaceChronoBleAgent &RaceChronoBle;
#endif // __RACECHRONO_H