Hardware Reference
In-Depth Information
Project 4
Negotiating in Bluetooth
The steps you went through to pair your
Bluetooth module with your computer
negotiated a series of exchanges that
included discovering other radios, learning
the services offered by those radios, and
pairing to open a connection. It's very
convenient to be able to do this from the
graphical user interface, but it would be
even better if the devices could negotiate
this exchange themselves. In the section
that follows, you'll negotiate some parts of
that exchange directly, in order to under-
stand how to program devices to handle
that negotiation.
MATERIALS
» 1 bluetooth Mate module
» 1 FTDI uSb-to-Serial converter
The Bluetooth module is essentially a modem in that it
converts from one communications medium (TTL serial
carried over wires) to another (Bluetooth serial carried
over radio). Modems are designed to open a connection
to another modem, negotiate the terms of data exchange,
carry on an exchange, and then disconnect. To do this,
they must have two operating modes, usually referred
to as command mode , in which you talk to the modem,
and data mode , in which you talk through the modem.
Bluetooth modems are no different in this respect.
Most Bluetooth modems (and many other communica-
tions devices) use a set of commands based on the those
designed originally for telephone modems, known as the
Hayes AT command protocol . All commands in the Hayes
command protocol (and therefore in Bluetooth command
protocols as well) are sent using ASCII characters. Devices
FTDI
USB-to-Serial
Cable
Bluetooth
Mate
Connect
RX
TX
Vcc
RX
TX
Vcc
RN-42
Gnd
Gnd
Stat
Figure 2-20
Bluetooth Mate module connected to an FT232RL USB-to-Serial converter. The Mate is designed to be a drop-in replacement for the FTDI
cable, so it has the same pin configuration. As a result, you have to cross the transmit and receive connections to make the connection work.
using this protocol all have a command mode and a data
mode. To switch from data mode to command mode in the
Hayes protocol, send the string +++ . There's a common
structure to all the commands. Each command sent from
the controlling device (like a microcontroller or personal
computer) to the modem begins with the ASCII string AT ,
followed by a short string of letters and numbers repre-
senting the command, followed by any parameters of the
command, separated by commas. The command ends
with an ASCII carriage return. The modem then responds
to the command with the message OK , followed by any
information it's expected to return.
The Bluetooth Mate doesn't use AT commands, but its
protocol is similar. The commands are all ASCII-based.
Search WWH ::




Custom Search