atcommand.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 ATCOMMAND_H
22 #define ATCOMMAND_H
23 
24 #include "XBeePacket"
25 #include <QByteArray>
26 
27 namespace QtXBee {
28 
39 class ATCommand : public XBeePacket
40 {
41  Q_OBJECT
42 public:
45  // Serial
46  ATWR = 0x5752,
47  ATRE = 0x5245,
48  ATFR = 0x4652,
49  // Addressing
50  ATDH = 0x4448,
51  ATDL = 0x444C,
52  ATMY = 0x4D59,
53  ATMP = 0x4D50,
54  ATNC = 0x4E43,
55  ATSH = 0x5348,
56  ATSL = 0x534C,
57  ATNI = 0x4E49,
58  ATSE = 0x5345,
59  ATDE = 0x4445,
60  ATCI = 0x4349,
61  ATTO = 0x544F,
62  ATNP = 0x4E50,
63  ATDD = 0x4444,
64  ATCR = 0x4352,
65  // Networking
66  ATCH = 0x4348,
67  ATDA = 0x4441,
68  ATID = 0x4944,
69  ATFP = 0x4650,
70  ATAS = 0x4153,
71  ATED = 0x4544,
72  ATOP = 0x4F50,
73  ATRR = 0x5252,
74  ATRN = 0x524E,
75  ATMM = 0x4D4D,
76  ATCE = 0x4345,
77  ATNH = 0x4E48,
78  ATBH = 0x4248,
79  ATOI = 0x4F49,
80  ATNT = 0x4E54,
81  ATNO = 0x4E4F,
82  ATSC = 0x5343,
83  ATSD = 0x5344,
84  ATZS = 0x5A53,
85  ATNJ = 0x4E4A,
86  ATJV = 0x4A56,
87  ATNW = 0x4E57,
88  ATJN = 0x4A4E,
89  ATAR = 0x4152,
90  ATA1 = 0x4131,
91  ATA2 = 0x4132,
92  // Security
93  ATEE = 0x4545,
94  ATEO = 0x454F,
95  ATNK = 0x4E4B,
96  ATKY = 0x4B59,
97  // RF Interfacing
98  ATPL = 0x504C,
99  ATCA = 0x4341,
100  ATPM = 0x504D,
101  ATDB = 0x4442,
102  ATPP = 0x5050,
103  // Serial Interfacing (I/O)
104  ATAP = 0x4150,
105  ATAO = 0x414F,
106  ATBD = 0x4244,
107  ATNB = 0x4E42,
108  ATSB = 0x5342,
109  ATRO = 0x524F,
110  // I/O ATs
111  ATIR = 0x4952,
112  ATIC = 0x4943,
113  ATP0 = 0x5030,
114  ATP1 = 0x5031,
115  ATP2 = 0x5032,
116  ATP3 = 0x5033,
117  ATD0 = 0x4430,
118  ATD1 = 0x4431,
119  ATD2 = 0x4432,
120  ATD3 = 0x4433,
121  ATD4 = 0x4434,
122  ATD5 = 0x4435,
123  ATD6 = 0x4436,
124  ATD7 = 0x4437,
125  ATD8 = 0x4438,
126  ATLT = 0x4C54,
127  ATPR = 0x5052,
128  ATRP = 0x5250,
129  ATV = 0x2556,
130  ATVP = 0x562B,
131  ATTP = 0x5450,
132  ATVR = 0x5652,
133  ATHV = 0x4856,
134  ATAI = 0x4149,
135  // AT AT Options
136  ATCT = 0x4354,
137  ATCN = 0x434E,
138  ATGT = 0x4754,
139  ATCC = 0x4343,
140  // Sleep ATs
141  ATSM = 0x534D,
142  ATSN = 0x534E,
143  ATSP = 0x5350,
144  ATDP = 0x4450,
145  ATST = 0x5354,
146  ATSO = 0x534F,
147  ATWH = 0x5748,
148  ATSI = 0x5349,
149  ATPO = 0x504F,
150  // Execution ATs
151  ATAC = 0x4143,
152  ATNR = 0x4E52,
153  ATCB = 0x4342,
154  ATND = 0x4E44,
155  ATDN = 0x444E,
156  ATIS = 0x4953,
157  AT1S = 0x3153
158  };
159 
160  explicit ATCommand (QObject *parent = 0);
161 
162  // Reimplemented from XBeePacket
163  virtual QString toString ();
164  virtual void assemblePacket ();
165  virtual void clear ();
166 
167  void setCommand (const ATCommandType command);
168  void setCommand (const QByteArray &command);
169  void setParameter (const QByteArray &param);
170 
171  ATCommandType command () const;
172  QByteArray parameter () const;
173 
174  static QString atCommandToString (const ATCommandType command);
175  static QByteArray atCommandToByteArray (const ATCommandType command);
176  static ATCommandType atCommandFromByteArray (const QByteArray & command);
177 
178  private:
179  ATCommandType m_command;
180  QByteArray m_parameter;
181 };
182 
183 } // END namespace
184 
185 #endif // ATCOMMAND_H