RA Flexible Software Package Documentation  Release v5.2.0

 

Functions

ble_status_t R_BLE_GATTS_Init (uint8_t cb_num)
 This function initializes the GATT Server and registers the number of the callbacks for GATT Server event. More...
 
ble_status_t R_BLE_GATTS_SetDbInst (st_ble_gatts_db_cfg_t *p_db_inst)
 This function sets GATT Database to host stack. More...
 
ble_status_t R_BLE_GATTS_RegisterCb (ble_gatts_app_cb_t cb, uint8_t priority)
 This function registers a callback for GATT Server event. More...
 
ble_status_t R_BLE_GATTS_DeregisterCb (ble_gatts_app_cb_t cb)
 This function deregisters the callback function for GATT Server event. More...
 
ble_status_t R_BLE_GATTS_Notification (uint16_t conn_hdl, st_ble_gatt_hdl_value_pair_t *p_ntf_data)
 This function sends a notification of an attribute's value. More...
 
ble_status_t R_BLE_GATTS_Indication (uint16_t conn_hdl, st_ble_gatt_hdl_value_pair_t *p_ind_data)
 This function sends a indication of an attribute's value. More...
 
ble_status_t R_BLE_GATTS_GetAttr (uint16_t conn_hdl, uint16_t attr_hdl, st_ble_gatt_value_t *p_value)
 This function gets a attribute value from the GATT Database. More...
 
ble_status_t R_BLE_GATTS_SetAttr (uint16_t conn_hdl, uint16_t attr_hdl, st_ble_gatt_value_t *p_value)
 This function sets an attribute value to the GATT Database. More...
 
ble_status_t R_BLE_GATTS_SendErrRsp (uint16_t error_code)
 This function sends an error response to a remote device. More...
 
ble_status_t R_BLE_GATTS_RspExMtu (uint16_t conn_hdl, uint16_t mtu)
 This function replies to a MTU Exchange Request from a remote device. More...
 
ble_status_t R_BLE_GATTS_SetPrepareQueue (st_ble_gatt_pre_queue_t *p_pre_queues, uint8_t queue_num)
 Register prepare queue and buffer in Host Stack. More...
 

Detailed Description

Data Structures

struct  st_ble_gatt_value_t
 Attribute Value. More...
 
struct  st_ble_gatt_hdl_value_pair_t
 Attribute handle and attribute Value. More...
 
struct  st_ble_gatt_queue_att_val_t
 Queued writes Attribute Value. More...
 
struct  st_ble_gatt_queue_pair_t
 Queued writes Attribute Value. More...
 
struct  st_ble_gatt_queue_elm_t
 Prepare Write Queue element for long chracteristic. More...
 
struct  st_ble_gatt_pre_queue_t
 Prepare Write Queue for long chracteristic. More...
 
struct  st_ble_gatts_db_params_t
 Attribute value to be set to or retrieved from the GATT Database and the access type from the GATT Client. More...
 
struct  st_ble_gatts_db_conn_hdl_t
 Information about the service or the characteristic that the attribute belongs to. More...
 
struct  st_ble_gatts_db_access_evt_t
 This structure notifies that the GATT Database has been accessed from a GATT Client. More...
 
struct  st_ble_gatts_conn_evt_t
 This structure notifies that the link with the GATT Client has been established. More...
 
struct  st_ble_gatts_disconn_evt_t
 This structure notifies that the link with the GATT Client has been disconnected. More...
 
struct  st_ble_gatts_ex_mtu_req_evt_t
 This structure notifies that a MTU Exchange Request PDU has been received from a GATT Client. More...
 
struct  st_ble_gatts_cfm_evt_t
 This structure notifies that a Confirmation PDU has been received from a GATT Client. More...
 
struct  st_ble_gatts_read_by_type_rsp_evt_t
 This structure notifies that a Read By Type Response PDU has been sent from GATT Server. More...
 
struct  st_ble_gatts_read_rsp_evt_t
 This structure notifies that a Read Response PDU has been sent from GATT Server. More...
 
struct  st_ble_gatts_read_blob_rsp_evt_t
 This structure notifies that a Read Blob Response PDU has been sent from GATT Server. More...
 
struct  st_ble_gatts_read_multi_rsp_evt_t
 This structure notifies that a Read Multiple Response PDU has been sent from GATT Server. More...
 
struct  st_ble_gatts_write_rsp_evt_t
 This structure notifies that a Write Response PDU has been sent from GATT Server. More...
 
struct  st_ble_gatts_prepare_write_rsp_evt_t
 This structure notifies that a Prepare Write Response PDU has been sent from GATT Server. More...
 
struct  st_ble_gatts_exe_write_rsp_evt_t
 This structure notifies that a Execute Write Response PDU has been sent from GATT Server. More...
 
struct  st_ble_gatts_db_uuid_cfg_t
 A structure that defines the information on the position where UUIDs are used. More...
 
struct  st_ble_gatts_db_attr_cfg_t
 A structure that defines the detailed information of the attributes. More...
 
struct  st_ble_gatts_db_attr_list_t
 The number of attributes are stored. More...
 
struct  st_ble_gatts_db_char_cfg_t
 A structure that defines the detailed information of the characteristics. More...
 
struct  st_ble_gatts_db_serv_cfg_t
 A structure that defines the detailed information of the characteristics. More...
 
struct  st_ble_gatts_db_cfg_t
 This is the structure of GATT Database that is specified in R_BLE_GATTS_SetDbInst(). More...
 
struct  st_ble_gatts_evt_data_t
 st_ble_gatts_evt_data_t is the type of the data notified in a GATT Server Event. More...
 

Macros

#define BLE_GATT_DEFAULT_MTU
 GATT Default MTU.
 
