-
Notifications
You must be signed in to change notification settings - Fork 0
/
Messages.h
53 lines (47 loc) · 1.56 KB
/
Messages.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
/*
* Messages.h
*
* Created on: Sep 15, 2016
* Author: bradmiller
*/
#ifndef MESSAGES_H_
#define MESSAGES_H_
/**
* Handles Bluetooth messages as they are received from the Reactor Control System
* This class keeps the current state of the field and allows your program to query it at
* any time. The read() method is called inside the loop() of your program. It reads a
* message and sets the internal class state based on it's contents. This happens each loop.
* You then write methods (like isStopped(), below) that report on that state. The idea is
* that the receipt and parsing of the messages is decoupled from your use of the state data
* making your programs much less complex.
*
* You need to add code and private state variables (like stopped, below) to parse and remember
* the RCS state. Then add methods that can be called independent of message receipt to retrieve
* that state.
*
* Other things you may want to do:
* - check is messages are addressed to your robot (or broadcast to all)
* - handle the source and destination fields which exist for all messages
* - add methods to determine which storage is free/used so you can ask by number
* rather than having to do the bit mask stuff
*/
class Messages {
public:
typedef enum {kReserved,
kStorageAvailability,
kSupplyAvailability,
kRadiationAlert,
kStopMovement,
kResumeMovement,
kRobotStatus,
kHeartbeat} MessageType;
Messages();
bool isStopped();
void sendHeartbeat();
bool read();
void setup();
void printMessage();
private:
bool stopped;
};
#endif /* MESSAGES_H_ */