Software Overview  |  Sitemap  |  Downloads  |  Developers  |  Forums
Small_clear_logo_llc

XBee Device Shared Methods

These methods are shared among XBee Devices. They will run on any XBee Device in the system, whether it's wired or wirelessly connected. For most systems, one won't need to use these methods, as the default configuration set up by the Virtual Wiring system works well. These methods are good for doing lower level device configuration, control and monitoring, and they are useful if you want to learn more about how XBees work. You can run these methods within your Scripts or from the Console.

AT Command Set Methods

AT commands are for probing and configuring the XBee network, checking signal strength and integrity, reading and writing the digital I/O pins, configuring the digital and analog input pins, setting up sampling, resetting individual devices and the network, and configuring the serial interfaces. See the XBee module reference manual for details on the command set.

do_AT method:

The do_AT method runs an XBee "AT" command and returns the result. It takes the AT command to run as its first parameter. Any following parameters are the parameters that the AT command uses. The result value is an array, where the first byte is the AT command status (0 means OK), and the following bytes are the value returned by the command. For more information on the AT command status bytes, see the XBee module reference manual.

As an example, the AT "NI" command returns the "node identifier" of an XBee device or, if a string is provided, sets the node identifier of the device. To read the node identifier of a device with the ID "coordinator" from the Console:

poke "coordinator", "do_AT \"NI\""

If the node identfier were "XSTICK", the return value would be:

[true,[0,88,83,84,73,67,75]]

The return array starts with 0, the command was OK, and six bytes of ASCII characters meaning: 'X', 'S', 'T', 'I', 'C', 'K'. To change the name of the "coordinator" from "XSTICK" to "COORDINATOR":

poke "coordinator", "do_AT \"NI\", \"COORDINATOR\""

The console returns:

[true,[0]]

write_AT method:

The write_AT method is similar to the do_AT method, except that it returns immediately without waiting for the result of its AT command. The method is useful if the result will be slow, as in a node discover(ND) command, or if you want to see a result pretty printed by the system's packet parser. If the write_AT command succeeds, its return value will be something other than nil or false.

Here, instead of running the do_AT command to learn a node's identifier, we'll run the write_AT command:

poke "coordinator", "write_AT \"NI\""
[true,16]

We can see that the result of the write_AT command (16) is not nil or false, so submitting the write_AT command to the XBee was successful. Since the write_AT command does not wait for the XBee's return value, we don't if the NI command was successful.

When the result of the NI command does come back from the XBee, it will be sent to the Log. If we go to the Log page, the last line will look something like:

status: "AT_RSP: (0x7E) L=0x0010 API=0x88 ID=0x13 CMD=NI STAT=OK RESP=0x434F4F5244494E41544F52(COORDINATOR) CHK=0x89"

Here, we see the NI return packet pretty printed. In the RESP (response) part of the packet, you can see the return value is "COORDINATOR". There are other packet fields as well. The packet start byte (always 0x7E), the length (0x10), API (0x88), packet ID (0x13), AT command (NI), return status (OK - a zero), and a check byte (0x89).

Catalina Computing, LLC.

Copyright © Catalina Computing, LLC. (2013-2017)




Page last updated: Fri May 8 13:01:47 2015 (UTC)