-
Notifications
You must be signed in to change notification settings - Fork 0
/
BTComms.h
28 lines (26 loc) · 841 Bytes
/
BTComms.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
#ifndef _BTReader
#define _BTReader
/**
* Low level class to both receive and send message to the field.
* The writeMessage() method sends messages to the field and the other methods
* receive message from the field.
*
* This class is used by the higher level Messages class to separate the actual
* byte reading and dealing with checksums from the messages class to make it more
* understandable.
*/
class BTComms {
public:
BTComms();
void setup();
int getMessageLength();
unsigned char getMessageByte(unsigned index);
bool read();
void writeMessage(unsigned char b1, unsigned char b2, unsigned char b3);
private:
enum BTstate {kLookingForStart, kReadingMessageLength, kReadMessage} BTstate;
unsigned messageLength;
unsigned messageIndex;
unsigned char kMessageStart = 0x5f;
};
#endif