Hardware Reference
In-Depth Information
The standard advertising packet contains a 31-byte payload used to include data that
describes the broadcaster and its capabilities, but it can also include any custom infor‐
mation you want to broadcast to other devices. If this standard 31-byte payload isn't
large enough to fit all of the required data, BLE also supports an optional secondary
advertising payload (called the Scan Response ), which allows devices that detect a
broadcasting device to request a second advertising frame with another 31-byte payload,
for up to 62 bytes total.
Broadcasting is fast and easy to use, and it's a good choice if you want to push only a
small amount of data on a fixed schedule or to multiple devices. Chapter 9 provides a
practical example of BLE's connectionless broadcasting in action with iBeacon.
A major limitation of broadcasting, when compared to a regular connection, is that
there are no security or privacy provisions at all with it (any observer device is able to
receive the data being broadcasted), so it might not be suited for sensitive data.
Connections
If you need to transmit data in both directions, or if you have more data than the two
advertising payloads can accomodate, you will need to use a connection . A connection
is a permanent, periodical data exchange of packets between two devices. It is therefore
inherently private (the data is sent to and received by only the two peers involved in a
connection, and no other device unless it's indiscriminately sniffing). “Connections” on
page 22 provides more information about connections at the lower level, and “Roles” on
page 36 discusses the corresponding GAP roles.
Connections involve two separate roles:
Central (master)
Repeatedly scans the preset frequencies for connectable advertising packets and,
when suitable, initates a connection. Once the connection is established, the central
manages the timing and initiates the periodical data exchanges.
Peripheral (slave)
A device that sends connectable advertising packets periodically and accepts in‐
coming connections. Once in an active connection, the peripheral follows the cen‐
tral's timing and exchanges data regularly with it.
To initiate a connection, a central device picks up the connectable advertising packets
from a peripheral and then sends a request to the peripheral to establish an exclusive
connection between the two devices. Once the connection is established, the peripheral
stops advertising and the two devices can begin exchanging data in both directions, as
shown in Figure 1-4 .
Search WWH ::




Custom Search