Peripheral GATT Write

Browse source code on GitHub

Overview

Similar to the Peripheral sample, except that this application uses GATT Write Without Response.

Requirements

  • BlueZ running on the host, or

  • A board with Bluetooth LE support

Building and Running

Build and flash the sample as follows, replacing <board> with your target board:

west build -b <board> samples/bluetooth/peripheral_gatt_write
west flash

Notification modes

By default both peers exchange GATT Write Without Response commands. Two Kconfig options (defined in the central sample’s Kconfig.gatt_write, shared by this sample) select notification-based workloads instead:

  • CONFIG_USE_NOTIFY switches the workload to GATT Notifications: this peripheral streams notifications and the central subscribes to and receives them.

  • CONFIG_USE_FULL_DUPLEX (enabled by default, and only meaningful together with CONFIG_USE_NOTIFY) makes both peers subscribe to and notify each other. Disable it to run the one-directional (simplex) path where only this peripheral notifies.

For example, to build in simplex notification mode:

west build -b <board> samples/bluetooth/peripheral_gatt_write -- -DCONFIG_USE_NOTIFY=y -DCONFIG_USE_FULL_DUPLEX=n

See Bluetooth samples for details.

See also

Generic Attribute Profile (GATT)
Bluetooth APIs