
246 MAKING THINGS TALK
Directed Messages
The more common way to use sessionless protocols is to send directed messages to
the object to which you want to speak. You saw this in action already in Chapter 6, when
you programmed your microcontrollers to speak to each other using the XBee radios.
Each radio had a source address (which you read and set using the ATMY command)
and a destination address (which you read and set using the ATDL command). One
radio’s destination was another’s source, and vice versa. Though there were only two
radios in that example, you could have included many more radios, and decided which
one to address by changing the destination address on the fly.
Sending UDP Datagrams To
and From a Lantronix Device
So far, you’ve used the Lantronix devices to communicate
via TCP, but they can also send and receive UDP packets.
To do this, you have to set the connectMode appropriately
(see “Configuring the Micro” in Chapter 4 for configuration
instructions) and set an address to which the datagrams
will be sent. You can also control when datagrams are sent;
for example, the default is 12 milliseconds after a serial
byte is received, but you can change the time delay, or you
can set the device to send after it receives a specific string
of characters.
To send directed UDP packets, you have to set the connect
Mode to 0xCC, which sets your device to accept any
incoming UDP ...