ble_gatts.h File Reference

BLE GATTS API. More...

#include "ble_error.h"
#include "ble_att.h"
#include "ble_gatt.h"
#include "ble_gapc.h"
#include <stdint.h>

Go to the source code of this file.

Classes

struct  ble_gatts_attm_desc_t
 Service(16-bit UUID) description. More...
 
struct  ble_gatts_attm_desc_128_t
 Service(128 bits UUID) description. More...
 
struct  ble_gatts_create_db_t
 Parameter of Added service description. More...
 
union  ble_gatts_create_db_t::attribute_table
 
struct  ble_gatts_read_cfm_t
 GATT read attribute result description. More...
 
struct  ble_gatts_write_cfm_t
 GATT write attribute result description. More...
 
struct  ble_gatts_prep_write_cfm_t
 GATT prepare write result description. More...
 
struct  ble_gatts_noti_ind_t
 GATT sending Notification or Indication event param description. More...
 
struct  ble_gatts_evt_read_t
 GATT read request event for BLE_GATTS_EVT_READ_REQUEST. More...
 
struct  ble_gatts_evt_write_t
 GATT write request event for BLE_GATTS_EVT_WRITE_REQUEST. More...
 
struct  ble_gatts_evt_prep_write_t
 GATT prepare write request event for BLE_GATTS_EVT_PREP_WRITE_REQUEST. More...
 
struct  ble_gatts_evt_ntf_ind_t
 Gatt Notification or indication event for BLE_GATTS_EVT_NTF_IND. More...
 
struct  ble_gatts_evt_cccd_rec_t
 Gatt cccd recovery event for BLE_GATTS_EVT_CCCD_RECOVERY. More...
 
struct  ble_gatts_evt_t
 BLE GATTS event structure. More...
 

Macros

#define BLE_GATTS_MAX_INC_SRVC_NUM   (5)
 
#define BLE_GATTS_BROADCAST   (0x01)
 
#define BLE_GATTS_READ   (0x02)
 
#define BLE_GATTS_WRITE_CMD   (0x04)
 
#define BLE_GATTS_WRITE_REQ   (0x08)
 
#define BLE_GATTS_NOTIFY   (0x10)
 
#define BLE_GATTS_INDICATE   (0x20)
 
#define BLE_GATTS_WRITE_SIGNED   (0x40)
 
#define BLE_GATTS_EXT_PROP   (0x80)
 
#define BLE_GATTS_READ_POS   (0x00)
 
#define BLE_GATTS_WRITE_POS   (0x02)
 
#define BLE_GATTS_INDICATE_POS   (0x04)
 
#define BLE_GATTS_NOTIFY_POS   (0x06)
 
#define BLE_GATTS_NOAUTH   (0x00)
 
#define BLE_GATTS_UNAUTH   (0x01)
 
#define BLE_GATTS_AUTH   (0x02)
 
#define BLE_GATTS_SEC_CON   (0x03)
 
#define BLE_GATTS_SEC_LEVEL_MASK   (0x03)
 
#define BLE_GATTS_UUID_TYPE_16   (0x00)
 
#define BLE_GATTS_UUID_TYPE_128   (0x02)
 
#define BLE_GATTS_SRVC_SECONDARY_SET   (0x80)
 
#define BLE_GATTS_SRVC_UUID_TYPE_SET(uuid_len)   ((uuid_len) << 5)
 
#define BLE_GATTS_SRVC_DISABLE   (0x10)
 
#define BLE_GATTS_SRVC_PERM(sec_level)   (((sec_level) & SEC_LEVEL_MASK) << 2)
 
#define BLE_GATTS_SRVC_ENCRP_KEY_SIZE_16   (0x02)
 
#define BLE_GATTS_SRVC_MULTI_ENABLE   (0x01)
 
#define BLE_GATTS_READ_PERM_UNSEC   (BLE_GATTS_READ << 8)
 
#define BLE_GATTS_READ_PERM(sec_level)   (BLE_GATTS_READ << 8 | (((sec_level) & BLE_GATTS_SEC_LEVEL_MASK) << BLE_GATTS_READ_POS))
 
#define BLE_GATTS_WRITE_REQ_PERM_UNSEC   (BLE_GATTS_WRITE_REQ << 8)
 
#define BLE_GATTS_WRITE_REQ_PERM(sec_level)   (BLE_GATTS_WRITE_REQ << 8 | (((sec_level) & BLE_GATTS_SEC_LEVEL_MASK) << BLE_GATTS_WRITE_POS))
 
