BLE5.2 1.0
开发文档说明
枚举 | 函数
xc_gatt_server_api.h 文件参考

GATT server API. Copyright (c) 2022 - 2025, XinChip All rights reserved. 更多...

浏览源代码.

枚举

enum  gatt_err { GATT_NO_ERROR = 0x00 }
 
enum  gatt_switch { GATT_DISABLE = 0 , GATT_ENABLE = 1 }
 

函数

uint16_t xc_ble_gatt_user_srv_register (uint16_t pref_mtu, uint8_t prio_level, const gatt_srv_cb_t *p_cb, uint8_t *p_user_lid)
 Command used to register a GATT user. This must be done prior to any GATT procedure execution.
 
uint16_t xc_ble_gatt_service_add (uint8_t user_lid, uint8_t info, const uint8_t *p_uuid, uint8_t nb_att, const uint8_t *p_att_mask, const gatt_att_desc_t *p_atts, uint8_t nb_att_rsvd, uint16_t *p_start_hdl)
 Command used to add a service into local attribute database.
 
uint16_t xc_ble_gatt_service16_add (uint8_t user_lid, uint8_t info, uint16_t uuid16, uint8_t nb_att, const uint8_t *p_att_mask, const gatt_att16_desc_t *p_atts, uint8_t nb_att_rsvd, uint16_t *p_start_hdl)
 Command used to add a service into local attribute database.
 
uint16_t xc_ble_gatt_service_remove (uint8_t user_lid, uint16_t start_hdl)
 Command used to remove a service from local attribute database.
 
uint16_t xc_ble_gatt_srv_notify (uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint16_t hdl, uint16_t length, const uint8_t *p_value)
 Command used by a GATT server user to send notifications
 
uint16_t xc_ble_gatt_srv_indicate (uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint16_t hdl, uint16_t length, const uint8_t *p_value)
 Command used by a GATT server user to send indication
 
uint16_t xc_ble_gatt_srv_read_cfm (uint8_t conidx, uint8_t user_lid, uint16_t token, uint16_t status, uint16_t att_length, uint16_t length, const uint8_t *p_value)
 Upper layer provide attribute value requested by GATT Layer for a read procedure If rejected, value is not used.
 
uint16_t xc_ble_gatt_srv_write_cfm (uint8_t conidx, uint8_t user_lid, uint16_t token, uint16_t status)
 Upper layer provide status of attribute value modification by GATT server user. Confirmation server user when an attribute value has been written by a peer device.
 

详细描述

GATT server API. Copyright (c) 2022 - 2025, XinChip All rights reserved.

在文件 xc_gatt_server_api.h 中定义.

枚举类型说明

◆ gatt_err

enum gatt_err
枚举值
GATT_NO_ERROR 

No error

在文件 xc_gatt_server_api.h20 行定义.

◆ gatt_switch

枚举值
GATT_DISABLE 
GATT_ENABLE 

在文件 xc_gatt_server_api.h26 行定义.

函数说明

◆ xc_ble_gatt_service16_add()

uint16_t xc_ble_gatt_service16_add ( uint8_t  user_lid,
uint8_t  info,
uint16_t  uuid16,
uint8_t  nb_att,
const uint8_t *  p_att_mask,
const gatt_att16_desc_t *  p_atts,
uint8_t  nb_att_rsvd,
uint16_t *  p_start_hdl 
)

Command used to add a service into local attribute database.

   Service and attributes UUIDs in service must be 16-bit

   If start handle is set to zero (invalid attribute handle), GATT looks for a
   free handle block matching with number of attributes to reserve.
   Else, according to start handle, GATT checks if attributes to reserve are
   not overlapping part of existing database.

   An added service is automatically visible for peer device.

   @note First attribute in attribute array must be a Primary or a Secondary service
参数
[in]user_lidGATT User Local identifier
[in]infoService Information bit field (
参见
enum gatt_svc_info_bf)
参数
[in]uuid16Service UUID (16-bit UUID - LSB First)
[in]nb_attNumber of attribute(s) in service
[in]p_att_maskPointer to mask of attribute to insert in database:
  • If NULL insert all attributes
  • If bit set to 1: attribute inserted
  • If bit set to 0: attribute not inserted
[in]p_attsPointer to List of attribute (with 16-bit uuid) description present in service.
[in]nb_att_rsvdNumber of attribute(s) reserved for the service (shall be equals or greater nb_att) Prevent any services to be inserted between start_hdl and (start_hdl + nb_att_rsvd - 1)
[in|out]p_start_hdl Pointer to Service Start Handle (0 = chosen by GATT module) Pointer updated with service start handle associated to created service.
返回
Status of the function execution (
参见
enum hl_err)

在文件 xc_gatt_server_api.c30 行定义.

◆ xc_ble_gatt_service_add()

uint16_t xc_ble_gatt_service_add ( uint8_t  user_lid,
uint8_t  info,
const uint8_t *  p_uuid,
uint8_t  nb_att,
const uint8_t *  p_att_mask,
const gatt_att_desc_t *  p_atts,
uint8_t  nb_att_rsvd,
uint16_t *  p_start_hdl 
)

Command used to add a service into local attribute database.

   If start handle is set to zero (invalid attribute handle), GATT looks for a
   free handle block matching with number of attributes to reserve.
   Else, according to start handle, GATT checks if attributes to reserve are
   not overlapping part of existing database.

   An added service is automatically visible for peer device.

   @note First attribute in attribute array must be a Primary or a Secondary service
