Skip to Academy content
MODULE 02 · LESSON 02
Beginner12 min read

What Is GAP in Bluetooth Low Energy?

When a sensor announces itself and a computer decides whether to connect, GAP defines the roles and procedures that make that encounter possible.

LEARNING OBJECTIVES

What you’ll learn

  • Explain what GAP governs and what it leaves to other layers
  • Distinguish all four GAP roles
  • Trace discovery through an optional connection
Before you begin

Know the basic BLE roles from Module 1; the architecture lesson explains where GAP sits in the Host.

GAP begins before a connection

Picture a temperature sensor on a desk. It sends advertising packets; a nearby phone or computer listens and notices it. The receiver may use information in the advertisement or, if the sensor permits it, initiate a connection. The Generic Access Profile (GAP) defines the operating modes and procedures used for that access: discovery, advertising, scanning, connection establishment, and related security modes.

GAP is part of the BLE Host described in the architecture lesson. It does not itself perform every radio action. The Controller’s Link Layer transmits advertising packets and manages link-level connection events; GAP specifies how higher-level roles and procedures use those capabilities. Once connected, GATT may organize application data, but GAP and GATT answer different questions.

Four roles, two common patterns

A broadcaster sends advertising data without taking part in a connection. An observer receives advertisements without connecting. A beacon broadcasting an identifier and a nearby listener illustrate this connectionless pair. A peripheral advertises in a way that can allow a central to connect; a central initiates that connection. A phone connecting to a sensor illustrates the connected pair.

A device can support more than one role, and an application may switch roles over time. The labels describe current BLE behavior, not a permanent hardware category. A peripheral may advertise, but it is inaccurate to call every advertiser a peripheral: a broadcast-only beacon is a broadcaster.

Two GAP relationship pairs: broadcaster sends advertisements to observer without connection; peripheral advertises and central may initiate a connection
The arrows show possible relationships, not a rule that every advertiser accepts a connection.

How advertising becomes discovery

An advertiser sends packets in advertising events. Depending on its chosen advertising type and data, a scanner may see an address, device name, service identifiers, or other data. A scanner need not connect to receive an advertisement. With active scanning, it may request a scan response from a scannable advertiser; passive scanning only listens. A scan response can supply additional data, but it does not turn a non-connectable advertisement into a connection offer.

Scan results are observations of radio traffic, not a complete inventory of nearby devices. A device may be off, asleep, not advertising, hidden by interference, or advertising outside the scan window. Privacy addresses can also change. Signal strength varies, so a missing or changing result is not necessarily a software fault. The advertising lesson contains the full Web App scanning experiment.

From discovery to an optional connection

When a central finds a connectable peripheral it wants to use, it can send a connection request through the lower layers. If the request succeeds, the devices establish a link and schedule connection events. The central and peripheral are then connected GAP roles. The application can discover services and use GATT if the devices support the relevant procedures and permissions.

A broadcaster and observer stop before this step: observing an identifier or sensor field may be the entire application. Conversely, a visible connectable device is not guaranteed to accept a request; availability, timing, signal conditions, policy, and connection limits still matter. Pairing and bonding may be required for protected data, but they are not prerequisites for receiving ordinary public advertisements.

Advertising reaches a scanner; the path branches to use broadcast data without connecting or to request an optional connection to a connectable peripheral
Discovery has two valid outcomes: use broadcast data, or connect when the application needs more.

See a GAP role with BleuIO

BleuIO’s AT+GAPSTATUS reports its configured role, connection state, and advertising state separately. In the recorded demonstration it returned Dual role, Not Connected, and Not Advertising. Dual role gives the dongle Central and Peripheral capabilities; the other two lines show that neither a connection nor advertising was active at that moment.

The demonstration then sends AT+CENTRAL, AT+PERIPHERAL, and AT+DUAL. An OK after a role command means the command was accepted; it does not establish a connection or start advertising. Dual capability does not promise that every procedure can run simultaneously. Follow the state checks in the lab before changing roles.

GAP versus GATT

GAP asks how devices announce themselves, discover one another, and establish a connection. GATT asks how a client discovers and uses structured data held by a server. A central often becomes a GATT client and a peripheral often becomes a GATT server, but those are different sets of roles. The next lesson explains that data model.

VIDEO DEMONSTRATION

Watch: Check and Change BLE GAP Roles with BleuIO

See the BleuIO Web App report its role, connection and advertising state, then change between Central, Peripheral and Dual roles.

Video unavailable here? Watch on YouTube ↗

HANDS-ON LAB · BLEUIO WEB APP

Check and Change BleuIO GAP Roles

Inspect the current state, switch roles while idle, and confirm the final role in the BleuIO Web App.

What you need

A BleuIO or BleuIO Pro USB dongle, a computer with a USB port, and a current desktop browser supporting Web Serial, such as Chrome or Edge. Browser and operating system support varies. No second BLE device is needed.

BleuIO Web App terminal output above an AT command entry field and Send button
BleuIO Web App command input and terminal. Official screenshot and guide.
  1. Plug in the dongle, open the Web App in a supported desktop browser, and use Connect to select its serial port.
  2. Send AT to check communication, then AT+GAPSTATUS. Read the role, connection state, and advertising state as separate facts. The video begins from Dual role, Not Connected, Not Advertising; your initial state may differ.
  3. Before switching roles, ensure BLE connections are terminated and advertising is stopped. The documented AT+CENTRAL and AT+DUAL commands require both conditions; AT+PERIPHERAL requires no active connection.
  4. Send AT+CENTRAL and observe OK. Central capability lets the dongle scan and initiate a connection, but OK does not mean it has connected.
  5. Send AT+PERIPHERAL and observe OK. Peripheral capability can support connection establishment when appropriate advertising is configured; this command alone does not start advertising.
  6. Send AT+DUAL and observe OK to restore both capabilities. As optional practice beyond the video sequence, send AT+GAPSTATUS after each switch and compare the reported role.
  7. Send AT+GAPSTATUS once more to confirm the final role, connection state, and advertising state.

Commands to send

AT
AT+GAPSTATUS
AT+CENTRAL
AT+PERIPHERAL
AT+DUAL
Recorded response excerpts — send each command separately; your initial role and state may differ
AT+GAPSTATUS
Dual role
Not Connected
Not Advertising

AT+CENTRAL
OK

AT+PERIPHERAL
OK

AT+DUAL
OK
Troubleshooting tips
  • If a role change is rejected, terminate existing BLE connections and stop advertising before trying again.
  • If the Web App cannot see the serial port, close other programs that may be using the dongle and reconnect it.
  • If AT produces no response, verify that the correct port is selected and the dongle has completed startup.
  • If verbose mode is enabled, responses appear in a different format; compare the role and state fields rather than exact wording.
  • Browser and operating system support for Web Serial varies.

Need a visual reference? See BleuIO’s illustrated Web App guide.

Open BleuIO Web App Opens in a new tab so you can keep this lesson open.
QUICK CHECK

Check your understanding

A beacon sends an identifier but does not accept connections. Which GAP role describes its behavior?

IN BRIEF

Key takeaways

  • GAP defines discovery, advertising, connection roles, and related access procedures.
  • Broadcaster/observer can communicate by advertisements without a connection.
  • Central/peripheral describe a connection relationship; they are distinct from GATT client/server.

Further Reading and Resources

Finished this lesson?

Save your progress in this browser.