Generic Attribute (GATT) Profile¶
The GATT Profile module can be used to receive service changed indications from a connected peer. It is used in the Bluetooth: Peripheral ANCS client sample.
API documentation¶
include/bluetooth/services/gattp.h
subsys/bluetooth/services/gattp.c
-
group
bt_gattp
API for the Bluetooth LE Generic Attribute (GATT) Profile.
Typedefs
-
typedef void (*
bt_gattp_indicate_cb
)(struct bt_gattp *gattp, const struct bt_gattp_handle_range *handle_range, int err)¶ Service Changed Indication callback function.
- Parameters
gattp – [in] GATT profile instance.
handle_range – [in] Affected handle range.
err – [in] 0 if the indication is valid. Otherwise, contains a (negative) error code.
Functions
-
int
bt_gattp_init
(struct bt_gattp *gattp)¶ Initialize the GATT profile instance.
- Parameters
gattp – [inout] GATT profile instance.
- Returns
0 – If the instance is initialized successfully. Otherwise, a (negative) error code is returned.
-
int
bt_gattp_handles_assign
(struct bt_gatt_dm *dm, struct bt_gattp *gattp)¶ Assign handles to the GATT profile instance.
Call this function when a link has been established with a peer to associate the link to this instance of the module. This makes it possible to handle several links and associate each link to a particular instance of this module.
- Parameters
dm – [in] Discovery object.
gattp – [inout] GATT profile instance.
- Returns
0 – If the operation is successful. Otherwise, a (negative) error code is returned.
-
int
bt_gattp_subscribe_service_changed
(struct bt_gattp *gattp, bt_gattp_indicate_cb func)¶ Subscribe to the Service Changed indication.
- Parameters
gattp – [in] GATT profile instance.
func – [in] Indication callback function handler.
- Returns
0 – If the operation is successful. Otherwise, a (negative) error code is returned.
-
struct
bt_gattp_handle_range
¶ - #include <gattp.h>
Structure for Service Changed handle range.
-
struct
bt_gattp
¶ - #include <gattp.h>
GATT profile instance.
Public Members
-
struct bt_conn *
conn
¶ Connection object.
-
uint16_t
handle_sc
¶ Handle of the Service Changed Characteristic.
-
uint16_t
handle_sc_ccc
¶ Handle of the CCCD of the Service Changed Characteristic.
-
struct bt_gatt_subscribe_params
indicate_params
¶ GATT subscribe parameters for the Service Changed Characteristic.
-
bt_gattp_indicate_cb
indicate_cb
¶ Callback function for the Service Changed indication.
-
atomic_t
state
¶ Internal state.
-
struct bt_conn *
-
typedef void (*