QtXBee 0.1.pre-alpha
Main Page
Related Pages
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Enumerations
Enumerator
Pages
src
qtxb
xbeepacket.h
1
/*
2
* Copyright (C) 2015 ThomArmax (Thomas COIN)
3
*
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
8
*
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
13
*
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
*
18
* Thomas COIN <esvcorp@gmail.com> 18/04/2015
19
*/
20
21
#ifndef XBEEPACKET_H
22
#define XBEEPACKET_H
23
24
#include <QByteArray>
25
#include <QObject>
26
27
namespace
QtXBee {
28
38
class
XBeePacket
:
public
QObject
39
{
40
Q_OBJECT
41
public
:
42
46
enum
ApiId
{
47
TxRequest64Id
= 0x00,
// 802.15.4
48
TxRequest16Id
= 0x01,
// 802.15.4
49
ATCommandId
= 0x08,
// 802.15.4, ZNet, ZigBee
50
ATCommandQueueId
= 0x09,
// 802.15.4, ZNet, ZigBee
51
ZBTxRequestId
= 0x10,
// ZNet, ZigBee
52
ZBExplicitTxRequestId
= 0x11,
// ZNet, ZigBee
53
RemoteATCommandRequestId
= 0x17,
// 802.15.4, ZNet, ZigBee
54
CreateSourceRouteId
= 0x21,
// ZigBee
55
ZBRegisterJoiningDeviceId = 0x24,
// ZigBee
56
Rx64ResponseId
= 0x80,
// 802.15.4
57
Rx16ResponseId
= 0x81,
// 802.15.4
58
Rx64IOResponseId
= 0x82,
// 802.15.4
59
Rx16IOResponseId
= 0x83,
// 802.15.4
60
ATCommandResponseId
= 0x88,
// 802.15.4, ZNet, ZigBee
61
TxStatusResponseId
= 0x89,
// 802.15.4
62
ModemStatusResponseId
= 0x8A,
// 802.15.4, ZNet, ZigBee
63
ZBTxStatusResponseId
= 0x8B,
// ZNet, ZigBee
64
ZBRxResponseId
= 0x90,
// ZNet, ZigBee
65
ZBExplicitRxResponseId
= 0x91,
// ZNet, ZigBee
66
ZBIOSampleResponseId
= 0x92,
// ZNet, ZigBee
67
XBeeSensorReadIndicatorId
= 0x94,
// ZNet, ZigBee
68
ZBIONodeIdentificationId
= 0x95,
// ZNet, ZigBee
69
RemoteATCommandResponseId
= 0x97,
// 802.15.4, ZNet, ZigBee
70
OverTheAirFirmwareUpdateId
= 0xA0,
// ZigBee
71
RouteRecordIndicatorId
= 0xA1,
// ZigBee
72
DeviceAuthenticatedIndicatorId = 0xA2,
// ZigBee
73
ManyToOneRouteRequestId
= 0xA3,
// ZigBee
74
RegisterJoiningDeviceStatusId = 0xA4,
// ZigBee
75
JoinNotificationStatusId = 0xA5,
// ZigBee
76
UndefinedId
= 0xFF
77
};
78
82
enum
SpecialByte
{
83
StartDelimiter
= 0x7E,
84
Escape
= 0x7D,
85
XON
= 0x11,
86
XOFF
= 0x13
87
};
88
89
explicit
XBeePacket
(QObject *parent = 0);
90
91
void
setStartDelimiter
(
unsigned
sd);
92
void
setLength
(
unsigned
length
);
93
void
setFrameType
(
ApiId
type);
94
void
setFrameId
(quint8
id
);
95
void
setChecksum
(
unsigned
cs);
96
bool
setPacket
(
const
QByteArray &
packet
);
97
98
QByteArray
packet
()
const
;
99
unsigned
startDelimiter
()
const
;
100
quint16
length
()
const
;
101
ApiId
frameType
()
const
;
102
quint8
frameId
()
const
;
103
unsigned
checksum
()
const
;
104
105
virtual
void
assemblePacket
();
106
virtual
void
clear
();
107
virtual
QString
toString
();
108
static
QString
frameTypeToString
(
const
ApiId
type);
109
110
void
escapePacket ();
111
bool
unescapePacket ();
112
113
private
:
114
bool
isSpecialByte (
const
char
c);
115
116
protected
:
117
virtual
bool
parseApiSpecificData
(
const
QByteArray & data);
118
void
createChecksum
(QByteArray array);
119
120
protected
:
121
QByteArray
m_packet
;
122
private
:
123
unsigned
m_startDelimiter;
124
quint16 m_length;
125
ApiId
m_frameType;
126
quint8 m_frameId;
127
unsigned
m_checksum;
128
};
129
130
}
// END namepsace
131
132
#endif // XBEEPACKET_H
Generated on Sat Jun 13 2015 19:02:02 for QtXBee by
1.8.3.1