SmartSnippets DA1459x SDK
ble_gatts.h
Go to the documentation of this file.
1 
39 #ifndef BLE_GATTS_H_
40 #define BLE_GATTS_H_
41 
42 #include <stdint.h>
43 #include "ble_att.h"
44 #include "ble_common.h"
45 #include "ble_gatt.h"
46 
48 typedef enum {
50 } gatts_flag_t;
51 
62 };
63 
65 typedef struct {
67  uint16_t conn_idx;
68  uint16_t handle;
69  uint16_t offset;
71 
73 typedef struct {
75  uint16_t conn_idx;
76  uint16_t handle;
77  uint16_t offset;
78  uint16_t length;
79  uint8_t value[];
81 
83 typedef struct {
85  uint16_t conn_idx;
86  uint16_t handle;
88 
90 typedef struct {
92  uint16_t conn_idx;
93  uint16_t handle;
95  bool status;
97 
122 ble_error_t ble_gatts_add_service(const att_uuid_t *uuid, const gatt_service_t type, uint16_t num_attrs);
123 
135 ble_error_t ble_gatts_add_include(uint16_t handle, uint16_t *h_offset);
136 
162 ble_error_t ble_gatts_add_characteristic(const att_uuid_t *uuid, gatt_prop_t prop, att_perm_t perm,
163  uint16_t max_len, gatts_flag_t flags,
164  uint16_t *h_offset, uint16_t *h_val_offset);
165 
192 ble_error_t ble_gatts_add_descriptor(const att_uuid_t *uuid, att_perm_t perm, uint16_t max_len,
193  gatts_flag_t flags, uint16_t *h_offset);
194 
210 ble_error_t ble_gatts_register_service(uint16_t *handle, ...);
211 
227 ble_error_t ble_gatts_enable_service(uint16_t handle);
228 
244 ble_error_t ble_gatts_disable_service(uint16_t handle);
245 
259 
277 
293 ble_error_t ble_gatts_get_value(uint16_t handle, uint16_t *length, void *value);
294 
310 ble_error_t ble_gatts_set_value(uint16_t handle, uint16_t length, const void *value);
311 
326 ble_error_t ble_gatts_read_cfm(uint16_t conn_idx, uint16_t handle, att_error_t status, uint16_t length, const void *value);
327 
328 
344 ble_error_t ble_gatts_write_cfm(uint16_t conn_idx, uint16_t handle, att_error_t status);
345 
359 ble_error_t ble_gatts_prepare_write_cfm(uint16_t conn_idx, uint16_t handle, uint16_t length, att_error_t status);
360 
384 ble_error_t ble_gatts_send_event(uint16_t conn_idx, uint16_t handle, gatt_event_t type,
385  uint16_t length, const void *value);
386 
400 ble_error_t ble_gatts_service_changed_ind(uint16_t conn_idx, uint16_t start_handle,
401  uint16_t end_handle);
402 
413 __STATIC_INLINE uint16_t ble_gatts_get_num_attr(uint16_t include, uint16_t characteristic,
414  uint16_t descriptor)
415 {
416  return 1 * include + 2 * characteristic + 1 * descriptor;
417 }
418 
419 #endif /* BLE_GATTS_H_ */
420 
ble_evt_gatts_prepare_write_req_t::handle
uint16_t handle
attribute handle
Definition: ble_gatts.h:86
gatt_event_t
gatt_event_t
Definition: ble_gatt.h:49
gatts_flag_t
gatts_flag_t
Definition: ble_gatts.h:48
GATTS_FLAG_CHAR_READ_REQ
enable BLE_EVT_GATTS_READ_REQ for attribute
Definition: ble_gatts.h:49
ble_gatts_read_cfm
ble_error_t ble_gatts_read_cfm(uint16_t conn_idx, uint16_t handle, att_error_t status, uint16_t length, const void *value)
Respond to an attribute read request.
ble_evt_gatts_write_req_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gatts.h:74
ble_evt_gatts_read_req_t::handle
uint16_t handle
attribute handle
Definition: ble_gatts.h:68
ble_gatts_set_characteristic_prop
ble_error_t ble_gatts_set_characteristic_prop(uint16_t handle, gatt_prop_t prop, att_perm_t perm)
Set characteristic properties and permissions.
ble_evt_gatts_read_req_t::offset
uint16_t offset
attribute value offset
Definition: ble_gatts.h:69
ble_gatts_prepare_write_cfm
ble_error_t ble_gatts_prepare_write_cfm(uint16_t conn_idx, uint16_t handle, uint16_t length, att_error_t status)
Respond to an attribute prepare write request.
ble_gatts_get_value
ble_error_t ble_gatts_get_value(uint16_t handle, uint16_t *length, void *value)
Get attribute value.
BLE_EVT_GATTS_WRITE_REQ
Definition: ble_gatts.h:57
ble_evt_gatts
ble_evt_gatts
Definition: ble_gatts.h:53
ble_gatts_add_characteristic
ble_error_t ble_gatts_add_characteristic(const att_uuid_t *uuid, gatt_prop_t prop, att_perm_t perm, uint16_t max_len, gatts_flag_t flags, uint16_t *h_offset, uint16_t *h_val_offset)
Add characteristic to GATT service.
gatt_prop_t
gatt_prop_t
Definition: ble_gatt.h:55
ble_evt_gatts_write_req_t::length
uint16_t length
attribute value length
Definition: ble_gatts.h:78
ble_evt_gatts_write_req_t
Definition: ble_gatts.h:73
att_error_t
att_error_t
Definition: ble_att.h:64
ble_gatt.h
Common definitions for GATT API.
ble_gatts_add_include
ble_error_t ble_gatts_add_include(uint16_t handle, uint16_t *h_offset)
Add included service to GATT service.
ble_evt_gatts_prepare_write_req_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gatts.h:85
ble_evt_gatts_read_req_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gatts.h:67
ble_gatts_add_service
ble_error_t ble_gatts_add_service(const att_uuid_t *uuid, const gatt_service_t type, uint16_t num_attrs)
Add new GATT service.
ble_gatts_set_value
ble_error_t ble_gatts_set_value(uint16_t handle, uint16_t length, const void *value)
Set attribute value.
gatt_service_t
gatt_service_t
Definition: ble_gatt.h:43
BLE_EVT_GATTS_READ_REQ
Definition: ble_gatts.h:55
ble_gatts_add_descriptor
ble_error_t ble_gatts_add_descriptor(const att_uuid_t *uuid, att_perm_t perm, uint16_t max_len, gatts_flag_t flags, uint16_t *h_offset)
Add descriptor to GATT service.
ble_evt_gatts_prepare_write_req_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gatts.h:84
ble_evt_gatts_read_req_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gatts.h:66
ble_evt_gatts_event_sent_t::handle
uint16_t handle
attribute handle
Definition: ble_gatts.h:93
ble_evt_gatts_prepare_write_req_t
Definition: ble_gatts.h:83
ble_evt_gatts_event_sent_t
Definition: ble_gatts.h:90
ble_evt_gatts_event_sent_t::type
gatt_event_t type
event type
Definition: ble_gatts.h:94
att_perm_t
att_perm_t
Definition: ble_att.h:48
ble_gatts_get_characteristic_prop
ble_error_t ble_gatts_get_characteristic_prop(uint16_t handle, gatt_prop_t *prop, att_perm_t *perm)
Read current characteristic properties and permissions.
ble_evt_hdr_t
Definition: ble_common.h:156
ble_gatts_send_event
ble_error_t ble_gatts_send_event(uint16_t conn_idx, uint16_t handle, gatt_event_t type, uint16_t length, const void *value)
Send a characteristic value notification or indication.
ble_evt_gatts_read_req_t
Definition: ble_gatts.h:65
ble_gatts_register_service
ble_error_t ble_gatts_register_service(uint16_t *handle,...)
Register service in database.
ble_evt_gatts_event_sent_t::status
bool status
event status
Definition: ble_gatts.h:95
BLE_EVT_CAT_FIRST
#define BLE_EVT_CAT_FIRST(CAT)
Definition: ble_common.h:153
ble_evt_gatts_write_req_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gatts.h:75
BLE_EVT_GATTS_EVENT_SENT
Definition: ble_gatts.h:61
ble_gatts_enable_service
ble_error_t ble_gatts_enable_service(uint16_t handle)
Enable service in database.
ble_evt_gatts_event_sent_t::hdr
ble_evt_hdr_t hdr
event header
Definition: ble_gatts.h:91
ble_att.h
Attribute protocol API.
ble_evt_gatts_write_req_t::offset
uint16_t offset
attribute value offset
Definition: ble_gatts.h:77
ble_error_t
ble_error_t
Definition: ble_common.h:53
BLE_EVT_GATTS_PREPARE_WRITE_REQ
Definition: ble_gatts.h:59
ble_evt_gatts_write_req_t::handle
uint16_t handle
attribute handle
Definition: ble_gatts.h:76
ble_common.h
Common definitions for BLE API.
ble_gatts_service_changed_ind
ble_error_t ble_gatts_service_changed_ind(uint16_t conn_idx, uint16_t start_handle, uint16_t end_handle)
Send indication of the Service Changed Characteristic.
ble_gatts_write_cfm
ble_error_t ble_gatts_write_cfm(uint16_t conn_idx, uint16_t handle, att_error_t status)
Respond to an attribute write request.
ble_gatts_get_num_attr
__STATIC_INLINE uint16_t ble_gatts_get_num_attr(uint16_t include, uint16_t characteristic, uint16_t descriptor)
Calculate number of attributes required for service.
Definition: ble_gatts.h:413
ble_evt_gatts_event_sent_t::conn_idx
uint16_t conn_idx
connection index
Definition: ble_gatts.h:92
ble_gatts_disable_service
ble_error_t ble_gatts_disable_service(uint16_t handle)
Disable service in database.