ble_gatts.h File Reference

BLE GATTS API. More...

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

Go to the source code of this file.

Data Structures

struct  attm_desc_t
 Service(16-bit UUID) description. More...
 
struct  attm_desc_128_t
 Service(128 bits UUID) description. More...
 
struct  gatts_create_db_t
 Parameter of Added service description. More...
 
union  gatts_create_db_t::attribute_table
 
struct  gatts_read_cfm_t
 GATT read attribute result description. More...
 
struct  gatts_write_cfm_t
 GATT write attribute result description. More...
 
struct  gatts_prep_write_cfm_t
 GATT prepare write result description. More...
 
struct  gatts_noti_ind_t
 GATT sending Notification or Indication event param description. More...
 

Macros

#define MAX_INC_SRVC_NUM   (5)
 
#define BROADCAST   (0x01)
 
#define READ   (0x02)
 
#define WRITE_CMD   (0x04)
 
#define WRITE_REQ   (0x08)
 
#define NOTIFY   (0x10)
 
#define INDICATE   (0x20)
 
#define WRITE_SIGNED   (0x40)
 
#define EXT_PROP   (0x80)
 
#define READ_POS   (0x00)
 
#define WRITE_POS   (0x02)
 
#define INDICATE_POS   (0x04)
 
#define NOTIFY_POS   (0x06)
 
#define NOAUTH   (0x00)
 
#define UNAUTH   (0x01)
 
#define AUTH   (0x02)
 
#define SEC_CON   (0x03)
 
#define SEC_LEVEL_MASK   (0x03)
 
#define UUID_TYPE_16   (0x00)
 
#define UUID_TYPE_128   (0x02)
 
#define SRVC_SECONDARY_SET   (0x80)
 
#define SRVC_UUID_TYPE_SET(uuid_len)   ((uuid_len) << 5)
 
#define SRVC_DISABLE   (0x10)
 
#define SRVC_PERM(sec_level)   (((sec_level) & SEC_LEVEL_MASK) << 2)
 
#define SRVC_ENCRP_KEY_SIZE_16   (0x02)
 
#define SRVC_MULTI_ENABLE   (0x01)
 
#define READ_PERM_UNSEC   (READ << 8)
 
#define READ_PERM(sec_level)   (READ << 8 | (((sec_level) & SEC_LEVEL_MASK) << READ_POS))
 
#define WRITE_REQ_PERM_UNSEC   (WRITE_REQ << 8)
 
#define WRITE_REQ_PERM(sec_level)   (WRITE_REQ << 8 | (((sec_level) & SEC_LEVEL_MASK) << WRITE_POS))
 
#define WRITE_CMD_PERM_UNSEC   (WRITE_CMD << 8)
 
#define WRITE_CMD_PERM(sec_level)   (WRITE_CMD << 8 | (((sec_level) & SEC_LEVEL_MASK) << WRITE_POS))
 
#define WRITE_SIGNED_PERM_UNSEC   (WRITE_SIGNED << 8)
 
#define WRITE_SIGNED_PERM(sec_level)   (WRITE_SIGNED << 8 | (((sec_level) & SEC_LEVEL_MASK) << WRITE_POS))
 
#define INDICATE_PERM_UNSEC   (INDICATE << 8)
 
#define INDICATE_PERM(sec_level)   (INDICATE << 8 | (((sec_level) & SEC_LEVEL_MASK) << INDICATE_POS))
 
#define NOTIFY_PERM_UNSEC   (NOTIFY << 8)
 
#define NOTIFY_PERM(sec_level)   (NOTIFY << 8 | (((sec_level) & SEC_LEVEL_MASK) << NOTIFY_POS))
 
#define BROADCAST_ENABLE   (BROADCAST << 8)
 
#define EXT_PROP_ENABLE   (EXT_PROP << 8)
 
#define ATT_VAL_LOC_USER   (1 << 15)
 
#define ATT_VAL_LOC_STACK   (0 << 15)
 
#define ATT_UUID_TYPE_SET(uuid_len)   ((uuid_len) << 13)
 
#define ATT_ENC_KEY_SIZE_16   (0x1000)
 

Enumerations

enum  gatts_service_type_t { SERVICE_TABLE_TYPE_16 = 0x00, SERVICE_TABLE_TYPE_128 }
 Service table type. More...
 

Functions

uint16_t ble_gatts_srvc_db_create (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 gatts_read_cfm_t *p_param)
 Respond to an attribute read request. It is used in profile read callback function gatts_prf_cbs_t::app_gatts_read_cb to send attribute value to stack which is saved in user space. More...
 
uint16_t ble_gatts_write_cfm (uint8_t conn_idx, const gatts_write_cfm_t *p_param)
 Respond to an attribute write request. It is used in profile write callback function gatts_prf_cbs_t::app_gatts_write_cb to send write operation status to stack. More...
 
uint16_t ble_gatts_prepare_write_cfm (uint8_t conn_idx, const gatts_prep_write_cfm_t *p_param)
 Respond to an attribute prepare write request. It is used in profile prepare write callback function gatts_prf_cbs_t::app_gatts_prep_write_cb to send prepare write operation status to stack. More...
 
uint16_t ble_gatts_noti_ind (uint8_t conn_idx, const gatts_noti_ind_t *p_param)
 Send out a notification or an indication. The execution status of sending notification or indication will be retrieved in the complete callback function gatts_prf_cbs_t::app_gatts_ntf_ind_cb. 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.
 

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.