-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessage.h
115 lines (83 loc) · 3.3 KB
/
Message.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**
* Message.h - The official Lithne library.
*
* Copyright (c) 2011-2012
* Serge Offermans, Remco Magielse
* {s.a.m.offermans, r.magielse}@tue.nl
* Intelligent Lighting Institute (ILI), TU/e.
*
* All rights reserved. LAST UPDATE: 01-04-2012
**/
#ifndef Message_h
#define Message_h
#include "Node.h"
#include "LithneXBee.h"
#include "LithneDefinitions.h"
class Message
{
public:
Message();
~Message();
// const static uint8_t ERROR_MESSAGE = 255;
const static uint16_t NO_ARGUMENT = 65535;
// const static uint8_t NO_SCOPE = 1;
//Payload constants
const static uint8_t SCOPE_MSB = 0;
const static uint8_t SCOPE_LSB = 1;
const static uint8_t FUNCTION_MSB = 2;
const static uint8_t FUNCTION_LSB = 3;
const static uint8_t MAXIMUM_PAYLOAD_BYTES = 72;
const static uint8_t MSG_HEADER_SIZE = 4;
void clearArguments();
/** 64-bit XBee Destination Address **/
XBeeAddress64 toXBeeAddress64( XBeeAddress64 _addr64 );
XBeeAddress64 toXBeeAddress64();
void setRecipient64( XBeeAddress64 _addr64 ); //deprecated
XBeeAddress64 getRecipient64( ); //deprecated
/** 16-bit XBee Destination Address **/
uint16_t toXBeeAddress16( uint16_t _addr16 );
uint16_t toXBeeAddress16();
void setRecipient16( uint16_t _addr16 ); //deprecated
uint16_t getRecipient16(); //deprecated
/** 64-bit XBee Sender Address **/
XBeeAddress64 fromXBeeAddress64();
XBeeAddress64 fromXBeeAddress64( XBeeAddress64 _addr64 );
void setSender64( XBeeAddress64 _addr64 ); //deprecated
XBeeAddress64 getSender64( ); //deprecated
/** 16-bit XBee Sender Address **/
uint16_t fromXBeeAddress16();
uint16_t fromXBeeAddress16( uint16_t _addr16 );
void setSender16( uint16_t _addr16 ); //deprecated
uint16_t getSender16(); //deprecated
// void setRecipient( uint8_t _id );
void setRecipient( Node * );
void setFunction( uint16_t _func );
void setFunction( String _func );
void setSender( uint16_t _addr16, XBeeAddress64 _addr64 );
void setScope( String _scope );
void setScope( uint16_t _scope );
bool addArgument( uint16_t _arg );
bool addByte( uint8_t _byte );
bool setStringArgument( String _arg );
// boolean addArg( uint32_t* arg); Discuss with Elco how to implement this
boolean functionIs( String _func );
uint8_t getNumberOfArguments();
uint8_t getNumberOfBytes();
uint8_t getPayloadSize();
uint8_t * getPayload();
uint8_t getPayloadByte( uint8_t _position );// Returns the byte at teh specified position in the total payload (including scope and function)
uint8_t getByte( uint8_t _position ); // Returns the byte at the specified position in the data bytes
uint16_t getArgument( uint8_t _position ); // Returns the integer from the arguments
uint16_t getFunction();
uint16_t getScope();
uint16_t hash( String _group );
String getStringArgument();
private:
uint8_t payloadSize ; //Contains the number of bytes in the payload including the Scope (2 bytes) and function(1 byte)
uint8_t payload[MAXIMUM_PAYLOAD_BYTES];
uint16_t sender16 ; //Contains the 16 bit address of the Sender
uint16_t recipient16 ; //Contains the 16 bit address of the Recipient
XBeeAddress64 sender64 ; //Contains the 64 bit address of the Sender
XBeeAddress64 recipient64 ; //Contains the 64 bit address of the Recipient
};
#endif