rc_proto: choose best power level for rc transmit
[protos/xbee.git] / xbee_atcmd.c
1 /*
2  * Copyright (c) 2011, Olivier MATZ <zer0@droids-corp.org>
3  * All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  *     * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the distribution.
12  *     * Neither the name of the University of California, Berkeley nor the
13  *       names of its contributors may be used to endorse or promote products
14  *       derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27
28 #include <string.h>
29 #include <stdlib.h>
30
31 #include "xbee_atcmd.h"
32
33 struct xbee_atcmd xbee_atcmd_list[] = {
34         {
35                 "WR",
36                 "write-param",
37                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
38                 "Write parameter values to non-volatile memory.",
39         },
40         {
41                 "RE",
42                 "restore-defaults",
43                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
44                 "Restore module parameters to factory defaults.",
45         },
46         {
47                 "FR",
48                 "soft-reset",
49                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
50                 "Software Reset. Responds with 'OK' then performs a "
51                 "reset 100ms later.",
52         },
53         {
54                 "AC",
55                 "apply-changes",
56                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
57                 "Apply Changes without exiting command mode.",
58         },
59         {
60                 "R1",
61                 "restore-compiled",
62                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
63                 "Restore module parameters to compiled defaults.",
64         },
65         {
66                 "VL",
67                 "version-long",
68                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
69                 "Shows detailed version information including"
70                 "application build date and time.",
71         },
72         {
73                 "DH",
74                 "dst-addr-high",
75                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
76                 "Upper 32 bits of the 64-bit destination address (0 "
77                 "to 0xFFFFFFFF, default is 0x0000FFFF).",
78         },
79         {
80                 "DL",
81                 "dst-addr-low",
82                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
83                 "Lower 32 bits of the 64-bit destination address (0 "
84                 "to 0xFFFFFFFF, default is 0x0000FFFF).",
85         },
86         {
87                 "DD",
88                 "device-type-id",
89                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ,
90                 "Device Type Identifier, it can be used to differentiate "
91                 "multiple XBee-based products (0 to 0xFFFFFFFF, read-only, "
92                 "default is 0x40000).",
93         },
94         {
95                 "SH",
96                 "src-addr-high",
97                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ,
98                 "Upper 32 bits of the 64-bit source address (read-only).",
99         },
100         {
101                 "SL",
102                 "src-addr-low",
103                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ,
104                 "Lower 32 bits of the 64-bit source address (read-only).",
105         },
106         {
107                 "SE",
108                 "src-endpoint",
109                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
110                 "The application source endpoint for all data transmissions "
111                 "(0 to 0xFF, default is 0xE8).",
112         },
113         {
114                 "DE",
115                 "dst-endpoint",
116                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
117                 "The application destination endpoint for all data "
118                 "transmissions (0 to 0xFF, default is 0xE8).",
119         },
120         {
121                 "CI",
122                 "cluster-id",
123                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
124                 "Cluster Identifier for all data transmissions (0 to 0xFFFF, "
125                 "default is 0x11).",
126         },
127         {
128                 "NP",
129                 "max-rf-payload",
130                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
131                 "Maximum RF Payload Bytes that can be sent in a unicast "
132                 "transmission based on the current configuration (0 to "
133                 "0xFFFF).",
134         },
135         {
136                 "CE",
137                 "coord-end-device",
138                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
139                 "Coordinator/End Device, messaging mode of the module "
140                 "(0 - Normal, 1 - Indirect coordinator, 2 - Polling, default "
141                 "is 0).",
142         },
143         {
144                 "AP",
145                 "api-mode",
146                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
147                 "API mode (0 - off, 1 - on, 2 - on with escape sequences).",
148         },
149         {
150                 "AO",
151                 "api-output-format",
152                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
153                 "API Output Format (0 - standard [0x90 for RX], 1 - explicit "
154                 "addressing [0x91 for RX]).",
155         },
156         {
157                 "BD",
158                 "baud-rate",
159                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
160                 "Baud rate of serial interface (0-8 select preset standard "
161                 "rates, and 0x39 to 0x1c9c38 select baud rate).",
162         },
163         {
164                 "RO",
165                 "packetization-timeout",
166                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
167                 "Packetization Timeout: the inter-character silence required "
168                 "before packetization specified in character times (0 to 0xFF, "
169                 "default is 3).",
170         },
171         {
172                 "FT",
173                 "flow-control-thres",
174                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
175                 "Flow Control Threshhold. De-assert CTS and/or send XOFF when "
176                 "FT bytes are in the UART receive buffer. Re-assert CTS when "
177                 "less than FT - 16 bytes are in the UART receive buffer (0x11 "
178                 "to 0xEE, default is 0xBE).",
179         },
180         {
181                 "NB",
182                 "parity",
183                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
184                 "Parity (0 - no parity, 1 - even parity, 2 - odd parity, 3 - "
185                 "forced high parity, 4 - forced low parity). Default is 0.",
186         },
187         {
188                 "D7",
189                 "dio7",
190                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
191                 "DIO7 Configuration (0 - unmonitored input, 1 - CTS, 3 - "
192                 "digital input, 4 - digital output low, 5 - digital output "
193                 "high, 6 - RS-485 low Tx, 7 -  RS-485 high Tx). Default is "
194                 "0.",
195         },
196         {
197                 "D6",
198                 "dio6",
199                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
200                 "DIO6 Configuration (0 - unmonitored input, 1 - RTS, 3 - "
201                 "digital input, 4 - digital output low, 5 - digital output "
202                 "high). Default is 0.",
203         },
204         {
205                 "P0",
206                 "dio10-pwm0",
207                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
208                 "DIO10/PWM0 Configuration. (0 - unmonitored input, 1 - RSSI, 2 "
209                 "- PWM0, 3 - digital input, 4 - digital output low, 5 - "
210                 "digital output high). Default is 1.",
211         },
212         {
213                 "P1",
214                 "dio11-pwm1",
215                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
216                 "DIO11/PWM1 Configuration. (0 - unmonitored input, 2 "
217                 "- PWM1, 3 - digital input, 4 - digital output low, 5 - "
218                 "digital output high). Default is 0.",
219         },
220         {
221                 "P2",
222                 "dio12",
223                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
224                 "DIO12 Configuration. (0 - unmonitored input, "
225                 "3 - digital input, 4 - digital output low, 5 - "
226                 "digital output high). Default is 0.",
227         },
228         {
229                 "RP",
230                 "rssi-pwm",
231                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
232                 "Time RSSI signal will be output after last transmission. "
233                 "When RP = 0xFF, output will always be on (0 - 0xFF, default "
234                 "is 0x28 = 4 seconds).",
235         },
236         {
237                 "1S",
238                 "sensor-sample",
239                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
240                 "Forces a sample to be taken on an XBee Sensor device.",
241         },
242         {
243                 "D0",
244                 "dio0-ad0",
245                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
246                 "AD0/DIO0 Configuration. (0 - unmonitored input, 1 - "
247                 "commission button enabled, 2 - analog input, 3 - digital "
248                 "input, 4 - digital output low, 5 - digital output high). "
249                 "Default is 1.",
250         },
251         {
252                 "D1",
253                 "dio1-ad1",
254                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
255                 "AD1/DIO1 Configuration. (0 - unmonitored input, "
256                 "2 - analog input, 3 - digital input, 4 - digital output "
257                 "low, 5 - digital output high). Default is 0.",
258         },
259         {
260                 "D2",
261                 "dio2-ad2",
262                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
263                 "AD2/DIO2 Configuration. (0 - unmonitored input, "
264                 "2 - analog input, 3 - digital input, 4 - digital output "
265                 "low, 5 - digital output high). Default is 0.",
266         },
267         {
268                 "D3",
269                 "dio3-ad3",
270                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
271                 "AD3/DIO3 Configuration. (0 - unmonitored input, "
272                 "2 - analog input, 3 - digital input, 4 - digital output "
273                 "low, 5 - digital output high). Default is 0.",
274         },
275         {
276                 "D4",
277                 "dio4-ad4",
278                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
279                 "AD4/DIO4 Configuration. (0 - unmonitored input, "
280                 "2 - analog input, 3 - digital input, 4 - digital output "
281                 "low, 5 - digital output high). Default is 0.",
282         },
283         {
284                 "D5",
285                 "dio5-ad5",
286                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
287                 "AD4/DIO4 Configuration. (0 - unmonitored input, 1 - LED, "
288                 "2 - analog input, 3 - digital input, 4 - digital output "
289                 "low, 5 - digital output high). Default is 1.",
290         },
291         {
292                 "D8",
293                 "dio8-sleep-rq",
294                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
295                 "DIO8/SLEEP_RQ Configuration. (0 - unmonitored input, 1 - LED, "
296                 "2 - analog input, 3 - digital input, 4 - digital output "
297                 "low, 5 - digital output high). Default is 0. When used as "
298                 "SLEEP_RQ, the D8 parameter should be configured in mode 0 "
299                 "or 3.",
300         },
301         {
302                 "D9",
303                 "dio9-on-sleep",
304                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
305                 "DIO9/ON_SLEEP Configuration. (0 - unmonitored input, 1 - "
306                 "ON/SLEEP, 2 - analog input, 3 - digital input, 4 - digital "
307                 "output low, 5 - digital output high). Default is ?.",
308         },
309         {
310                 "PR",
311                 "pull-up-resistor",
312                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
313                 "Pull-up Resistor. Bit field that configures the internal "
314                 "pull-up resistors for the I/O lines (bit set = pull-up "
315                 "enabled). Range is from 0 to 0x1FFF, default is 0x1FFF.",
316         },
317         {
318                 "M0",
319                 "pwm0-out-level",
320                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
321                 "PWM0 Output Level. The line should be configured as a PWM "
322                 "output using the P0 command (0 to 0x3FF, default is 0).",
323         },
324         {
325                 "M1",
326                 "pwm1-out-level",
327                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
328                 "PWM1 Output Level. The line should be configured as a PWM "
329                 "output using the P1 command (0 to 0x3FF, default is 0).",
330         },
331         {
332                 "LT",
333                 "led-blink-time",
334                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
335                 "Associate LED Blink Time (should be enabled through D5 "
336                 "command). Range is 0x14-0xFF (x10ms), default is 0.",  },
337         {
338                 "IS",
339                 "force-sample",
340                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
341                 "Forces a read of all enabled digital and "
342                 "analog input lines.",
343         },
344         {
345                 "IC",
346                 "digital-change-detect",
347                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
348                 "I/O Digital Change Detection. If a pin is enabled as a "
349                 "digital input/output, the IC command can be used to "
350                 "force an immediate I/O sample transmission when the DIO "
351                 "state changes. IC is a bitmask, range is 0 to 0xFFFF, "
352                 "default is 0",
353         },
354         {
355                 "IR",
356                 "io-sample-rate",
357                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
358                 "IO Sample Rate for periodic sampling. If zero, periodic "
359                 "sampling is disabled. Else the value is in milliseconds "
360                 "(range 0 to 0xFFFF, default is 0).",
361         },
362         {
363                 "CB",
364                 "comissioning-button",
365                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
366                 "Commissioning Pushbutton, simulate commissioning button "
367                 "in software. The parameter value should be set to the number "
368                 "of button presses to be simulated (range is 0 to 4).",
369         },
370         {
371                 "VR",
372                 "firmware-version",
373                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ,
374                 "Firmware version of the module (read only).",
375         },
376         {
377                 "HV",
378                 "hardware-version",
379                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
380                 "Hardware version of the module (read only)."
381         },
382         {
383                 "CK",
384                 "config-code",
385                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ,
386                 "Configuration Code, that can be used as a quick "
387                 "check to determine if a node has been configured as "
388                 "desired (read-only, 0-0xFFFFFFFF)."
389         },
390         {
391                 "ER",
392                 "rf-errors",
393                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
394                 "Number of times a packet was received which contained errors "
395                 "of some sort. Read-only, saturate at 0xFFFF.",
396         },
397         {
398                 "GD",
399                 "good-packets",
400                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
401                 "Number of good received frames. Read-only, saturate at "
402                 "0xFFFF.",
403         },
404         {
405                 "RP",
406                 "rssi-pwm-timer",
407                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
408                 "RSSI PWM timer, the time in tenth of seconds that the RSSI "
409                 "output indicating signal strength will remain active after "
410                 "the last reception (1 to 0xff, default is 0x20 = 3.2 secs).",
411         },
412         {
413                 "TR",
414                 "tx-errors",
415                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
416                 "Transmission Errors, the number of MAC frames that "
417                 "exhaust MAC retries without ever receiving a MAC "
418                 "acknowledgement message. Read-only, saturate at 0xFFFF.",
419         },
420         {
421                 "TP",
422                 "temperature",
423                 XBEE_ATCMD_F_PARAM_S16 | XBEE_ATCMD_F_READ,
424                 "Temperature. Read module temperature in (tenths of ?) "
425                 "Celsius. Negatives temperatures can be returned (read-only, "
426                 "from 0xff74 [-140] to 0x0258 [600]).",
427         },
428         {
429                 "DB",
430                 "rx-signal-strength",
431                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
432                 "Received Signal Strength of the last received RF data "
433                 "packet measured in -dBm. For example if DB returns 0x60, "
434                 "then the RSSI of the last packet received was -96dBm "
435                 "(read-only)."
436         },
437         {
438                 "DC",
439                 "duty-cycle",
440                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ,
441                 "Duty Cycle. Returns a current usage percentage of the "
442                 "10% duty cycle measured over the period of 1 hour "
443                 "(read-only, from 0 to 0x64).",
444         },
445         {
446                 "RC",
447                 "rssi-for-channel", //XXX in fact it is a read with a param
448                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_WRITE,
449                 "Reads the dBm level (RSSI) of the designated "
450                 "channel.",
451         },
452         {
453                 "R#",
454                 "reset-number",
455                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ,
456                 "Tells the reason for the last module reset (0 - Power up "
457                 "reset, 2 - Watchdog reset, 3 - Software reset, 4 - Reset "
458                 "line reset, 5 - Brownout reset). Read-only.",
459         },
460         {
461                 "TA",
462                 "tx-ack-errors",
463                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
464                 "Transmit Acknowlegement Errors. Incremented once for "
465                 "each failed ack retry (read-only, from 0 to 0xFFFF).",
466         },
467         {
468                 "%V",
469                 "supply-voltage",
470                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ,
471                 "Voltage on the Vcc pin in mV (read-only, from 0 to 0xF00).",
472         },
473         {
474                 "CT",
475                 "cmd-mode-timeout",
476                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
477                 "Command Mode Timeout: the period of inactivity (no valid "
478                 "commands received) after which the RF module automatically "
479                 "exits AT Command Mode and returns to Idle Mode (2 to 0x1770, "
480                 "default is 0x64).",
481         },
482         {
483                 "CN",
484                 "exit-cmd-mode",
485                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
486                 "Exit Command Mode.",
487         },
488         {
489                 "GT",
490                 "guard-times",
491                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
492                 "Guard Times: period of silence in ms before and after the "
493                 "Command Sequence Characters of the AT Command Mode Sequence, "
494                 "used to prevent inadvertent entrance into AT Command Mode "
495                 "(0 to 0xFFFF, default is 0x3E8).",
496         },
497         {
498                 "CC",
499                 "command-chars",
500                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
501                 "Command Character used between guard times of the AT Command "
502                 "Mode Sequence (0 to 0xFF, default is 0x2B).",
503         },
504         {
505                 "ID",
506                 "network-id",
507                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
508                 "Network ID. Nodes must have the same network identifier "
509                 "to communicate (0 to 0x7FFF, default is 0x7FFF).",
510         },
511         {
512                 "NT",
513                 "ndisc-timeout",
514                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
515                 "Node Discover Timeout, time in tenth of secs a node will "
516                 "spend discovering other nodes when ND or DN is issued (0 "
517                 "to 0xFC, default is 0x82).",
518         },
519         {
520                 "NI",
521                 "node-id",
522                 XBEE_ATCMD_F_PARAM_STRING_20B | XBEE_ATCMD_F_READ |
523                 XBEE_ATCMD_F_WRITE,
524                 "Node Identifier in printable ASCII characters. This string is "
525                 "returned as part of the ATND (Network Discover) command. This "
526                 "identifier is also used with the ATDN (Destination Node) "
527                 "command. The string contains up to 20 byte ASCII string, "
528                 "default is a space character.",
529         },
530         {
531                 "DN",
532                 "disc-node",
533                 XBEE_ATCMD_F_PARAM_STRING_20B | XBEE_ATCMD_F_READ |
534                 XBEE_ATCMD_F_WRITE,
535                 /* XXX */
536                 "Resolves a Node Identifier string to a physical address "
537                 "(case sensitive). 0xFFFE and the 64bits extended address are "
538                 "returned."
539         },
540         {
541                 "ND",
542                 "network-discover",
543                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
544                 "Network Discovery, see doc", /* XXX */
545         },
546         {
547                 "NO",
548                 "ndisc-options",
549                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
550                 "Network Discovery Options, a bitfield value that changes the "
551                 "behavior of the ND command (bit0 - Append DD value, bit1 - "
552                 "Local device sends ND response frame when ND is issued). "
553                 "Default is 0."
554         },
555         {
556                 "EE",
557                 "security-enable",
558                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
559                 "Enable or disable 128-bit AES encryption (0 or 1, 0 is the "
560                 "default).",
561         },
562         {
563                 "KY", /* XXX */
564                 "security-key",
565                 XBEE_ATCMD_F_PARAM_HEXBUF_16B | XBEE_ATCMD_F_WRITE,
566                 "The 128bits security key (the command is write-only).",
567         },
568         {
569                 "MT",
570                 "bcast-multi-xmit",
571                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
572                 "Number of additional MAC-level broadcast transmissions. All "
573                 "broadcast packets are transmitted MT+1 times to ensure "
574                 "it is received (0 to 0xF, default is 3).",
575         },
576         {
577                 "RR",
578                 "unicast-retries",
579                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
580                 "Number of additional MAC-level packet delivery attempts for "
581                 "unicast transactions. If RR is non-zero, packets sent from "
582                 "the radio will request an acknowledgement, and can be resent "
583                 "up to RR times if no acknowledgement is received. (0 to 0xF, "
584                 "default is 10).",
585         },
586         {
587                 "PL",
588                 "power-level",
589                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
590                 "Power Level of RF transmitter (0 - 1mW, 1 - 23mW, 2 - 100mW, "
591                 "3 - 158 mW, 4 - 316 mW). Default is 4.",
592         },
593         {
594                 "SM",
595                 "sleep-mode",
596                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
597                 "Sleep Mode (0 - disabled, 1 - pin sleep, 4 - async cyclic "
598                 "sleep, 5 - async cyclic sleep with pin wakeup). Default "
599                 "is 0.",
600         },
601         {
602                 "SO",
603                 "sleep-options",
604                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
605                 "Sleep Options bitmask (bit8 - always wake for ST time). "
606                 "Default is 0.",
607         },
608         {
609                 "ST",
610                 "wake-time",
611                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
612                 "Wake Time: the amount of time in ms that the module will stay "
613                 "awake after receiving RF or serial data (from 0x45 to "
614                 "0x36EE80, default is 0x7D0 = 2 secs).",
615         },
616         {
617                 "SP",
618                 "sleep-period",
619                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
620                 "Sleep Period: the amount of time in 10ms unit the module will "
621                 "sleep per cycle.  For a node operating as an Indirect "
622                 "Messaging Coordinator, this command defines the amount of "
623                 "time that it will hold an indirect message for an end device. "
624                 "The coordinator will hold the message for (2.5 * SP). Range "
625                 "is from 1 to 1440000, default is 200 (2 secs).",
626         },
627         {
628                 "SN",
629                 "num-sleep-periods",
630                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
631                 "Number of Sleep Periods that must elapse between assertions "
632                 "of the ON_SLEEP line during the wake time of asynchronous "
633                 "cyclic sleep (1 to 0xFFFF, default is 1).",
634         },
635         {
636                 "WH",
637                 "wake-host",
638                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
639                 "Wake Host time. If it is set to a non-zero value, it "
640                 "specifies the time in ms that the device should allow after "
641                 "waking from sleep before sending data out the UART or "
642                 "transmitting an I/O sample. If serial characters are "
643                 "received, the WH timer is stopped immediately. Range is "
644                 "from 0 to 0xFFFF, default is 0.",
645         },
646         {
647                 NULL,
648                 NULL,
649                 0,
650                 NULL,
651         },
652 };
653
654 struct xbee_atcmd *xbee_atcmd_lookup_name(const char *atcmd_str)
655 {
656         struct xbee_atcmd *cmd;
657
658         for (cmd = &xbee_atcmd_list[0]; cmd->name != NULL; cmd++) {
659                 if (strcmp(atcmd_str, cmd->name))
660                         continue;
661                 break;
662         }
663
664         if (cmd->name == NULL) /* not found */
665                 return NULL;
666
667         return cmd;
668 }
669
670 struct xbee_atcmd *xbee_atcmd_lookup_desc(const char *desc)
671 {
672         struct xbee_atcmd *cmd;
673
674         for (cmd = &xbee_atcmd_list[0]; cmd->desc != NULL; cmd++) {
675                 if (strcmp(desc, cmd->desc))
676                         continue;
677                 break;
678         }
679
680         if (cmd->name == NULL) /* not found */
681                 return NULL;
682
683         return cmd;
684 }