#define BLE_GATTS_WRITE_CMD_PERM_UNSEC   (BLE_GATTS_WRITE_CMD << 8)
 
#define BLE_GATTS_WRITE_CMD_PERM(sec_level)   (BLE_GATTS_WRITE_CMD << 8 | (((sec_level) & BLE_GATTS_SEC_LEVEL_MASK) << BLE_GATTS_WRITE_POS))
 
#define BLE_GATTS_WRITE_SIGNED_PERM_UNSEC   (BLE_GATTS_WRITE_SIGNED << 8)
 
#define BLE_GATTS_WRITE_SIGNED_PERM(sec_level)   (BLE_GATTS_WRITE_SIGNED << 8 | (((sec_level) & BLE_GATTS_SEC_LEVEL_MASK) << BLE_GATTS_WRITE_POS))
 
#define BLE_GATTS_INDICATE_PERM_UNSEC   (BLE_GATTS_INDICATE << 8)
 
#define BLE_GATTS_INDICATE_PERM(sec_level)   (BLE_GATTS_INDICATE << 8 | (((sec_level) & BLE_GATTS_SEC_LEVEL_MASK) << BLE_GATTS_INDICATE_POS))
 
#define BLE_GATTS_NOTIFY_PERM_UNSEC   (BLE_GATTS_NOTIFY << 8)
 
#define BLE_GATTS_NOTIFY_PERM(sec_level)   (BLE_GATTS_NOTIFY << 8 | (((sec_level) & BLE_GATTS_SEC_LEVEL_MASK) << BLE_GATTS_NOTIFY_POS))
 
#define BLE_GATTS_BROADCAST_ENABLE   (BLE_GATTS_BROADCAST << 8)
 
#define BLE_GATTS_EXT_PROP_ENABLE   (BLE_GATTS_EXT_PROP << 8)
 
#define BLE_GATTS_ATT_VAL_LOC_USER   (1 << 15)
 
#define BLE_GATTS_ATT_VAL_LOC_STACK   (0 << 15)
 
#define BLE_GATTS_ATT_UUID_TYPE_SET(uuid_len)   ((uuid_len) << 13)
 
#define BLE_GATTS_ATT_ENC_KEY_SIZE_16   (0x1000)
 

Enumerations

enum  ble_gatts_service_type_t {
  BLE_GATTS_SERVICE_TABLE_TYPE_16 = 0x00,
  BLE_GATTS_SERVICE_TABLE_TYPE_128
}
 Service table type. More...
 

Functions

uint16_t ble_gatts_srvc_db_create (ble_gatts_create_db_t *p_param)
 Register a service's attribute list. More...
 
uint16_t ble_gatts_value_set (uint16_t handle, uint16_t length, uint16_t offset, const uint8_t *p_value)
 Update attribute value only if the attribute value is saved in the BLE Stack space. More...
 
uint16_t ble_gatts_value_get (uint16_t handle, uint16_t *p_length, uint8_t *p_value)
 Retrieve attribute value only if the attribute value is saved in the BLE Stack space. More...
 
uint16_t ble_gatts_attr_permission_set (uint16_t handle, uint16_t perm, uint16_t ext_perm)
 Update attribute permission. More...
 
uint16_t ble_gatts_attr_permission_get (uint16_t handle, uint16_t *p_perm, uint16_t *p_ext_perm)
 Retrieve attribute permission. More...
 
uint16_t ble_gatts_read_cfm (uint8_t conn_idx, const ble_gatts_read_cfm_t *p_param)
 Respond to an attribute read request.. More...
 
uint16_t ble_gatts_write_cfm (uint8_t conn_idx, const ble_gatts_write_cfm_t *p_param)
 Respond to an attribute write request. More...
 
uint16_t ble_gatts_prepare_write_cfm (uint8_t conn_idx, const ble_gatts_prep_write_cfm_t *p_param)
 Respond to an attribute prepare write request. More...
 
uint16_t ble_gatts_noti_ind (uint8_t conn_idx, const ble_gatts_noti_ind_t *p_param)
 Send out a notification or an indication. More...
 
void ble_gatts_service_changed (void)
 When service on local device finishes upgrade, call this API to send service upgrade to stack. If the bonded device connects again, the stack will send service change to the bonded device until the bonded device has sent back indication confirmation. More...
 

Detailed Description

BLE GATTS API.

Attention
#####Copyright (c) 2019 GOODIX All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of GOODIX nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file ble_gatts.h.