参数
[in]user_lidGATT User Local identifier
[in]infoService Information bit field (
参见
enum gatt_svc_info_bf)
参数
[in]p_uuidPointer to service UUID (LSB first)
[in]nb_attNumber of attribute(s) in service
[in]p_att_maskPointer to mask of attribute to insert in database:
  • If NULL insert all attributes
  • If bit set to 1: attribute inserted
  • If bit set to 0: attribute not inserted
[in]p_attsPointer to List of attribute description present in service.
[in]nb_att_rsvdNumber of attribute(s) reserved for the service (shall be equals or greater nb_att) Prevent any services to be inserted between start_hdl and (start_hdl + nb_att_rsvd -1)
[in|out]p_start_hdl Pointer to Service Start Handle (0 = chosen by GATT module) Pointer updated with service start handle associated to created service.
返回
Status of the function execution (
参见
enum hl_err)

在文件 xc_gatt_server_api.c20 行定义.

◆ xc_ble_gatt_service_remove()

uint16_t xc_ble_gatt_service_remove ( uint8_t  user_lid,
uint16_t  start_hdl 
)

Command used to remove a service from local attribute database.

   Only GATT user responsible of service can remove it.
参数
[in]user_lidGATT User Local identifier
[in]start_hdlService Start Handle
返回
Status of the function execution (
参见
enum hl_err)

在文件 xc_gatt_server_api.c40 行定义.

◆ xc_ble_gatt_srv_indicate()

uint16_t xc_ble_gatt_srv_indicate ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  dummy,
uint16_t  hdl,
uint16_t  length,
const uint8_t *  p_value 
)

Command used by a GATT server user to send indication

   Since user is not aware of MTU size of the bearer used for attribute
   transmission it cannot be considered reliable. If size of the data buffer is too
   big, data is truncated to max supported length.

   Wait for @see cb_event_sent execution before starting a new procedure
参数
[in]conidxConnection index
[in]user_lidGATT User Local identifier
[in]dummyDummy parameter whose meaning is upper layer dependent and which is returned in command complete.
[in]hdlAttribute handle
[in]lengthValue length
[in]p_valuePointer to Value to transmit
返回
Status of the function execution (
参见
enum hl_err) Consider status only if an error occurs; else wait for execution completion

在文件 xc_gatt_server_api.c69 行定义.

◆ xc_ble_gatt_srv_notify()

uint16_t xc_ble_gatt_srv_notify ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  dummy,
uint16_t  hdl,
uint16_t  length,
const uint8_t *  p_value 
)

Command used by a GATT server user to send notifications

   Since user is not aware of MTU size of the bearer used for attribute
   transmission it cannot be considered reliable. If size of the data buffer is too
   big, data is truncated to max supported length.

   Wait for @see cb_event_sent execution before starting a new procedure
参数
[in]conidxConnection index
[in]user_lidGATT User Local identifier
[in]dummyDummy parameter whose meaning is upper layer dependent and which is returned in command complete.
[in]hdlAttribute handle
[in]lengthValue length
[in]p_valuePointer to Value to transmit
返回
Status of the function execution (
参见
enum hl_err) Consider status only if an error occurs; else wait for execution completion

在文件 xc_gatt_server_api.c45 行定义.

◆ xc_ble_gatt_srv_read_cfm()

uint16_t xc_ble_gatt_srv_read_cfm ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  token,
uint16_t  status,
uint16_t  att_length,
uint16_t  length,
const uint8_t *  p_value 
)

Upper layer provide attribute value requested by GATT Layer for a read procedure If rejected, value is not used.

参数
[in]conidxConnection index
[in]user_lidGATT User Local identifier
[in]tokenProcedure token provided in corresponding callback
[in]statusStatus of attribute value get (
参见
enum hl_err)
参数
[in]att_lengthComplete Length of the attribute value
[in]lengthValue length
[in]p_valuePointer to buffer attribute data
返回
Status of the function execution (
参见
enum hl_err)

在文件 xc_gatt_server_api.c93 行定义.

◆ xc_ble_gatt_srv_write_cfm()

uint16_t xc_ble_gatt_srv_write_cfm ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  token,
uint16_t  status 
)

Upper layer provide status of attribute value modification by GATT server user. Confirmation server user when an attribute value has been written by a peer device.

参数
[in]conidxConnection index
[in]user_lidGATT User Local identifier
[in]tokenProcedure token provided in corresponding callback
[in]statusStatus of attribute value set (
参见
enum hl_err)
返回
Status of the function execution (
参见
enum hl_err)

在文件 xc_gatt_server_api.c123 行定义.

◆ xc_ble_gatt_user_srv_register()

uint16_t xc_ble_gatt_user_srv_register ( uint16_t  pref_mtu,
uint8_t  prio_level,
const gatt_srv_cb_t *  p_cb,
uint8_t *  p_user_lid 
)

Command used to register a GATT user. This must be done prior to any GATT procedure execution.

A GATT server can manipulate local attribute database and initiate server procedures. It shall be able to handle all server initiated events

Same module can register multiple GATT users.

参数
[in]pref_mtuPreferred MTU for attribute exchange.
[in]prio_levelUser attribute priority level
[in]p_cbPointer to set of callback functions to be used for communication with the GATT server user
[out]p_user_lidPointer where GATT user local identifier will be set
返回
Status of the function execution (
参见
enum hl_err)

在文件 xc_gatt_server_api.c13 行定义.