#define BLE_GATT_16_BIT_UUID_FORMAT
 GATT Identification for 16-bit UUID Format.
 
#define BLE_GATT_128_BIT_UUID_FORMAT
 GATT Identification for 128-bit UUID Format.
 
#define BLE_GATT_16_BIT_UUID_SIZE
 GATT 16-bit UUID Size.
 
#define BLE_GATT_128_BIT_UUID_SIZE
 GATT 128-bit UUID Size.
 
#define BLE_GATT_INVALID_ATTR_HDL_VAL
 GATT Invalid Attribute Handle Value.
 
#define BLE_GATT_ATTR_HDL_START_RANGE
 GATT Attribute Handle Start Range.
 
#define BLE_GATT_ATTR_HDL_END_RANGE
 GATT Attribute Handle End Range.
 
#define BLE_GATTS_CLI_CNFG_NOTIFICATION
 GATT Client Configuration values. Enable Notification.
 
#define BLE_GATTS_CLI_CNFG_INDICATION
 GATT Client Configuration values. Enable Indication.
 
#define BLE_GATTS_CLI_CNFG_DEFAULT
 GATT Client Configuration values. Default value or disable notification/indication.
 
#define BLE_GATTS_SER_CNFG_BROADCAST
 GATT Server Configuration values. Enable broadcast.
 
#define BLE_GATTS_SER_CNFG_DEFAULT
 GATT Server Configuration values. Default value.
 
#define BLE_GATTS_MAX_CB
 GATT Server Callback Number.
 
#define BLE_GATTS_OP_CHAR_VALUE_READ_REQ
 Characteristic Value Local Read Operation.
 
#define BLE_GATTS_OP_CHAR_VALUE_WRITE_REQ
 Characteristic Value Local Write Operation.
 
#define BLE_GATTS_OP_CHAR_VALUE_WRITE_WITHOUT_REQ
 Characteristic Value Local Write Without Response Operation.
 
#define BLE_GATTS_OP_CHAR_CLI_CNFG_READ_REQ
 Characteristic Client Configuration Local Read Operation.
 
#define BLE_GATTS_OP_CHAR_CLI_CNFG_WRITE_REQ
 Characteristic Client Configuration Local Write Operation.
 
#define BLE_GATTS_OP_CHAR_SER_CNFG_READ_REQ
 Characteristic Server Configuration Local Read Operation.
 
#define BLE_GATTS_OP_CHAR_SER_CNFG_WRITE_REQ
 Characteristic Server Configuration Local Write Operation.
 
#define BLE_GATTS_OP_CHAR_PEER_READ_REQ
 Characteristic Value Peer Read Operation.
 
#define BLE_GATTS_OP_CHAR_PEER_WRITE_REQ
 Characteristic Value Peer Write Operation.
 
#define BLE_GATTS_OP_CHAR_PEER_WRITE_CMD
 Characteristic Value Peer Write Command.
 
#define BLE_GATTS_OP_CHAR_PEER_CLI_CNFG_READ_REQ
 Characteristic Client Configuration Peer Read Operation.
 
#define BLE_GATTS_OP_CHAR_PEER_CLI_CNFG_WRITE_REQ
 Characteristic Client Configuration Peer Write Operation.
 
#define BLE_GATTS_OP_CHAR_PEER_SER_CNFG_READ_REQ
 Characteristic Server Configuration Peer Read Operation.
 
#define BLE_GATTS_OP_CHAR_PEER_SER_CNFG_WRITE_REQ
 Characteristic Server Configuration Peer Write Operation.
 
#define BLE_GATTS_OP_CHAR_PEER_USR_DESC_READ_REQ
 Characteristic User Description Peer Read Operation.
 
#define BLE_GATTS_OP_CHAR_PEER_USR_DESC_WRITE_REQ
 Characteristic User Description Peer Write Operation.
 
#define BLE_GATTS_OP_CHAR_PEER_HLD_DESC_READ_REQ
 Characteristic Higher Layer Defined Descriptor Peer Read Operation.
 
#define BLE_GATTS_OP_CHAR_PEER_HLD_DESC_WRITE_REQ
 Characteristic Higher Layer Defined Descriptor Peer Write Operation.
 
#define BLE_GATTS_OP_CHAR_REQ_AUTHOR
 Operation Required Authorization.
 
#define BLE_GATT_DB_READ
 Allow clients to read.
 
#define BLE_GATT_DB_WRITE
 Allow clients to write.
 
#define BLE_GATT_DB_WRITE_WITHOUT_RSP
 Allow clients to write without response.
 
#define BLE_GATT_DB_READ_WRITE
 Allow clients to access of all.
 
#define BLE_GATT_DB_NO_AUXILIARY_PROPERTY
 No auxiliary properties.
 
#define BLE_GATT_DB_FIXED_LENGTH_PROPERTY
 Fixed length attribute value.
 
#define BLE_GATT_DB_AUTHORIZATION_PROPERTY
 Attributes requiring authorization.
 
#define BLE_GATT_DB_ATTR_DISABLED
 The attribute is disabled. If this value is set, the attribute cannot be found and accessed by a GATT Client.
 
#define BLE_GATT_DB_128_BIT_UUID_FORMAT
 Attribute with 128 bit UUID.
 
#define BLE_GATT_DB_PEER_SPECIFIC_VAL_PROPERTY
 Attribute managed by each GATT Client.
 
#define BLE_GATT_DB_CONST_ATTR_VAL_PROPERTY
 Fixed attribute value.
 
#define BLE_GATT_DB_SER_SECURITY_UNAUTH
 Unauthenticated pairing(Security Mode1 Security Level 2, Security Mode 2 Security Level 1). Unauthenticated pairing is required to access the service.
 
