-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataPacket.h
75 lines (60 loc) · 2.29 KB
/
DataPacket.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
/*
AllThingsTalk lora library
Copyright 2015-2016 AllThingsTalk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Original author: Jan Bogaerts (2015-2016)
*/
#ifndef DataPacket_h
#define DataPacket_h
#include <string.h>
#include <Stream.h>
#include <LoRaPacket.h>
//this class represents the ATT cloud platform.
class DataPacket: public LoRaPacket
{
public:
//create the object
DataPacket();
//writes the packet content to the specified byte array. This must be at least 51 bytes long.
//returns: the nr of bytes actually written to the array.
virtual unsigned char Write(unsigned char* result);
//loads a bool data value into the data packet tha is being prepared to send to the
//cloud server.
//the packet is sent after calling Send(id_of_sensor)
//returns true if successful, otherwise false.
bool Add(bool value);
//loads a bool data value into the data packet tha is being prepared to send to the
//cloud server.
//the packet is sent after calling Send(id_of_sensor)
//returns true if successful, otherwise false.
bool Add(short value);
//loads a bool data value into the data packet tha is being prepared to send to the
//cloud server.
//the packet is sent after calling Send(id_of_sensor)
//returns true if successful, otherwise false.
bool Add(String value);
//loads a bool data value into the data packet tha is being prepared to send to the
//cloud server.
//the packet is sent after calling Send(id_of_sensor)
//returns true if successful, otherwise false.
bool Add(float value);
//resets the content of the packet back to 0 ->> all data will be removed
void Reset();
private:
//define the stores for all the values for this packet
char stringValues[48];
short intValues[16];
float floatValues[16];
unsigned char boolValues;
unsigned char stringPos;
unsigned char nrInts;
unsigned char nrFloats;
unsigned char nrBools;
};
#endif