-
Notifications
You must be signed in to change notification settings - Fork 0
/
MessageBuilder.h
54 lines (46 loc) · 1.46 KB
/
MessageBuilder.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
#pragma once
#include "Arduino.h"
//Flags
#define FLAG_IMPORTANT 1
#define FLAG_ACK 2
class MessageBuilder{
private:
char m_flags;
String m_address_from;
String m_address_to;
char m_message_type;
char m_message_sub_type;
String m_data;
static String intToBase36(int i);
static int base36ToInt(String str);
public:
static void setChecksum(String& message);
//Error codes
// 0 = Ok.
// 1 = checksum error
// 2 = fields missing
static char validate(String message);
static String computeChecksum(String message);
static char decodeFlags(String message);
static String decodeAddressTo(String message);
static String decodeAddressFrom(String message);
static char decodeType(String message);
static char decodeSubType(String message);
static String decodeData(String message);
static void decodeMessageFields(String message,
char& flags, String& address_from, String& address_to,
char& type,char& sub_type,String& data);
static void setFlags(String& message, char codes);
static void setAddressFrom(String& message, String address);
static void setAddressTo(String& message, String address);
static void invertAddress(String& message);
void setFlags(char codes);
void setAddressFrom(String address);
void setAddressTo(String address);
void setMessageType(char type);
void setMessageSubType(char sub_type);
void setData(String data);
String getMessage();
MessageBuilder(void);
~MessageBuilder(void);
};