#define BLE_GATT_DB_SER_SECURITY_AUTH
 Authenticated pairing(Security Mode1 Security Level 3, Security Mode 2 Security Level 2). Authenticated pairing is required to access the service.
 
#define BLE_GATT_DB_SER_SECURITY_SECONN
 Authenticated LE secure connections that generates 16bytes LTK(Security Mode1 Security Level 4). Authenticated LE secure connections pairing that generates 16bytes LTK is required to access the service. If this bit is set, bit24-27 are ignored.
 
#define BLE_GATT_DB_SER_SECURITY_ENC
 Encryption. Encryption by the LTK exchanged in pairing is required to access.
 
#define BLE_GATT_DB_SER_NO_SECURITY_PROPERTY
 No Security(Security Mode1 Security Level 1).
 
#define BLE_GATT_DB_SER_ENC_KEY_SIZE_DONT_CARE
 7-byte or larger encryption key.
 
#define BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_7
 7-byte encryption key.
 
#define BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_8
 8-byte encryption key.
 
#define BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_9
 9-byte encryption key.
 
#define BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_10
 10-byte encryption key.
 
#define BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_11
 11-byte encryption key.
 
#define BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_12
 12-byte encryption key.
 
#define BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_13
 13-byte encryption key.
 
#define BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_14
 14-byte encryption key.
 
#define BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_15
 15-byte encryption key.
 
#define BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_16
 16-byte encryption key.
 

Typedefs

typedef void(* ble_gatts_app_cb_t) (uint16_t event_type, ble_status_t event_result, st_ble_gatts_evt_data_t *p_event_data)
 ble_gatts_app_cb_t is the GATT Server Event callback function type. More...
 

Enumerations

enum  e_r_ble_gatts_evt_t
 GATT Server Event Identifier. More...
 

Data Structure Documentation

◆ st_ble_gatt_value_t

struct st_ble_gatt_value_t

Attribute Value.

Data Fields
uint16_t value_len Length of the attribute value.
uint8_t * p_value Attribute Value.

◆ st_ble_gatt_hdl_value_pair_t

struct st_ble_gatt_hdl_value_pair_t

Attribute handle and attribute Value.

Data Fields
uint16_t attr_hdl Attribute Handle.
st_ble_gatt_value_t value Attribute Value.

◆ st_ble_gatt_queue_att_val_t

struct st_ble_gatt_queue_att_val_t

Queued writes Attribute Value.

Data Fields
uint8_t * p_value Attribute Value for Queued Write .
uint16_t value_len Length of the attribute value.
uint16_t padding padding.

◆ st_ble_gatt_queue_pair_t

struct st_ble_gatt_queue_pair_t

Queued writes Attribute Value.

Data Fields
st_ble_gatt_queue_att_val_t queue_value Attribute Value for Queued Write.
uint16_t attr_hdl Attribute Handle.

◆ st_ble_gatt_queue_elm_t

struct st_ble_gatt_queue_elm_t

Prepare Write Queue element for long chracteristic.

Data Fields
st_ble_gatt_queue_pair_t queue_value_pair Part of Long Characteristic Value and Characteristic Value Handle.
uint16_t offset Offset that indicates the location to be written.

◆ st_ble_gatt_pre_queue_t

struct st_ble_gatt_pre_queue_t

Prepare Write Queue for long chracteristic.

Data Fields
uint8_t * p_buf_start Buffer start address for Write Long Characteristic Request.
st_ble_gatt_queue_elm_t * p_queue Prepare Write Queue for Long Characteristic Value.
uint16_t buffer_len Buffer length.
uint16_t conn_hdl Connection Handle.
uint16_t buf_offset Current buffer offset.
uint8_t queue_size Number of elements in the prepare write queue.
uint8_t queue_idx Index of Prepare Write Queue.

◆ st_ble_gatts_db_params_t

struct st_ble_gatts_db_params_t

Attribute value to be set to or retrieved from the GATT Database and the access type from the GATT Client.

Data Fields
st_ble_gatt_value_t value Attribute value to be set to or retrieved from the GATT Database. Note that the address of the value field in the value field is invalid in case of read access.
uint16_t attr_hdl Attribute handle identifying the attribute to be set or retrieved.
uint8_t db_op Type of the access to GATT Database from the GATT Client.
See also
access_type_to_gatt_database

◆ st_ble_gatts_db_conn_hdl_t

struct st_ble_gatts_db_conn_hdl_t

Information about the service or the characteristic that the attribute belongs to.

Data Fields
uint16_t conn_hdl Connection handle identifying the GATT Client that accesses to the GATT DataBase.
uint8_t service_id ID of the service that the attribute belongs to.
uint8_t char_id ID of the Characteristic that the attribute belongs to.

◆ st_ble_gatts_db_access_evt_t

struct st_ble_gatts_db_access_evt_t

This structure notifies that the GATT Database has been accessed from a GATT Client.

Data Fields
st_ble_gatts_db_conn_hdl_t * p_handle Information about the service or the characteristic that the attribute belongs to.
st_ble_gatts_db_params_t * p_params Attribute value to be set to or retrieved from the GATT Database and the access type from the GATT Client.

◆ st_ble_gatts_conn_evt_t

struct st_ble_gatts_conn_evt_t

This structure notifies that the link with the GATT Client has been established.

Data Fields
st_ble_dev_addr_t * p_addr Address of the GATT Client.

◆ st_ble_gatts_disconn_evt_t

struct st_ble_gatts_disconn_evt_t

This structure notifies that the link with the GATT Client has been disconnected.

Data Fields
st_ble_dev_addr_t * p_addr Address of the GATT Client.

◆ st_ble_gatts_ex_mtu_req_evt_t

