Going all the way back to where we started with
check_radio(), that method will return the 16-bit “MY”
address if a radio is detected (present, correct baud rate,
configured for API). If there is a problem, -1 will be
returned to the caller.

The only other method of note in the XBee object is
used for setting AT values, but I think we've covered
enough details about XBee API packets by now that the
code will be easy to understand. So, we don't need to
discuss it here.

Reading the XBee Profile

To understand how this works, let's have a look at a
response frame from the “MY” AT command:

7E 00 07 88 01 4D 59 00 BA 5E B8

The AT command string is returned in the packet
Let's start with a simple demo that reads connection
parameters from the connected XBee — you'll see
something as in Figure 1. The program looks for a radio
and if found, prints the primary values related to wireless
connections.

(bytes five and six), followed by a status byte which should
be zero. What follows is the value returned and the
payload checksum.

At the heart of this little demo is a routine that
retrieves an AT value and puts it onto the terminal at a
specific location. Here's a sample of that:
As you can see, there are five bytes in the payload in
addition to the returned value. In this method, len is the
number of bytes in the return value. The value starts at
byte eight in the packet; this is moved into idx.

pub show_parameters | value
term.str(@Report)

The value of ofs is the number of return bytes minus
one; this will be the current byte of the method's return
value. Remember that XBee uses Big Endian values but the

Propeller uses Little Endian values; hence, we have to flip
the bytes from the packet — this is what we're doing with
the loop. We're indexing the bytes in the result in reverse
order while moving forward through the bytes in the
packet.

As you can see, I've cut this down because the rest of
that method has blocks of code for reading and displaying
each parameter. The point of this program is to ensure
that we have a good connection to the local XBee.

That said, the whole idea behind the XBee object is to
allow us to connect with multiple external devices via API