xbee_proto: fix parsing hdr len
[protos/xbee-avr.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 <aversive/pgmspace.h>
29
30 #include <string.h>
31 #include <stdlib.h>
32 #include <stdio.h>
33
34 #include "xbee_atcmd.h"
35
36 prog_char atcmd0_name[] = "WR";
37 prog_char atcmd0_desc[] = "write-param";
38 prog_char atcmd0_help[] =
39         "Write parameter values to non-volatile memory.";
40
41 prog_char atcmd1_name[] = "RE";
42 prog_char atcmd1_desc[] = "restore-defaults";
43 prog_char atcmd1_help[] =
44         "Restore module parameters to factory defaults.";
45
46 prog_char atcmd2_name[] = "FR";
47 prog_char atcmd2_desc[] = "soft-reset";
48 prog_char atcmd2_help[] =
49         "Software Reset. Responds with 'OK' then performs a "
50         "reset 100ms later.";
51
52 prog_char atcmd3_name[] = "AC";
53 prog_char atcmd3_desc[] = "apply-changes";
54 prog_char atcmd3_help[] =
55         "Apply Changes without exiting command mode.";
56
57 prog_char atcmd4_name[] = "R1";
58 prog_char atcmd4_desc[] = "restore-compiled";
59 prog_char atcmd4_help[] =
60         "Restore module parameters to compiled defaults.";
61
62 prog_char atcmd5_name[] = "VL";
63 prog_char atcmd5_desc[] = "version-long";
64 prog_char atcmd5_help[] =
65         "Shows detailed version information including"
66         "application build date and time.";
67
68 prog_char atcmd6_name[] = "DH";
69 prog_char atcmd6_desc[] = "dst-addr-high";
70 prog_char atcmd6_help[] =
71         "Upper 32 bits of the 64-bit destination address (0 "
72         "to 0xFFFFFFFF, default is 0x0000FFFF).";
73
74 prog_char atcmd7_name[] = "DL";
75 prog_char atcmd7_desc[] = "dst-addr-low";
76 prog_char atcmd7_help[] =
77         "Lower 32 bits of the 64-bit destination address (0 "
78         "to 0xFFFFFFFF, default is 0x0000FFFF).";
79
80 prog_char atcmd8_name[] = "DD";
81 prog_char atcmd8_desc[] = "device-type-id";
82 prog_char atcmd8_help[] =
83         "Device Type Identifier, it can be used to differentiate "
84         "multiple XBee-based products (0 to 0xFFFFFFFF, read-only, "
85         "default is 0x40000).";
86
87 prog_char atcmd9_name[] = "SH";
88 prog_char atcmd9_desc[] = "src-addr-high";
89 prog_char atcmd9_help[] =
90         "Upper 32 bits of the 64-bit source address (read-only).";
91
92 prog_char atcmd10_name[] = "SL";
93 prog_char atcmd10_desc[] = "src-addr-low";
94 prog_char atcmd10_help[] =
95         "Lower 32 bits of the 64-bit source address (read-only).";
96
97 prog_char atcmd11_name[] = "SE";
98 prog_char atcmd11_desc[] = "src-endpoint";
99 prog_char atcmd11_help[] =
100         "The application source endpoint for all data transmissions "
101         "(0 to 0xFF, default is 0xE8).";
102
103 prog_char atcmd12_name[] = "DE";
104 prog_char atcmd12_desc[] = "dst-endpoint";
105 prog_char atcmd12_help[] =
106         "The application destination endpoint for all data "
107         "transmissions (0 to 0xFF, default is 0xE8).";
108
109 prog_char atcmd13_name[] = "CI";
110 prog_char atcmd13_desc[] = "cluster-id";
111 prog_char atcmd13_help[] =
112         "Cluster Identifier for all data transmissions (0 to 0xFFFF, "
113         "default is 0x11).";
114
115 prog_char atcmd14_name[] = "NP";
116 prog_char atcmd14_desc[] = "max-rf-payload";
117 prog_char atcmd14_help[] =
118         "Maximum RF Payload Bytes that can be sent in a unicast "
119         "transmission based on the current configuration (0 to "
120         "0xFFFF).";
121
122 prog_char atcmd15_name[] = "CE";
123 prog_char atcmd15_desc[] = "coord-end-device";
124 prog_char atcmd15_help[] =
125         "Coordinator/End Device, messaging mode of the module "
126         "(0 - Normal, 1 - Indirect coordinator, 2 - Polling, default "
127         "is 0).";
128
129 prog_char atcmd16_name[] = "AP";
130 prog_char atcmd16_desc[] = "api-mode";
131 prog_char atcmd16_help[] =
132         "API mode (0 - off, 1 - on, 2 - on with escape sequences).";
133
134 prog_char atcmd17_name[] = "AO";
135 prog_char atcmd17_desc[] = "api-output-format";
136 prog_char atcmd17_help[] =
137         "API Output Format (0 - standard [0x90 for RX], 1 - explicit "
138         "addressing [0x91 for RX]).";
139
140 prog_char atcmd18_name[] = "BD";
141 prog_char atcmd18_desc[] = "baud-rate";
142 prog_char atcmd18_help[] =
143         "Baud rate of serial interface (0-8 select preset standard "
144         "rates, and 0x39 to 0x1c9c38 select baud rate).";
145
146 prog_char atcmd19_name[] = "RO";
147 prog_char atcmd19_desc[] = "packetization-timeout";
148 prog_char atcmd19_help[] =
149         "Packetization Timeout: the inter-character silence required "
150         "before packetization specified in character times (0 to 0xFF, "
151         "default is 3).";
152
153 prog_char atcmd20_name[] = "FT";
154 prog_char atcmd20_desc[] = "flow-control-thres";
155 prog_char atcmd20_help[] =
156         "Flow Control Threshhold. De-assert CTS and/or send XOFF when "
157         "FT bytes are in the UART receive buffer. Re-assert CTS when "
158         "less than FT - 16 bytes are in the UART receive buffer (0x11 "
159         "to 0xEE, default is 0xBE).";
160
161 prog_char atcmd21_name[] = "NB";
162 prog_char atcmd21_desc[] = "parity";
163 prog_char atcmd21_help[] =
164         "Parity (0 - no parity, 1 - even parity, 2 - odd parity, 3 - "
165         "forced high parity, 4 - forced low parity). Default is 0.";
166
167 prog_char atcmd22_name[] = "D7";
168 prog_char atcmd22_desc[] = "dio7";
169 prog_char atcmd22_help[] =
170         "DIO7 Configuration (0 - unmonitored input, 1 - CTS, 3 - "
171         "digital input, 4 - digital output low, 5 - digital output "
172         "high, 6 - RS-485 low Tx, 7 - RS-485 high Tx). Default is "
173         "0.";
174
175 prog_char atcmd23_name[] = "D6";
176 prog_char atcmd23_desc[] = "dio6";
177 prog_char atcmd23_help[] =
178         "DIO6 Configuration (0 - unmonitored input, 1 - RTS, 3 - "
179         "digital input, 4 - digital output low, 5 - digital output "
180         "high). Default is 0.";
181
182 prog_char atcmd24_name[] = "P0";
183 prog_char atcmd24_desc[] = "dio10-pwm0";
184 prog_char atcmd24_help[] =
185         "DIO10/PWM0 Configuration. (0 - unmonitored input, 1 - RSSI, 2 "
186         "- PWM0, 3 - digital input, 4 - digital output low, 5 - "
187         "digital output high). Default is 1.";
188
189 prog_char atcmd25_name[] = "P1";
190 prog_char atcmd25_desc[] = "dio11-pwm1";
191 prog_char atcmd25_help[] =
192         "DIO11/PWM1 Configuration. (0 - unmonitored input, 2 "
193         "- PWM1, 3 - digital input, 4 - digital output low, 5 - "
194         "digital output high). Default is 0.";
195
196 prog_char atcmd26_name[] = "P2";
197 prog_char atcmd26_desc[] = "dio12";
198 prog_char atcmd26_help[] =
199         "DIO12 Configuration. (0 - unmonitored input, "
200         "3 - digital input, 4 - digital output low, 5 - "
201         "digital output high). Default is 0.";
202
203 prog_char atcmd27_name[] = "RP";
204 prog_char atcmd27_desc[] = "rssi-pwm";
205 prog_char atcmd27_help[] =
206         "Time RSSI signal will be output after last transmission. "
207         "When RP[] = 0xFF, output will always be on (0 - 0xFF, default "
208         "is 0x28[] = 4 seconds).";
209
210 prog_char atcmd28_name[] = "1S";
211 prog_char atcmd28_desc[] = "sensor-sample";
212 prog_char atcmd28_help[] =
213         "Forces a sample to be taken on an XBee Sensor device.";
214
215 prog_char atcmd29_name[] = "D0";
216 prog_char atcmd29_desc[] = "dio0-ad0";
217 prog_char atcmd29_help[] =
218         "AD0/DIO0 Configuration. (0 - unmonitored input, 1 - "
219         "commission button enabled, 2 - analog input, 3 - digital "
220         "input, 4 - digital output low, 5 - digital output high). "
221         "Default is 1.";
222
223 prog_char atcmd30_name[] = "D1";
224 prog_char atcmd30_desc[] = "dio1-ad1";
225 prog_char atcmd30_help[] =
226         "AD1/DIO1 Configuration. (0 - unmonitored input, "
227         "2 - analog input, 3 - digital input, 4 - digital output "
228         "low, 5 - digital output high). Default is 0.";
229
230 prog_char atcmd31_name[] = "D2";
231 prog_char atcmd31_desc[] = "dio2-ad2";
232 prog_char atcmd31_help[] =
233         "AD2/DIO2 Configuration. (0 - unmonitored input, "
234         "2 - analog input, 3 - digital input, 4 - digital output "
235         "low, 5 - digital output high). Default is 0.";
236
237 prog_char atcmd32_name[] = "D3";
238 prog_char atcmd32_desc[] = "dio3-ad3";
239 prog_char atcmd32_help[] =
240         "AD3/DIO3 Configuration. (0 - unmonitored input, "
241         "2 - analog input, 3 - digital input, 4 - digital output "
242         "low, 5 - digital output high). Default is 0.";
243
244 prog_char atcmd33_name[] = "D4";
245 prog_char atcmd33_desc[] = "dio4-ad4";
246 prog_char atcmd33_help[] =
247         "AD4/DIO4 Configuration. (0 - unmonitored input, "
248         "2 - analog input, 3 - digital input, 4 - digital output "
249         "low, 5 - digital output high). Default is 0.";
250
251 prog_char atcmd34_name[] = "D5";
252 prog_char atcmd34_desc[] = "dio5-ad5";
253 prog_char atcmd34_help[] =
254         "AD4/DIO4 Configuration. (0 - unmonitored input, 1 - LED, "
255         "2 - analog input, 3 - digital input, 4 - digital output "
256         "low, 5 - digital output high). Default is 1.";
257
258 prog_char atcmd35_name[] = "D8";
259 prog_char atcmd35_desc[] = "dio8-sleep-rq";
260 prog_char atcmd35_help[] =
261         "DIO8/SLEEP_RQ Configuration. (0 - unmonitored input, 1 - LED, "
262         "2 - analog input, 3 - digital input, 4 - digital output "
263         "low, 5 - digital output high). Default is 0. When used as "
264         "SLEEP_RQ, the D8 parameter should be configured in mode 0 "
265         "or 3.";
266
267 prog_char atcmd36_name[] = "D9";
268 prog_char atcmd36_desc[] = "dio9-on-sleep";
269 prog_char atcmd36_help[] =
270         "DIO9/ON_SLEEP Configuration. (0 - unmonitored input, 1 - "
271         "ON/SLEEP, 2 - analog input, 3 - digital input, 4 - digital "
272         "output low, 5 - digital output high). Default is ?.";
273
274 prog_char atcmd37_name[] = "PR";
275 prog_char atcmd37_desc[] = "pull-up-resistor";
276 prog_char atcmd37_help[] =
277         "Pull-up Resistor. Bit field that configures the internal "
278         "pull-up resistors for the I/O lines (bit set = pull-up "
279         "enabled). Range is from 0 to 0x1FFF, default is 0x1FFF.";
280
281 prog_char atcmd38_name[] = "M0";
282 prog_char atcmd38_desc[] = "pwm0-out-level";
283 prog_char atcmd38_help[] =
284         "PWM0 Output Level. The line should be configured as a PWM "
285         "output using the P0 command (0 to 0x3FF, default is 0).";
286
287 prog_char atcmd39_name[] = "M1";
288 prog_char atcmd39_desc[] = "pwm1-out-level";
289 prog_char atcmd39_help[] =
290         "PWM1 Output Level. The line should be configured as a PWM "
291         "output using the P1 command (0 to 0x3FF, default is 0).";
292
293 prog_char atcmd40_name[] = "LT";
294 prog_char atcmd40_desc[] = "led-blink-time";
295 prog_char atcmd40_help[] =
296         "Associate LED Blink Time (should be enabled through D5 ";
297
298 prog_char atcmd41_name[] = "IS";
299 prog_char atcmd41_desc[] = "force-sample";
300 prog_char atcmd41_help[] =
301         "Forces a read of all enabled digital and "
302         "analog input lines.";
303
304 prog_char atcmd42_name[] = "IC";
305 prog_char atcmd42_desc[] = "digital-change-detect";
306 prog_char atcmd42_help[] =
307         "I/O Digital Change Detection. If a pin is enabled as a "
308         "digital input/output, the IC command can be used to "
309         "force an immediate I/O sample transmission when the DIO "
310         "state changes. IC is a bitmask, range is 0 to 0xFFFF, "
311         "default is 0";
312
313 prog_char atcmd43_name[] = "IR";
314 prog_char atcmd43_desc[] = "io-sample-rate";
315 prog_char atcmd43_help[] =
316         "IO Sample Rate for periodic sampling. If zero, periodic "
317         "sampling is disabled. Else the value is in milliseconds "
318         "(range 0 to 0xFFFF, default is 0).";
319
320 prog_char atcmd44_name[] = "CB";
321 prog_char atcmd44_desc[] = "comissioning-button";
322 prog_char atcmd44_help[] =
323         "Commissioning Pushbutton, simulate commissioning button "
324         "in software. The parameter value should be set to the number "
325         "of button presses to be simulated (range is 0 to 4).";
326
327 prog_char atcmd45_name[] = "VR";
328 prog_char atcmd45_desc[] = "firmware-version";
329 prog_char atcmd45_help[] =
330         "Firmware version of the module (read only).";
331
332 prog_char atcmd46_name[] = "HV";
333 prog_char atcmd46_desc[] = "hardware-version";
334 prog_char atcmd46_help[] =
335         "Hardware version of the module (read only).";
336
337 prog_char atcmd47_name[] = "CK";
338 prog_char atcmd47_desc[] = "config-code";
339 prog_char atcmd47_help[] =
340         "Configuration Code, that can be used as a quick "
341         "check to determine if a node has been configured as "
342         "desired (read-only, 0-0xFFFFFFFF).";
343
344 prog_char atcmd48_name[] = "ER";
345 prog_char atcmd48_desc[] = "rf-errors";
346 prog_char atcmd48_help[] =
347         "Number of times a packet was received which contained errors "
348         "of some sort. Read-only, saturate at 0xFFFF.";
349
350 prog_char atcmd49_name[] = "GD";
351 prog_char atcmd49_desc[] = "good-packets";
352 prog_char atcmd49_help[] =
353         "Number of good received frames. Read-only, saturate at "
354         "0xFFFF.";
355
356 prog_char atcmd50_name[] = "RP";
357 prog_char atcmd50_desc[] = "rssi-pwm-timer";
358 prog_char atcmd50_help[] =
359         "RSSI PWM timer, the time in tenth of seconds that the RSSI "
360         "output indicating signal strength will remain active after "
361         "the last reception (1 to 0xff, default is 0x20 = 3.2 secs).";
362
363 prog_char atcmd51_name[] = "TR";
364 prog_char atcmd51_desc[] = "tx-errors";
365 prog_char atcmd51_help[] =
366         "Transmission Errors, the number of MAC frames that "
367         "exhaust MAC retries without ever receiving a MAC "
368         "acknowledgement message. Read-only, saturate at 0xFFFF.";
369
370 prog_char atcmd52_name[] = "TP";
371 prog_char atcmd52_desc[] = "temperature";
372 prog_char atcmd52_help[] =
373         "Temperature. Read module temperature in (tenths of ?) "
374         "Celsius. Negatives temperatures can be returned (read-only, "
375         "from 0xff74 [-140] to 0x0258 [600]).";
376
377 prog_char atcmd53_name[] = "DB";
378 prog_char atcmd53_desc[] = "rx-signal-strength";
379 prog_char atcmd53_help[] =
380         "Received Signal Strength of the last received RF data "
381         "packet measured in -dBm. For example if DB returns 0x60, "
382         "then the RSSI of the last packet received was -96dBm "
383         "(read-only).";
384
385 prog_char atcmd54_name[] = "DC";
386 prog_char atcmd54_desc[] = "duty-cycle";
387 prog_char atcmd54_help[] =
388         "Duty Cycle. Returns a current usage percentage of the "
389         "10% duty cycle measured over the period of 1 hour "
390         "(read-only, from 0 to 0x64).";
391
392 prog_char atcmd55_name[] = "RC";
393 prog_char atcmd55_desc[] = "rssi-for-channel";
394 prog_char atcmd55_help[] =
395         "Reads the dBm level (RSSI) of the designated "
396         "channel.";
397
398 prog_char atcmd56_name[] = "R#";
399 prog_char atcmd56_desc[] = "reset-number";
400 prog_char atcmd56_help[] =
401         "Tells the reason for the last module reset (0 - Power up "
402         "reset, 2 - Watchdog reset, 3 - Software reset, 4 - Reset "
403         "line reset, 5 - Brownout reset). Read-only.";
404
405 prog_char atcmd57_name[] = "TA";
406 prog_char atcmd57_desc[] = "tx-ack-errors";
407 prog_char atcmd57_help[] =
408         "Transmit Acknowlegement Errors. Incremented once for "
409         "each failed ack retry (read-only, from 0 to 0xFFFF).";
410
411 prog_char atcmd58_name[] = "%V";
412 prog_char atcmd58_desc[] = "supply-voltage";
413 prog_char atcmd58_help[] =
414         "Voltage on the Vcc pin in mV (read-only, from 0 to 0xF00).";
415
416 prog_char atcmd59_name[] = "CT";
417 prog_char atcmd59_desc[] = "cmd-mode-timeout";
418 prog_char atcmd59_help[] =
419         "Command Mode Timeout: the period of inactivity (no valid "
420         "commands received) after which the RF module automatically "
421         "exits AT Command Mode and returns to Idle Mode (2 to 0x1770, "
422         "default is 0x64).";
423
424 prog_char atcmd60_name[] = "CN";
425 prog_char atcmd60_desc[] = "exit-cmd-mode";
426 prog_char atcmd60_help[] =
427         "Exit Command Mode.";
428
429 prog_char atcmd61_name[] = "GT";
430 prog_char atcmd61_desc[] = "guard-times";
431 prog_char atcmd61_help[] =
432         "Guard Times: period of silence in ms before and after the "
433         "Command Sequence Characters of the AT Command Mode Sequence, "
434         "used to prevent inadvertent entrance into AT Command Mode "
435         "(0 to 0xFFFF, default is 0x3E8).";
436
437 prog_char atcmd62_name[] = "CC";
438 prog_char atcmd62_desc[] = "command-chars";
439 prog_char atcmd62_help[] =
440         "Command Character used between guard times of the AT Command "
441         "Mode Sequence (0 to 0xFF, default is 0x2B).";
442
443 prog_char atcmd63_name[] = "ID";
444 prog_char atcmd63_desc[] = "network-id";
445 prog_char atcmd63_help[] =
446         "Network ID. Nodes must have the same network identifier "
447         "to communicate (0 to 0x7FFF, default is 0x7FFF).";
448
449 prog_char atcmd64_name[] = "NT";
450 prog_char atcmd64_desc[] = "ndisc-timeout";
451 prog_char atcmd64_help[] =
452         "Node Discover Timeout, time in tenth of secs a node will "
453         "spend discovering other nodes when ND or DN is issued (0 "
454         "to 0xFC, default is 0x82).";
455
456 prog_char atcmd65_name[] = "NI";
457 prog_char atcmd65_desc[] = "node-id";
458 prog_char atcmd65_help[] =
459         "Node Identifier in printable ASCII characters. This string is "
460         "returned as part of the ATND (Network Discover) command. This "
461         "identifier is also used with the ATDN (Destination Node) "
462         "command. The string contains up to 20 byte ASCII string, "
463         "default is a space character.";
464
465 prog_char atcmd66_name[] = "DN";
466 prog_char atcmd66_desc[] = "disc-node";
467 prog_char atcmd66_help[] = /* XXX */
468         "Resolves a Node Identifier string to a physical address "
469         "(case sensitive). 0xFFFE and the 64bits extended address are "
470         "returned.";
471
472 prog_char atcmd67_name[] = "ND";
473 prog_char atcmd67_desc[] = "network-discover";
474 prog_char atcmd67_help[] = "Network Discovery, see doc"; /* XXX */
475
476 prog_char atcmd68_name[] = "NO";
477 prog_char atcmd68_desc[] = "ndisc-options";
478 prog_char atcmd68_help[] =
479         "Network Discovery Options, a bitfield value that changes the "
480         "behavior of the ND command (bit0 - Append DD value, bit1 - "
481         "Local device sends ND response frame when ND is issued). "
482         "Default is 0.";
483
484 prog_char atcmd69_name[] = "EE";
485 prog_char atcmd69_desc[] = "security enable";
486 prog_char atcmd69_help[] =
487         "Enable or disable 128-bit AES encryption (0 or 1, 0 is the "
488         "default).";
489
490 prog_char atcmd70_name[] = "KY"; /* XXX */;
491 prog_char atcmd70_desc[] = "security-key";
492 prog_char atcmd70_help[] =
493         "The 128bits security key (the command is write-only).";
494
495 prog_char atcmd71_name[] = "MT";
496 prog_char atcmd71_desc[] = "bcast-multi-xmit";
497 prog_char atcmd71_help[] =
498         "Number of additional MAC-level broadcast transmissions. All "
499         "broadcast packets are transmitted MT+1 times to ensure "
500         "it is received (0 to 0xF, default is 3).";
501
502 prog_char atcmd72_name[] = "RR";
503 prog_char atcmd72_desc[] = "unicast-retries";
504 prog_char atcmd72_help[] =
505         "Number of additional MAC-level packet delivery attempts for "
506         "unicast transactions. If RR is non-zero, packets sent from "
507         "the radio will request an acknowledgement, and can be resent "
508         "up to RR times if no acknowledgement is received. (0 to 0xF, "
509         "default is 10).";
510
511 prog_char atcmd73_name[] = "PL";
512 prog_char atcmd73_desc[] = "power-level";
513 prog_char atcmd73_help[] =
514         "Power Level of RF transmitter (0 - 1mW, 1 - 23mW, 2 - 100mW, "
515         "3 - 158 mW, 4 - 316 mW). Default is 4.";
516
517 prog_char atcmd74_name[] = "SM";
518 prog_char atcmd74_desc[] = "sleep-mode";
519 prog_char atcmd74_help[] =
520         "Sleep Mode (0 - disabled, 1 - pin sleep, 4 - async cyclic "
521         "sleep, 5 - async cyclic sleep with pin wakeup). Default "
522         "is 0.";
523
524 prog_char atcmd75_name[] = "SO";
525 prog_char atcmd75_desc[] = "sleep-options";
526 prog_char atcmd75_help[] =
527         "Sleep Options bitmask (bit8 - always wake for ST time). "
528         "Default is 0.";
529
530 prog_char atcmd76_name[] = "ST";
531 prog_char atcmd76_desc[] = "wake-time";
532 prog_char atcmd76_help[] =
533         "Wake Time: the amount of time in ms that the module will stay "
534         "awake after receiving RF or serial data (from 0x45 to "
535         "0x36EE80, default is 0x7D0 = 2 secs).";
536
537 prog_char atcmd77_name[] = "SP";
538 prog_char atcmd77_desc[] = "sleep-period";
539 prog_char atcmd77_help[] =
540         "Sleep Period: the amount of time in 10ms unit the module will "
541         "sleep per cycle. For a node operating as an Indirect "
542         "Messaging Coordinator, this command defines the amount of "
543         "time that it will hold an indirect message for an end device. "
544         "The coordinator will hold the message for (2.5 * SP). Range "
545         "is from 1 to 1440000, default is 200 (2 secs).";
546
547 prog_char atcmd78_name[] = "SN";
548 prog_char atcmd78_desc[] = "num-sleep-periods";
549 prog_char atcmd78_help[] =
550         "Number of Sleep Periods that must elapse between assertions "
551         "of the ON_SLEEP line during the wake time of asynchronous "
552         "cyclic sleep (1 to 0xFFFF, default is 1).";
553
554 prog_char atcmd79_name[] = "WH";
555 prog_char atcmd79_desc[] = "wake-host";
556 prog_char atcmd79_help[] = "Wake Host time. If it is set to a non-zero value, it "
557         "specifies the time in ms that the device should allow after "
558         "waking from sleep before sending data out the UART or "
559         "transmitting an I/O sample. If serial characters are "
560         "received, the WH timer is stopped immediately. Range is "
561         "from 0 to 0xFFFF, default is 0.";
562
563 struct xbee_atcmd_pgm xbee_atcmd_list[] = {
564         {
565                 /* "WR" */
566                 atcmd0_name,
567                 atcmd0_desc,
568                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
569                 atcmd0_help,
570         },
571         {
572                 /* "RE" */
573                 atcmd1_name,
574                 atcmd1_desc,
575                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
576                 atcmd1_help,
577         },
578         {
579                 /* "FR" */
580                 atcmd2_name,
581                 atcmd2_desc,
582                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
583                 atcmd2_help,
584         },
585         {
586                 /* "AC" */
587                 atcmd3_name,
588                 atcmd3_desc,
589                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
590                 atcmd3_help,
591         },
592         {
593                 /* "R1" */
594                 atcmd4_name,
595                 atcmd4_desc,
596                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
597                 atcmd4_help,
598         },
599         {
600                 /* "VL" */
601                 atcmd5_name,
602                 atcmd5_desc,
603                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
604                 atcmd5_help,
605         },
606         {
607                 /* "DH" */
608                 atcmd6_name,
609                 atcmd6_desc,
610                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
611                 atcmd6_help,
612         },
613         {
614                 /* "DL" */
615                 atcmd7_name,
616                 atcmd7_desc,
617                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
618                 atcmd7_help,
619         },
620         {
621                 /* "DD" */
622                 atcmd8_name,
623                 atcmd8_desc,
624                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ,
625                 atcmd8_help,
626         },
627         {
628                 /* "SH" */
629                 atcmd9_name,
630                 atcmd9_desc,
631                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ,
632                 atcmd9_help,
633         },
634         {
635                 /* "SL" */
636                 atcmd10_name,
637                 atcmd10_desc,
638                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ,
639                 atcmd10_help,
640         },
641         {
642                 /* "SE" */
643                 atcmd11_name,
644                 atcmd11_desc,
645                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
646                 atcmd11_help,
647         },
648         {
649                 /* "DE" */
650                 atcmd12_name,
651                 atcmd12_desc,
652                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
653                 atcmd12_help,
654         },
655         {
656                 /* "CI" */
657                 atcmd13_name,
658                 atcmd13_desc,
659                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
660                 atcmd13_help,
661         },
662         {
663                 /* "NP" */
664                 atcmd14_name,
665                 atcmd14_desc,
666                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
667                 atcmd14_help,
668         },
669         {
670                 /* "CE" */
671                 atcmd15_name,
672                 atcmd15_desc,
673                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
674                 atcmd15_help,
675         },
676         {
677                 /* "AP" */
678                 atcmd16_name,
679                 atcmd16_desc,
680                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
681                 atcmd16_help,
682         },
683         {
684                 /* "AO" */
685                 atcmd17_name,
686                 atcmd17_desc,
687                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
688                 atcmd17_help,
689         },
690         {
691                 /* "BD" */
692                 atcmd18_name,
693                 atcmd18_desc,
694                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
695                 atcmd18_help,
696         },
697         {
698                 /* "RO" */
699                 atcmd19_name,
700                 atcmd19_desc,
701                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
702                 atcmd19_help,
703         },
704         {
705                 /* "FT" */
706                 atcmd20_name,
707                 atcmd20_desc,
708                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
709                 atcmd20_help,
710         },
711         {
712                 /* "NB" */
713                 atcmd21_name,
714                 atcmd21_desc,
715                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
716                 atcmd21_help,
717         },
718         {
719                 /* "D7" */
720                 atcmd22_name,
721                 atcmd22_desc,
722                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
723                 atcmd22_help,
724         },
725         {
726                 /* "D6" */
727                 atcmd23_name,
728                 atcmd23_desc,
729                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
730                 atcmd23_help,
731         },
732         {
733                 /* "P0" */
734                 atcmd24_name,
735                 atcmd24_desc,
736                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
737                 atcmd24_help,
738         },
739         {
740                 /* "P1" */
741                 atcmd25_name,
742                 atcmd25_desc,
743                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
744                 atcmd25_help,
745         },
746         {
747                 /* "P2" */
748                 atcmd26_name,
749                 atcmd26_desc,
750                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
751                 atcmd26_help,
752         },
753         {
754                 /* "RP" */
755                 atcmd27_name,
756                 atcmd27_desc,
757                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
758                 atcmd27_help,
759         },
760         {
761                 /* "1S" */
762                 atcmd28_name,
763                 atcmd28_desc,
764                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
765                 atcmd28_help,
766         },
767         {
768                 /* "D0" */
769                 atcmd29_name,
770                 atcmd29_desc,
771                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
772                 atcmd29_help,
773         },
774         {
775                 /* "D1" */
776                 atcmd30_name,
777                 atcmd30_desc,
778                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
779                 atcmd30_help,
780         },
781         {
782                 /* "D2" */
783                 atcmd31_name,
784                 atcmd31_desc,
785                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
786                 atcmd31_help,
787         },
788         {
789                 /* "D3" */
790                 atcmd32_name,
791                 atcmd32_desc,
792                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
793                 atcmd32_help,
794         },
795         {
796                 /* "D4" */
797                 atcmd33_name,
798                 atcmd33_desc,
799                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
800                 atcmd33_help,
801         },
802         {
803                 /* "D5" */
804                 atcmd34_name,
805                 atcmd34_desc,
806                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
807                 atcmd34_help,
808         },
809         {
810                 /* "D8" */
811                 atcmd35_name,
812                 atcmd35_desc,
813                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
814                 atcmd35_help,
815         },
816         {
817                 /* "D9" */
818                 atcmd36_name,
819                 atcmd36_desc,
820                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
821                 atcmd36_help,
822         },
823         {
824                 /* "PR" */
825                 atcmd37_name,
826                 atcmd37_desc,
827                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
828                 atcmd37_help,
829         },
830         {
831                 /* "M0" */
832                 atcmd38_name,
833                 atcmd38_desc,
834                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
835                 atcmd38_help,
836         },
837         {
838                 /* "M1" */
839                 atcmd39_name,
840                 atcmd39_desc,
841                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
842                 atcmd39_help,
843         },
844         {
845                 /* "LT" */
846                 atcmd40_name,
847                 atcmd40_desc,
848                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
849                 atcmd40_help,
850         },
851         {
852                 /* "IS" */
853                 atcmd41_name,
854                 atcmd41_desc,
855                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
856                 atcmd41_help,
857         },
858         {
859                 /* "IC" */
860                 atcmd42_name,
861                 atcmd42_desc,
862                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
863                 atcmd42_help,
864         },
865         {
866                 /* "IR" */
867                 atcmd43_name,
868                 atcmd43_desc,
869                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
870                 atcmd43_help,
871         },
872         {
873                 /* "CB" */
874                 atcmd44_name,
875                 atcmd44_desc,
876                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
877                 atcmd44_help,
878         },
879         {
880                 /* "VR" */
881                 atcmd45_name,
882                 atcmd45_desc,
883                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ,
884                 atcmd45_help,
885         },
886         {
887                 /* "HV" */
888                 atcmd46_name,
889                 atcmd46_desc,
890                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
891                 atcmd46_help,
892         },
893         {
894                 /* "CK" */
895                 atcmd47_name,
896                 atcmd47_desc,
897                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ,
898                 atcmd47_help,
899         },
900         {
901                 /* "ER" */
902                 atcmd48_name,
903                 atcmd48_desc,
904                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
905                 atcmd48_help,
906         },
907         {
908                 /* "GD" */
909                 atcmd49_name,
910                 atcmd49_desc,
911                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
912                 atcmd49_help,
913         },
914         {
915                 /* "RP" */
916                 atcmd50_name,
917                 atcmd50_desc,
918                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
919                 atcmd50_help,
920         },
921         {
922                 /* "TR" */
923                 atcmd51_name,
924                 atcmd51_desc,
925                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
926                 atcmd51_help,
927         },
928         {
929                 /* "TP" */
930                 atcmd52_name,
931                 atcmd52_desc,
932                 XBEE_ATCMD_F_PARAM_S16 | XBEE_ATCMD_F_READ,
933                 atcmd52_help,
934         },
935         {
936                 /* "DB" */
937                 atcmd53_name,
938                 atcmd53_desc,
939                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ,
940                 atcmd53_help,
941         },
942         {
943                 /* "DC" */
944                 atcmd54_name,
945                 atcmd54_desc,
946                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ,
947                 atcmd54_help,
948         },
949         {
950                 /* "RC" */
951                 atcmd55_name,
952                 atcmd55_desc,
953                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ,
954                 atcmd55_help,
955         },
956         {
957                 /* "R#" */
958                 atcmd56_name,
959                 atcmd56_desc,
960                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ,
961                 atcmd56_help,
962         },
963         {
964                 /* "TA" */
965                 atcmd57_name,
966                 atcmd57_desc,
967                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ,
968                 atcmd57_help,
969         },
970         {
971                 /* "%V" */
972                 atcmd58_name,
973                 atcmd58_desc,
974                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ,
975                 atcmd58_help,
976         },
977         {
978                 /* "CT" */
979                 atcmd59_name,
980                 atcmd59_desc,
981                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
982                 atcmd59_help,
983         },
984         {
985                 /* "CN" */
986                 atcmd60_name,
987                 atcmd60_desc,
988                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
989                 atcmd60_help,
990         },
991         {
992                 /* "GT" */
993                 atcmd61_name,
994                 atcmd61_desc,
995                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
996                 atcmd61_help,
997         },
998         {
999                 /* "CC" */
1000                 atcmd62_name,
1001                 atcmd62_desc,
1002                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1003                 atcmd62_help,
1004         },
1005         {
1006                 /* "ID" */
1007                 atcmd63_name,
1008                 atcmd63_desc,
1009                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1010                 atcmd63_help,
1011         },
1012         {
1013                 /* "NT" */
1014                 atcmd64_name,
1015                 atcmd64_desc,
1016                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1017                 atcmd64_help,
1018         },
1019         {
1020                 /* "NI" */
1021                 atcmd65_name,
1022                 atcmd65_desc,
1023                 XBEE_ATCMD_F_PARAM_STRING_20B | XBEE_ATCMD_F_READ |
1024                 XBEE_ATCMD_F_WRITE,
1025                 atcmd65_help,
1026         },
1027         {
1028                 /* "DN" */
1029                 atcmd66_name,
1030                 atcmd66_desc,
1031                 XBEE_ATCMD_F_PARAM_STRING_20B | XBEE_ATCMD_F_READ |
1032                 XBEE_ATCMD_F_WRITE,
1033                 atcmd66_help,
1034         },
1035         {
1036                 /* "ND" */
1037                 atcmd67_name,
1038                 atcmd67_desc,
1039                 XBEE_ATCMD_F_PARAM_NONE | XBEE_ATCMD_F_WRITE,
1040                 atcmd67_help,
1041         },
1042         {
1043                 /* "NO" */
1044                 atcmd68_name,
1045                 atcmd68_desc,
1046                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1047                 atcmd68_help,
1048         },
1049         {
1050                 /* "EE" */
1051                 atcmd69_name,
1052                 atcmd69_desc,
1053                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1054                 atcmd69_help,
1055         },
1056         {
1057                 /* "KY"  XXX */
1058                 atcmd70_name,
1059                 atcmd70_desc,
1060                 XBEE_ATCMD_F_PARAM_HEXBUF_16B | XBEE_ATCMD_F_WRITE,
1061                 atcmd70_help,
1062         },
1063         {
1064                 /* "MT" */
1065                 atcmd71_name,
1066                 atcmd71_desc,
1067                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1068                 atcmd71_help,
1069         },
1070         {
1071                 /* "RR" */
1072                 atcmd72_name,
1073                 atcmd72_desc,
1074                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1075                 atcmd72_help,
1076         },
1077         {
1078                 /* "PL" */
1079                 atcmd73_name,
1080                 atcmd73_desc,
1081                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1082                 atcmd73_help,
1083         },
1084         {
1085                 /* "SM" */
1086                 atcmd74_name,
1087                 atcmd74_desc,
1088                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1089                 atcmd74_help,
1090         },
1091         {
1092                 /* "SO" */
1093                 atcmd75_name,
1094                 atcmd75_desc,
1095                 XBEE_ATCMD_F_PARAM_U8 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1096                 atcmd75_help,
1097         },
1098         {
1099                 /* "ST" */
1100                 atcmd76_name,
1101                 atcmd76_desc,
1102                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1103                 atcmd76_help,
1104         },
1105         {
1106                 /* "SP" */
1107                 atcmd77_name,
1108                 atcmd77_desc,
1109                 XBEE_ATCMD_F_PARAM_U32 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1110                 atcmd77_help,
1111         },
1112         {
1113                 /* "SN" */
1114                 atcmd78_name,
1115                 atcmd78_desc,
1116                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1117                 atcmd78_help,
1118         },
1119         {
1120                 /* "WH" */
1121                 atcmd79_name,
1122                 atcmd79_desc,
1123                 XBEE_ATCMD_F_PARAM_U16 | XBEE_ATCMD_F_READ | XBEE_ATCMD_F_WRITE,
1124                 atcmd79_help,
1125         },
1126         {
1127                 NULL,
1128                 NULL,
1129                 0,
1130                 NULL,
1131         },
1132 };
1133
1134 struct xbee_atcmd_pgm *xbee_atcmd_lookup_name(const char *atcmd_str)
1135 {
1136         struct xbee_atcmd_pgm *cmd;
1137         struct xbee_atcmd copy;
1138
1139         for (cmd = &xbee_atcmd_list[0], memcpy_P(&copy, cmd, sizeof(copy));
1140              copy.name != NULL;
1141              cmd++, memcpy_P(&copy, cmd, sizeof(copy))) {
1142
1143                 if (!strcmp_P(atcmd_str, copy.name))
1144                         break;
1145         }
1146
1147         if (copy.name == NULL) /* not found */
1148                 return NULL;
1149
1150         return cmd;
1151 }
1152
1153 struct xbee_atcmd_pgm *xbee_atcmd_lookup_desc(const char *desc)
1154 {
1155         struct xbee_atcmd_pgm *cmd;
1156         struct xbee_atcmd copy;
1157
1158         for (cmd = &xbee_atcmd_list[0], memcpy_P(&copy, cmd, sizeof(copy));
1159              copy.name != NULL;
1160              cmd++, memcpy_P(&copy, cmd, sizeof(copy))) {
1161                 if (!strcmp_P(desc, copy.desc))
1162                         break;
1163         }
1164         if (copy.name == NULL) /* not found */
1165                 return NULL;
1166
1167         return cmd;
1168 }