struct st_ble_gatts_ex_mtu_req_evt_t

This structure notifies that a MTU Exchange Request PDU has been received from a GATT Client.

Data Fields
uint16_t mtu Maximum receive MTU size by GATT Client.

◆ st_ble_gatts_cfm_evt_t

struct st_ble_gatts_cfm_evt_t

This structure notifies that a Confirmation PDU has been received from a GATT Client.

Data Fields
uint16_t attr_hdl Attribute handle identifying the Characteristic sent by the Indication PDU.

◆ st_ble_gatts_read_by_type_rsp_evt_t

struct st_ble_gatts_read_by_type_rsp_evt_t

This structure notifies that a Read By Type Response PDU has been sent from GATT Server.

Data Fields
uint16_t attr_hdl Attribute handle identifying the Characteristic read by the Read By Type Request PDU.

◆ st_ble_gatts_read_rsp_evt_t

struct st_ble_gatts_read_rsp_evt_t

This structure notifies that a Read Response PDU has been sent from GATT Server.

Data Fields
uint16_t attr_hdl Attribute handle identifying the Characteristic read by the Read Request PDU.

◆ st_ble_gatts_read_blob_rsp_evt_t

struct st_ble_gatts_read_blob_rsp_evt_t

This structure notifies that a Read Blob Response PDU has been sent from GATT Server.

Data Fields
uint16_t attr_hdl Attribute handle identifying the Characteristic read by the Read Blob Request PDU.

◆ st_ble_gatts_read_multi_rsp_evt_t

struct st_ble_gatts_read_multi_rsp_evt_t

This structure notifies that a Read Multiple Response PDU has been sent from GATT Server.

Data Fields
uint8_t count The number of attribute read by the Read Multiple Request PDU.
uint16_t * p_attr_hdl_list The list of attribute read by the Read Multiple Request PDU.

◆ st_ble_gatts_write_rsp_evt_t

struct st_ble_gatts_write_rsp_evt_t

This structure notifies that a Write Response PDU has been sent from GATT Server.

Data Fields
uint16_t attr_hdl Attribute handle identifying the Characteristic written by the Write Request PDU.

◆ st_ble_gatts_prepare_write_rsp_evt_t

struct st_ble_gatts_prepare_write_rsp_evt_t

This structure notifies that a Prepare Write Response PDU has been sent from GATT Server.

Data Fields
uint16_t attr_hdl Attribute handle identifying the Characteristic written by the Prepare Write Request PDU.
uint16_t length The length of written bytes by the Prepare Write Request PDU.
uint16_t offset The offset of the first octet to be written.

◆ st_ble_gatts_exe_write_rsp_evt_t

struct st_ble_gatts_exe_write_rsp_evt_t

This structure notifies that a Execute Write Response PDU has been sent from GATT Server.

Data Fields
uint8_t exe_flag The flag that indicates whether execution or cancellation.
value description
0x00 Cancellation.
0x01 Execution.

◆ st_ble_gatts_db_uuid_cfg_t

struct st_ble_gatts_db_uuid_cfg_t

A structure that defines the information on the position where UUIDs are used.

Data Fields
uint16_t offset The position of the defined UUID is specified by offset value in uuid_table of st_ble_gatts_db_cfg_t.
uint16_t first The attribute handle that indicates the first position in st_ble_gatts_db_attr_cfg_t for the defined UUID is specified.
uint16_t last The attribute handle that indicates the last position in st_ble_gatts_db_attr_cfg_t for the defined UUID is specified.

◆ st_ble_gatts_db_attr_cfg_t

struct st_ble_gatts_db_attr_cfg_t

A structure that defines the detailed information of the attributes.

Data Fields
uint8_t desc_prop The properties of attribute are specified.

Set the following properties by a bitwise OR.

macro description
BLE_GATT_DB_READ(0x01) Allow clients to read.
BLE_GATT_DB_WRITE(0x02) Allow clients to write.
BLE_GATT_DB_WRITE_WITHOUT_RSP(0x04) Allow clients to write.
BLE_GATT_DB_READ_WRITE(0x07) Allow clients to access of all.
uint8_t aux_prop The auxiliary properties of attribute are specified.

Set the following properties by a bitwise OR.

macro description
BLE_GATT_DB_NO_AUXILIARY_PROPERTY(0x00) No auxiliary properties.
It is invalid when used with other properties at the same time.
BLE_GATT_DB_FIXED_LENGTH_PROPERTY(0x01) Fixed length attribute value.
BLE_GATT_DB_AUTHORIZATION_PROPERTY(0x02) Attributes requiring authorization.
BLE_GATT_DB_ATTR_DISABLED(0x10) The attribute is disabled. If this value is set, the attribute cannot be found and accessed by a GATT Client. It is invalid when used with other properties at the same time.
BLE_GATT_DB_128_BIT_UUID_FORMAT(0x20) Attribute with 128 bit UUID.
If this macro is not set, the attribute value is 16-bits UUID.
BLE_GATT_DB_PEER_SPECIFIC_VAL_PROPERTY(0x40) Attribute managed by each GATT Client.
BLE_GATT_DB_CONST_ATTR_VAL_PROPERTY(0x80) Fixed attribute value.
Writing from Client and setting from Server are prohibited.
uint16_t length The length of the attribute value is specified.
uint16_t next The position of the next attribute with the same UUID as the defined attribute is specified by an attribute handle.
uint16_t uuid_offset The storage area of attribute value.

UUID of the defined attribute is set by specifying the position of the UUID registered in uuid_table of st_ble_gatts_db_cfg_t with the array offset value.

uint8_t * p_data_offset Storage area of attribute value.

