PebbleOS v4.47.0-1161-g94e3d98da
Loading...
Searching...
No Matches
GATT server

What the GATT services of the device share. More...

Data Structures

struct  pbl_bt_gatts_service
 A service of the device. More...
 

Macros

#define PBL_BT_GATTS_SERVICE_DEFINE(_name, _order, _add)
 Define a service of the device, added by pbl_bt_gatts_add_services().
 

Functions

int pbl_bt_gatts_add_services (void)
 Add the services defined with PBL_BT_GATTS_SERVICE_DEFINE(), before the host starts.
 
int pbl_bt_gatts_add (const struct ble_gatt_svc_def *svcs)
 Add services to the GATT server, before the host starts.
 
int pbl_bt_gatts_notify (uint16_t conn_handle, uint16_t attr_handle, const void *data, uint16_t len)
 Notify a value to a peer, subscribed or not.
 

Detailed Description

What the GATT services of the device share.

Macro Definition Documentation

◆ PBL_BT_GATTS_SERVICE_DEFINE

#define PBL_BT_GATTS_SERVICE_DEFINE (   _name,
  _order,
  _add 
)
Value:
static const struct pbl_bt_gatts_service pbl_bt_gatts_service_##_name PBL_ITERABLE_SECTION( \
const struct pbl_bt_gatts_service, bt_gatts, #_order "_" #_name) = {.add = (_add)}
#define PBL_ITERABLE_SECTION(type, tag, key)
Add the object to an iterable section, a table gathered at link time from any file.
Definition section.h:144
A service of the device.
Definition gatts.h:20
int(* add)(void)
Add the service to the GATT server, e.g.
Definition gatts.h:26

Define a service of the device, added by pbl_bt_gatts_add_services().

Services are added by increasing order, which sets their attribute handles. Peers cache the handles of a bonded device, so the order of services that shipped must not change.

Parameters
_nameName of the service.
_orderTwo digits that place it among the others.
_addIts function, see struct pbl_bt_gatts_service.

Function Documentation

◆ pbl_bt_gatts_add()

int pbl_bt_gatts_add ( const struct ble_gatt_svc_def *  svcs)

Add services to the GATT server, before the host starts.

Parameters
svcsThe services, ended by an empty one. They must outlive the server.
Returns
0 on success, negative errno otherwise.

◆ pbl_bt_gatts_add_services()

int pbl_bt_gatts_add_services ( void  )

Add the services defined with PBL_BT_GATTS_SERVICE_DEFINE(), before the host starts.

Returns
0 on success, or what the first service that failed returned.

◆ pbl_bt_gatts_notify()

int pbl_bt_gatts_notify ( uint16_t  conn_handle,
uint16_t  attr_handle,
const void *  data,
uint16_t  len 
)

Notify a value to a peer, subscribed or not.

Parameters
conn_handleConnection.
attr_handleHandle of the characteristic value.
dataThe value.
lenIts length.
Returns
0 on success, -ENOMEM if there is no buffer for it now, -ENOTCONN if the connection is gone, another negative errno otherwise.