Attribute Profile). This data exchange mechanism is based
on Services and Characteristics. Simply put, a Service is a
logical collection of Characteristics. A collection of Services
is called a Profile. Figure 1 is a graphical representation of
how Profiles, Services, and Characteristics interweave.
GATT is based on the client/server model. Let’s
expand on our relationship between the Link Layer and
Link Layer Master = GAP Central = GATT Client
Link Layer Slave = GAP Peripheral = GATT Server
To pull it all together, take a look at the BLE stack
drawn up in Figure 2. GATT is based on ATT (Attribute
Protocol). ATT can be thought of as a lookup table of
Services and Characteristics that are uniquely identified
using 16-bit IDs.
Let’s quickly examine the Figure 2 BLE stack bottom to
top. The Physical Layer is the nRF52832 radio. The PHY is
responsible for converting analog data to digital data and
passing it along to the Link Layer. The PHY is also capable
of processing digital data it receives from the Link Layer
and transmitting it over the air.
Earlier, we used nRFgo Studio
to load SoftDevice 132. So, all we
need to do at this point is compile
the template code with our
n SCREENSHOT 3. Master Control Panel has picked up our nRF52832’s
advertisement. We know this is ours as the device name (NutsVolts) reflects the
change we made in the original template source code.
n SCREENSHOT 2. We must include the preprocessor
symbol CONFIG_NFCT_PINS_AS_GPIOS to use the
MDBT42Q’s pins 9 and 10 as standard GPIO. BOARD_
CUSTOM tells the compiler to use the board configuration
entries within our custom_board.h file.
The Link Layer is there to oversee scanning,
advertising, and creating/maintaining connections. L2CAP
(Logical Link Control and Adaptation Protocol) performs
the transportation of data for higher layer protocols,
including multiplexing multiple applications over a single
link. SMP (Security Manager Protocol) is obviously used for
security of the BLE link and data.
I’m not going to list the
template source code here as you
can get the source by downloading
the version 12 nRF5 SDK. Once
you have a copy of the ble_app_
template project code, you will
see that the GAP and associated
connection parameters have
already been defined. The same
goes for the advertising functions.
There are a couple of changes
that we will make just to show that
the code is working as designed.
Let’s change the device name and
eliminate the advertising timeout:
58 November 2016