The address in the array registered in No.1-No.4 is specified to set the attribute value storage area of the defined attribute.

◆ st_ble_gatts_db_attr_list_t

struct st_ble_gatts_db_attr_list_t

The number of attributes are stored.

Data Fields
uint8_t count The number of the services or the characteristics.

◆ st_ble_gatts_db_char_cfg_t

struct st_ble_gatts_db_char_cfg_t

A structure that defines the detailed information of the characteristics.

Data Fields
st_ble_gatts_db_attr_list_t list The total number of attributes in the defined characteristic is specified.
uint16_t start_hdl The first attribute handle of the characteristic is specified.
uint8_t service_id The index of service to which the characteristic belongs is specified.

◆ st_ble_gatts_db_serv_cfg_t

struct st_ble_gatts_db_serv_cfg_t

A structure that defines the detailed information of the characteristics.

Data Fields
st_ble_gatts_db_attr_list_t list The total number of service declarations in the defined service is specified.
uint32_t desc The properties of the defined service are specified.

Set the security level, the security mode and the key size with a bitwise OR. The bit0-bit3 are specified as the security level. Select one of the following.

macro description
BLE_GATT_DB_SER_SECURITY_UNAUTH(0x00000001) Unauthenticated pairing(Security Mode1 Security Level 2, Security Mode 2 Security Level 1)
Unauthenticated pairing is required to access the service.
BLE_GATT_DB_SER_SECURITY_AUTH(0x00000002) Authenticated pairing(Security Mode1 Security Level 3, Security Mode 2 Security Level 2)
Authenticated pairing is required to access the service.
BLE_GATT_DB_SER_SECURITY_SECONN(0x00000004) Authenticated LE secure connections that generates 16bytes LTK(Security Mode1 Security Level 4)
Authenticated LE secure connections pairing that generates 16bytes LTK is required to access the service. If this bit is set, bit24-27 are ignored.


The bit4 is specified as the security mode.

macro description
BLE_GATT_DB_SER_SECURITY_ENC(0x00000010) Encryption
Encryption by the LTK exchanged in pairing is required to access.


If the security requirement of the service is not needed, specify the bit0-bit4 to BLE_GATT_DB_SER_NO_SECURITY_PROPERTY(0x00000000).(Security Mode1 Security Level 1)
The bit24-bit27 are specified as the key size required by the defined service.
Select one of the following.

macro description
BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_7(0x01000000) 7-byte encryption key.
BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_8(0x02000000) 8-byte encryption key.
BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_9(0x03000000) 9-byte encryption key.
BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_10(0x04000000) 10-byte encryption key.
BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_11(0x05000000) 11-byte encryption key.
BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_12(0x06000000) 12-byte encryption key.
BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_13(0x07000000) 13-byte encryption key.
BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_14(0x08000000) 14-byte encryption key.
BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_15(0x09000000) 15-byte encryption key.
BLE_GATT_DB_SER_ENCRYPT_KEY_SIZE_16(0x0A000000) 16-byte encryption key.
BLE_GATT_DB_SER_ENC_KEY_SIZE_DONT_CARE(0x00000000) 7-byte or larger encryption key.


Other bits are reserved.

uint16_t start_hdl The start attribute handle of the defined service is specified.
uint16_t end_hdl The end attribute handle of the defined service is specified.
uint8_t char_start_idx The start index of the characteristic that belongs to the defined service is specified.
uint8_t char_end_idx The end index of the characteristic that belongs to the defined service is specified.

◆ st_ble_gatts_db_cfg_t

struct st_ble_gatts_db_cfg_t

This is the structure of GATT Database that is specified in R_BLE_GATTS_SetDbInst().

Data Fields
const uint8_t * p_uuid_table The array to register the UUID to be used.
uint8_t * p_attr_val_table The array to register variable attribute values.
const uint8_t * p_const_attr_val_table The array to register fixed attribute values.
uint8_t * p_rem_spec_val_table The array to manage the attribute values handled for each GATT client.
const uint8_t * p_const_rem_spec_val_table The array to register the default of the attribute value handled by each GATT client.
const st_ble_gatts_db_uuid_cfg_t * p_uuid_cfg The array to register information on the position where UUIDs are used.
const st_ble_gatts_db_attr_cfg_t * p_attr_cfg The array to register the detailed information of attributes.
const st_ble_gatts_db_char_cfg_t * p_char_cfg The array to register the detailed information of characteristics.
const st_ble_gatts_db_serv_cfg_t * p_serv_cfg The array to register the detailed information of services.
uint8_t serv_cnt The number of services included in the GATT Database.
uint8_t char_cnt The number of characteristics included in the GATT Database.
uint8_t uuid_type_cnt The number of UUIDs included in the GATT Database.
uint8_t peer_spec_val_cnt The total size of attribute value that needs to be managed for each GATT client.

◆ st_ble_gatts_evt_data_t

struct st_ble_gatts_evt_data_t

st_ble_gatts_evt_data_t is the type of the data notified in a GATT Server Event.

Data Fields
uint16_t conn_hdl Connection handle identifying the GATT Client.
uint16_t param_len The size of GATT Server Event parameters.
void * p_param GATT Server Event parameters. This parameter differs in each GATT Server Event.

Typedef Documentation

◆ ble_gatts_app_cb_t

ble_gatts_app_cb_t

ble_gatts_app_cb_t is the GATT Server Event callback function type.

Parameters
[in]event_typeThe type of GATT Server Event.
[in]event_resultThe result of GATT Server Event
[in]p_event_dataData notified by GATT Server Event.
Returns
none

Enumeration Type Documentation

◆ e_r_ble_gatts_evt_t

GATT Server Event Identifier.

Enumerator
BLE_GATTS_EVENT_EX_MTU_REQ 

