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

Function Documentation

◆ ble_gatts_attr_permission_get()

uint16_t ble_gatts_attr_permission_get ( uint16_t  handle,
uint16_t *  p_perm,
uint16_t *  p_ext_perm 
)

Retrieve attribute permission.

Parameters
[in]handleAttribute handle.
[out]p_permAttribute permission value to be returned.
[out]p_ext_permAttribute extended permission value to be returned.
Return values
SDK_SUCCESSRetrieve attribute permission successfully.
SDK_ERR_POINTER_NULLPerm or ext_perm is NULL.
SDK_ERR_INVALID_HANDLEHandle not exist in the database.

◆ ble_gatts_attr_permission_set()

uint16_t ble_gatts_attr_permission_set ( uint16_t  handle,
uint16_t  perm,
uint16_t  ext_perm 
)

Update attribute permission.

Note
The modifications of attribute permission to service/character/include/character_extended_properties_descriptor declaration: not supported.
The modifications of attribute permission to others: perm can be updated and EKS of ext_perm can be updated.See Attribute Permission.
Parameters
[in]handleAttribute handle.
[in]permNew attribute permission.
[in]ext_permNew attribute extended permission.
Return values
SDK_SUCCESSUpdate attribute permission successfully.
SDK_ERR_INVALID_HANDLEHandle not exist in the database.
SDK_ERR_REQ_NOT_SUPPORTEDAttribute permission can't be modified.

◆ ble_gatts_noti_ind()

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.

Note
Check whether the relevant Client Characteristic Configuration Descriptor is enabled before using this API.
Parameters
[in]conn_idxCurrent connection index.
[in]p_paramPointer to the parameters filled by profile. see gatts_noti_ind_t.
Return values
SDK_SUCCESSSend Notification or Indication event to stack successfully.
SDK_ERR_POINTER_NULLParam is NULL.
SDK_ERR_INVALID_CONN_IDXConidx is invalid.
SDK_ERR_INVALID_PARAMType is invalid.
SDK_ERR_INVALID_HANDLEHandle not exist in the database.
SDK_ERR_NO_RESOURCESNot enough resources.

◆ ble_gatts_prepare_write_cfm()

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.

Note
The status member gatts_prep_write_cfm_t::status should be set to BLE_ATT_ERR_INSUFF_AUTHOR to control the authorization of particular client's write operation.
Parameters
[in]conn_idxCurrent connection index.
[in]p_paramPointer to the parameters filled by profile. see gatts_prep_write_cfm_t.
Return values
SDK_SUCCESSSend prepare write confirm status to stack successfully.
SDK_ERR_POINTER_NULLParam is NULL.
SDK_ERR_INVALID_CONN_IDXConidx is invalid.
SDK_ERR_NO_RESOURCESNot enough resources.

◆ ble_gatts_read_cfm()

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.

Note
The status member gatts_read_cfm_t::status should be set to BLE_ATT_ERR_INSUFF_AUTHOR to control the authorization of particular read operations of a client.
Parameters
[in]conn_idxCurrent connection index.
[in]p_paramPointer to the parameters filled by profile. See gatts_read_cfm_t.
Return values
SDK_SUCCESSSend read confirm value to stack successfully.
SDK_ERR_POINTER_NULLParam is NULL.
SDK_ERR_INVALID_CONN_IDXConidx is invalid.
SDK_ERR_NO_RESOURCESNot enough resources.

◆ ble_gatts_srvc_db_create()

uint16_t ble_gatts_srvc_db_create ( gatts_create_db_t p_param)

Register a service's attribute list.

Parameters
[in,out]p_paramPointer to the parameter used in creating databases. see gatts_create_db_t.
Return values
SDK_SUCCESSDatabase has been registered successfully.
SDK_ERR_POINTER_NULLParam is NULL or param's members are NULL.
SDK_ERR_INVALID_PARAMThe member of param is invalid.
SDK_ERR_INVALID_HANDLEThe service handles can not be allocated.
SDK_ERR_NO_RESOURCESThere is not enough memory to allocate service buffer.
SDK_ERR_INVALID_PERMPermissions of Client Characteristic Configuration or Server Characteristic Configuration are not set correctly.

◆ ble_gatts_value_get()

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.

Parameters
[in]handleAttribute handle.
[in,out]p_lengthInput as buffer size and output as attribute value length.
[out]p_valueBuffer to store attribute value when buffer size is enough.
Return values
SDK_SUCCESSAttribute value retrieved successfully.
SDK_ERR_POINTER_NULLThe pointer to input buffer size or input buffer is NULL.
SDK_ERR_INVALID_HANDLEHandle not exist in the database.
SDK_ERR_REQ_NOT_SUPPORTEDAttribute data is not present in database.
SDK_ERR_INVALID_ATT_VAL_LENAttribute data value size is bigger than buffer size.
SDK_ERR_APP_ERRORDatabase is not correctly initialized by application.

◆ ble_gatts_value_set()

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.

Parameters
[in]handleAttribute handle.
[in]lengthSize of the value to set.
[in]offsetData offset of the value in attribute value.
[in]p_valueThe value to set. If offset = 0, the value is the new attribute value; otherwise, the value is part of the new attribute value.
Return values
SDK_SUCCESSSuccessfully update the attribute value.
SDK_ERR_POINTER_NULLValue is NULL.
SDK_ERR_INVALID_HANDLEHandle not exist in database.
SDK_ERR_REQ_NOT_SUPPORTEDAttribute data is not present in database or cannot be modified.
SDK_ERR_INVALID_ATT_VAL_LENNew value length exceeds maximum attribute value length.
SDK_ERR_INVALID_OFFSETOffset exceeds current attribute value length.

◆ ble_gatts_write_cfm()

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.

Note
The status member gatts_write_cfm_t::status should be set to BLE_ATT_ERR_INSUFF_AUTHOR to control the authorization of particular client's write operation.
Parameters
[in]conn_idxCurrent connection index.
[in]p_paramPointer to the parameters filled by profile. see gatts_write_cfm_t.
Return values
SDK_SUCCESSSend write confirm status to stack successfully.
SDK_ERR_POINTER_NULLParam is NULL.
SDK_ERR_INVALID_CONN_IDXConidx is invalid.
SDK_ERR_NO_RESOURCESNot enough resources.