MTU Exchange Request has been received.

This event notifies the application layer that a MTU Exchange Request PDU has been received from a GATT Client. Need to reply to the request by R_BLE_GATTS_RspExMtu().

Event Code: 0x3002

Event Data:

st_ble_gatts_ex_mtu_req_evt_tBLE_GATTS_EVENT_EX_MTU_REQ

BLE_GATTS_EVENT_READ_BY_TYPE_RSP_COMP 

Read By Type Response has been sent.

This event notifies the application layer that a Read By Type Response PDU has been sent from GATT Server to the GATT Client.

Event Code: 0x3009

Event Data:

st_ble_gatts_read_by_type_rsp_evt_tBLE_GATTS_EVENT_READ_BY_TYPE_RSP_COMP

BLE_GATTS_EVENT_READ_RSP_COMP 

Read Response has been sent.

This event notifies the application layer that a Read Response PDU has been sent from GATT Server to the GATT Client.

Event Code: 0x300B

Event Data:

st_ble_gatts_read_rsp_evt_tBLE_GATTS_EVENT_READ_RSP_COMP

BLE_GATTS_EVENT_READ_BLOB_RSP_COMP 

Read Blob Response has been sent.

This event notifies the application layer that a Read Blob Response PDU has been sent from GATT Server to the GATT Client.

Event Code: 0x300D

Event Data:

st_ble_gatts_read_blob_rsp_evt_tBLE_GATTS_EVENT_READ_BLOB_RSP_COMP

BLE_GATTS_EVENT_READ_MULTI_RSP_COMP 

Read Multiple Response has been sent.

This event notifies the application layer that a Read Multiple Response PDU has been sent from GATT Server to the GATT Client.

Event Code: 0x300F

Event Data:

st_ble_gatts_read_multi_rsp_evt_tBLE_GATTS_EVENT_READ_MULTI_RSP_COMP

BLE_GATTS_EVENT_WRITE_RSP_COMP 

Write Response has been sent.

This event notifies the application layer that a Write Response PDU has been sent from GATT Server to the GATT Client.

Event Code: 0x3013

Event Data:

st_ble_gatts_write_rsp_evt_tBLE_GATTS_EVENT_WRITE_RSP_COMP

BLE_GATTS_EVENT_PREPARE_WRITE_RSP_COMP 

Prepare Write Response has been sent.

This event notifies the application layer that a Prepare Write Response PDU has been sent from GATT Server to the GATT Client.

Event Code: 0x3017

Event Data:

st_ble_gatts_prepare_write_rsp_evt_tBLE_GATTS_EVENT_PREPARE_WRITE_RSP_COMP

BLE_GATTS_EVENT_EXE_WRITE_RSP_COMP 

Execute Write Response has been sent.

This event notifies the application layer that a Execute Write Response PDU has been sent from GATT Server to the GATT Client.

Event Code: 0x3019

Event Data:

st_ble_gatts_exe_write_rsp_evt_tBLE_GATTS_EVENT_EXE_WRITE_RSP_COMP

BLE_GATTS_EVENT_HDL_VAL_CNF 

Confirmation has been received.

This event notifies the application layer that a Confirmation PDU has been received from a GATT Client.

Event Code: 0x301E

Event Data:

st_ble_gatts_cfm_evt_tBLE_GATTS_EVENT_HDL_VAL_CNF

BLE_GATTS_EVENT_DB_ACCESS_IND 

The GATT Database has been accessed from a GATT Client.

This event notifies the application layer that the GATT Database has been accessed from a GATT Client.

Event Code: 0x3040

Event Data:

st_ble_gatts_db_access_evt_tBLE_GATTS_EVENT_DB_ACCESS_IND

BLE_GATTS_EVENT_CONN_IND 

A connection has been established.

This event notifies the application layer that the link with the GATT Client has been established.

Event Code: 0x3081

Event Data:

st_ble_gatts_conn_evt_tBLE_GATTS_EVENT_CONN_IND

BLE_GATTS_EVENT_DISCONN_IND 

A connection has been disconnected.

This event notifies the application layer that the link with the GATT Client has been disconnected.

Event Code: 0x3082

Event Data:

st_ble_gatts_disconn_evt_tBLE_GATTS_EVENT_DISCONN_IND

BLE_GATTS_EVENT_INVALID 

Invalid GATT Server Event.

Event Code: 0x30FF

Event Data:

noneBLE_GATTS_EVENT_INVALID

Function Documentation

◆ R_BLE_GATTS_Init()

ble_status_t R_BLE_GATTS_Init ( uint8_t  cb_num)

This function initializes the GATT Server and registers the number of the callbacks for GATT Server event.

Specify the cb_num parameter to a value between 1 and BLE_GATTS_MAX_CB.
R_BLE_GATTS_RegisterCb() registers the callback.
The result of this API call is returned by a return value.

Parameters
[in]cb_numThe number of callbacks to be registered.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_ARG(0x0003)The cb_num parameter is out of range.

◆ R_BLE_GATTS_SetDbInst()

ble_status_t R_BLE_GATTS_SetDbInst ( st_ble_gatts_db_cfg_t p_db_inst)

This function sets GATT Database to host stack.

The result of this API call is returned by a return value.

Parameters
[in]p_db_instGATT Database to be set.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_PTR(0x0001)The reason for this error is as follows.
  • The db_inst parameter is specified as NULL.
  • The array in the db_inst is specified as NULL.

◆ R_BLE_GATTS_RegisterCb()

ble_status_t R_BLE_GATTS_RegisterCb ( ble_gatts_app_cb_t  cb,
uint8_t  priority 
)

This function registers a callback for GATT Server event.

The number of the callback that may be registered by this function is the value specified by R_BLE_GATTS_Init().
The result of this API call is returned by a return value.

Parameters
[in]cbCallback function for GATT Server event.
[in]priorityThe priority of the callback function.
Valid range is 1 <= priority <= BLE_GATTS_MAX_CB.
A lower priority number means a higher priority level.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_PTR(0x0001)The cb parameter is specified as NULL.
BLE_ERR_INVALID_ARG(0x0003)The priority parameter is out of range.
BLE_ERR_CONTEXT_FULL(0x000B)Host stack has already registered the maximum number of callbacks.

◆ R_BLE_GATTS_DeregisterCb()

ble_status_t R_BLE_GATTS_DeregisterCb ( ble_gatts_app_cb_t  cb)

This function deregisters the callback function for GATT Server event.

The result of this API call is returned by a return value.

Parameters
[in]cbThe callback function to be deregistered.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_PTR(0x0001)The cb parameter is specified as NULL.
BLE_ERR_NOT_FOUND(0x000D)The callback has not been registered.

◆ R_BLE_GATTS_Notification()

ble_status_t R_BLE_GATTS_Notification ( uint16_t  conn_hdl,
st_ble_gatt_hdl_value_pair_t p_ntf_data 
)

This function sends a notification of an attribute's value.

The maximum length of the attribute value that can be sent with notification is MTU-3.
The result of this API call is returned by a return value.

Parameters
[in]conn_hdlConnection handle identifying the remote device to be sent the notification.
[in]p_ntf_dataThe attribute value to send.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_PTR(0x0001)The p_ntf_data parameter or the value field in the value field in the p_ntf_data parameter is NULL.
BLE_ERR_INVALID_ARG(0x0003)The value_len field in the value field in the p_ntf_data parameter is 0 or the attr_hdl field in the p_ntf_data parameters is 0.
BLE_ERR_INVALID_OPERATION(0x0009)This function was called while processing other request.
BLE_ERR_MEM_ALLOC_FAILED(0x000C)Insufficient memory is needed to generate this function.
BLE_ERR_INVALID_HDL(0x000E)The remote device specified by conn_hdl was not found.

◆ R_BLE_GATTS_Indication()

ble_status_t R_BLE_GATTS_Indication ( uint16_t  conn_hdl,
st_ble_gatt_hdl_value_pair_t p_ind_data 
)

This function sends a indication of an attribute's value.

The maximum length of the attribute value that can be sent with indication is MTU-3.
The result of this API call is returned by a return value.
The remote device that receives a indication sends a confirmation.
BLE_GATTS_EVENT_HDL_VAL_CNF event notifies the application layer that the confirmation has been received.

Parameters
[in]conn_hdlConnection handle identifying the remote device to be sent the indication.
[in]p_ind_dataThe attribute value to send.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_PTR(0x0001)The p_ind_data parameter or the value field in the value field in the p_ind_data parameter is NULL.
BLE_ERR_INVALID_ARG(0x0003)The value_len field in the value field in the p_ind_data parameter is 0 or the attr_hdl field in the p_ind_data parameters is 0.
BLE_ERR_INVALID_OPERATION(0x0009)This function was called while processing other request.
BLE_ERR_MEM_ALLOC_FAILED(0x000C)Insufficient memory is needed to generate this function.
BLE_ERR_INVALID_HDL(0x000E)The remote device specified by conn_hdl was not found.

◆ R_BLE_GATTS_GetAttr()

ble_status_t R_BLE_GATTS_GetAttr ( uint16_t  conn_hdl,
uint16_t  attr_hdl,
st_ble_gatt_value_t p_value 
)

This function gets a attribute value from the GATT Database.

The result of this API call is returned by a return value.

Parameters
[in]conn_hdlIf the attribute value that has information about the remote device is retrieved, specify the remote device with the conn_hdl parameter. When information about the remote device is not required, set the conn_hdl parameter to BLE_GAP_INVALID_CONN_HDL.
[in]attr_hdlThe attribute handle of the attribute value to be retrieved.
[out]p_valueThe attribute value to be retrieved.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_PTR(0x0001)The p_value parameter is specified as NULL.
BLE_ERR_INVALID_ARG(0x0003)The attr_hdl parameter is 0 or larger than the last attribute handle of GATT Database.
BLE_ERR_INVALID_STATE(0x0008)The attribute is not in a state to be read.
BLE_ERR_INVALID_OPERATION(0x0009)The attribute cannot be read.
BLE_ERR_NOT_FOUND(0x000D)The attribute specified by the attr_hdl parameter is not belonging to any services or characteristics.
BLE_ERR_INVALID_HDL(0x000E)The remote device specified by the conn_hdl parameter was not found.

◆ R_BLE_GATTS_SetAttr()

ble_status_t R_BLE_GATTS_SetAttr ( uint16_t  conn_hdl,
uint16_t  attr_hdl,
st_ble_gatt_value_t p_value 
)

This function sets an attribute value to the GATT Database.

The result of this API call is returned by a return value.

Parameters
[in]conn_hdlIf the attribute value that has information about the remote device is retrieved, specify the remote device with the conn_hdl parameter. When information about the remote device is not required, set the conn_hdl parameter to BLE_GAP_INVALID_CONN_HDL.
[in]attr_hdlThe attribute handle of the attribute value to be set.
[in]p_valueThe attribute value to be set.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_PTR(0x0001)The p_value parameter is specified as NULL.
BLE_ERR_INVALID_DATA(0x0002)The write size is larger than the length of the attribute value.
BLE_ERR_INVALID_ARG(0x0003)The attr_hdl parameter is 0 or larger than the last attribute handle of GATT Database.
BLE_ERR_INVALID_STATE(0x0008)The attribute is not in a state to be written.
BLE_ERR_INVALID_OPERATION(0x0009)The attribute cannot be written.
BLE_ERR_NOT_FOUND(0x000D)The attribute specified by the attr_hdl parameter is not belonging to any services or characteristics.
BLE_ERR_INVALID_HDL(0x000E)The remote device specified by the conn_hdl parameter was not found.

◆ R_BLE_GATTS_SendErrRsp()

ble_status_t R_BLE_GATTS_SendErrRsp ( uint16_t  error_code)

This function sends an error response to a remote device.

The result is returned from the API.
The error code specified in the callback is notified as Error Response to the remote device.
The result of this API call is returned by a return value.

Parameters
[in]error_codeThe error codes to be notified the client.
It is a bitwise OR of GATT Error Group ID : 0x3000 and the following error codes defined in Core Spec and Core Spec Supplement.
Error Code description
BLE_ERR_GATT_INVALID_HANDLE(0x3001) Invalid attribute handle
BLE_ERR_GATT_READ_NOT_PERMITTED(0x3002) The attribute cannot be read.
BLE_ERR_GATT_WRITE_NOT_PERMITTED(0x3003) The attribute cannot be written.
BLE_ERR_GATT_INVALID_PDU(0x3004) Invalid PDU.
BLE_ERR_GATT_INSUFFICIENT_AUTHENTICATION(0x3005) The authentication to access the attribute is insufficient.
BLE_ERR_GATT_REQUEST_NOT_SUPPORTED(0x3006) The request is not supported.
BLE_ERR_GATT_INVALID_OFFSET(0x3007) The specified offset is larger than the length of the attribute value.
BLE_ERR_GATT_INSUFFICIENT_AUTHORIZATION(0x3008) Authorization is required to access the attribute.
BLE_ERR_GATT_PREPARE_WRITE_QUEUE_FULL(0x3009) The Write Queue in the GATT Server is full.
BLE_ERR_GATT_ATTRIBUTE_NOT_FOUND(0x300A) The specified attribute is not found.
BLE_ERR_GATT_ATTRIBUTE_NOT_LONG(0x300B) The attribute cannot be read by Read Blob Request.
BLE_ERR_GATT_INSUFFICIENT_ENC_KEY_SIZE(0x300C) The Encryption Key Size is insufficient.
BLE_ERR_GATT_INVALID_ATTRIBUTE_LEN(0x300D) The length of the specified attribute is invalid.
BLE_ERR_GATT_UNLIKELY_ERROR(0x300E) Because an error has occurred, the process cannot be advanced.
BLE_ERR_GATT_INSUFFICIENT_ENCRYPTION(0x300F) Encryption is required to access the attribute.
BLE_ERR_GATT_UNSUPPORTED_GROUP_TYPE(0x3010) The type of the specified attribute is not supported.
BLE_ERR_GATT_INSUFFICIENT_RESOURCES(0x3011) The resource to complete the request is insufficient.
0x3080 - 0x309F Application Error. The upper layer defines the error codes.
0x30E0 - 0x30FF The error code defined in Common Profile and Service Error Core Specification Supplement(CSS).
CSS ver.7 defines the error codes from 0x30FC to 0x30FF.
BLE_ERR_GATT_WRITE_REQ_REJECTED(0x30FC) The Write Request has not been completed due to the reason other than Permission.
BLE_ERR_GATT_CCCD_IMPROPERLY_CFG(0x30FD) The CCCD is set to be invalid.
BLE_ERR_GATT_PROC_ALREADY_IN_PROGRESS(0x30FE) The request is now in progress.
BLE_ERR_GATT_OUT_OF_RANGE(0x30FF) The attribute value is out of range.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_ARG(0x0003)The Group ID of the error_code parameter is not 0x3000, or it is 0x3000.
BLE_ERR_INVALID_OPERATION(0x0009)While processing other error response,this function was called.

◆ R_BLE_GATTS_RspExMtu()

ble_status_t R_BLE_GATTS_RspExMtu ( uint16_t  conn_hdl,
uint16_t  mtu 
)

This function replies to a MTU Exchange Request from a remote device.

BLE_GATTS_EVENT_EX_MTU_REQ event notifies the application layer that a MTU Exchange Request has been received. Therefore when the callback has received the event, call this function.
The new MTU is the minimum of the mtu parameter specified by this function and the mtu field in BLE_GATTS_EVENT_EX_MTU_REQ event.
Default MTU size is 23 bytes.
The result of this API call is returned by a return value.

Parameters
[in]conn_hdlConnection handle identifying the remote device to be sent MTU Exchange Response.
[in]mtuThe maximum size(in bytes) of the GATT PDU that GATT Server can receive.
Valid range is 23 <= mtu <= 247.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_ARG(0x0003)The mtu parameter is out of range.
BLE_ERR_INVALID_OPERATION(0x0009)This function was called while processing other request.
BLE_ERR_MEM_ALLOC_FAILED(0x000C)Insufficient memory is needed to generate this function.
BLE_ERR_INVALID_HDL(0x000E)The remote device specified by conn_hdl was not found.

◆ R_BLE_GATTS_SetPrepareQueue()

ble_status_t R_BLE_GATTS_SetPrepareQueue ( st_ble_gatt_pre_queue_t p_pre_queues,
uint8_t  queue_num 
)

Register prepare queue and buffer in Host Stack.

This function registers the prepare queue and buffer for long chracteristic write and reliable writes. The result of this API call is returned by a return value.

Parameters
[in]p_pre_queuesThe prepare write queues to be registered.
[in]queue_numThe number of prepare write queues to be registered.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_PTR(0x0001)The p_pre_queue parameter is specified as NULL.