BLE5.2 1.0
开发文档说明
函数
xc_gatt_client_api.h 文件参考

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

浏览源代码.

函数

uint16_t xc_ble_gatt_user_cli_register (uint16_t pref_mtu, uint8_t prio_level, const gatt_cli_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_user_unregister (uint8_t user_lid)
 Command used to unregister a GATT user (client or server).
 
uint16_t xc_ble_gatt_cli_discover_svc (uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint8_t disc_type, bool full, uint16_t start_hdl, uint16_t end_hdl, uint8_t uuid_type, const uint8_t *p_uuid)
 Command used by a GATT client user to discover primary or secondary services, exposed by peer device in its attribute database.
 
uint16_t xc_ble_gatt_cli_discover_inc_svc (uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint16_t start_hdl, uint16_t end_hdl)
 Command used by a GATT client user to discover included services, exposed by peer device in its attribute database.
 
uint16_t xc_ble_gatt_cli_discover_char (uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint8_t disc_type, uint16_t start_hdl, uint16_t end_hdl, uint8_t uuid_type, const uint8_t *p_uuid)
 Command used by a GATT client user to discover all or according to a specific UUID characteristics exposed by peer device in its attribute database.
 
uint16_t xc_ble_gatt_cli_discover_desc (uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint16_t start_hdl, uint16_t end_hdl)
 Command used by a GATT client user to discover characteristic descriptor exposed by peer device in its attribute database.
 
uint16_t xc_ble_gatt_cli_discover_cancel (uint8_t conidx, uint8_t user_lid, uint16_t dummy)
 Command used by a GATT client user to cancel an on-going discovery procedure. The dummy parameter in the request must be equals to dummy parameter used for service discovery command.
 
uint16_t xc_ble_gatt_cli_read (uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint16_t hdl, uint16_t offset, uint16_t length)
 Command used by a GATT client user to read value of an attribute (identified by its handle) present in peer database.
 
uint16_t xc_ble_gatt_cli_read_by_uuid (uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint16_t start_hdl, uint16_t end_hdl, uint8_t uuid_type, const uint8_t *p_uuid)
 Command used by a GATT client user to read value of an attribute with a given UUID in peer database.
 
uint16_t xc_ble_gatt_cli_write (uint8_t conidx, uint8_t user_lid, uint16_t dummy, uint8_t write_type, uint16_t hdl, uint16_t length, const uint8_t *p_data)
 Command used by a GATT client user to request to write value of an attribute in peer database.
 
uint16_t xc_ble_gatt_cli_event_register (uint8_t conidx, uint8_t user_lid, uint16_t start_hdl, uint16_t end_hdl)
 Command used by a GATT client user to register for reception of events (notification / indication) for a given handle range.
 
uint16_t xc_ble_gatt_cli_event_unregister (uint8_t conidx, uint8_t user_lid, uint16_t start_hdl, uint16_t end_hdl)
 Command used by a GATT client user to stop reception of events (notification / indication) onto a specific handle range.
 
uint16_t xc_ble_gatt_cli_mtu_exch (uint8_t conidx, uint8_t user_lid)
 Request a MTU exchange on legacy attribute bearer. There is no callback executed when the procedure is over.
 
uint16_t xc_ble_gatt_cli_indicate_cfm (uint8_t conidx, uint8_t user_lid, uint16_t token)
 Upper layer provide status of attribute event handled by GATT client user. confirmation of indicate by GATT client.
 

详细描述

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

在文件 xc_gatt_client_api.h 中定义.

函数说明

◆ xc_ble_gatt_cli_discover_cancel()

uint16_t xc_ble_gatt_cli_discover_cancel ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  dummy 
)

Command used by a GATT client user to cancel an on-going discovery procedure. The dummy parameter in the request must be equals to dummy parameter used for service discovery command.

The discovery is aborted as soon as on-going discovery attribute transaction is over.

Wait for

参见
cb_discover_cmp 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.
返回
Status of the function execution (
参见
enum hl_err) Consider status only if an error occurs; else wait for execution completion

在文件 xc_gatt_client_api.c58 行定义.

◆ xc_ble_gatt_cli_discover_char()

uint16_t xc_ble_gatt_cli_discover_char ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  dummy,
uint8_t  disc_type,
uint16_t  start_hdl,
uint16_t  end_hdl,
uint8_t  uuid_type,
const uint8_t *  p_uuid 
)

Command used by a GATT client user to discover all or according to a specific UUID characteristics exposed by peer device in its attribute database.

The discovery is done between start handle and end handle range. For a complete discovery start handle must be set to 0x0001 and end handle to 0xFFFF.

Wait for

参见
cb_discover_cmp 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]disc_typeGATT characteristic discovery type (
参见
enum gatt_char_discovery_type)
参数
[in]start_hdlSearch start handle
[in]end_hdlSearch end handle
[in]uuid_typeUUID Type (
参见
enum gatt_uuid_type)
参数
[in]p_uuidPointer to searched Attribute Value UUID (meaningful only for discovery by UUID)
返回
Status of the function execution (
参见
enum hl_err) Consider status only if an error occurs; else wait for execution completion

在文件 xc_gatt_client_api.c42 行定义.

◆ xc_ble_gatt_cli_discover_desc()

uint16_t xc_ble_gatt_cli_discover_desc ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  dummy,
uint16_t  start_hdl,
uint16_t  end_hdl 
)

Command used by a GATT client user to discover characteristic descriptor exposed by peer device in its attribute database.

The discovery is done between start handle and end handle range. For a complete discovery start handle must be set to 0x0001 and end handle to 0xFFFF.

Wait for

参见
cb_discover_cmp 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]start_hdlSearch start handle
[in]end_hdlSearch end handle
返回
Status of the function execution (
参见
enum hl_err) Consider status only if an error occurs; else wait for execution completion

在文件 xc_gatt_client_api.c51 行定义.

◆ xc_ble_gatt_cli_discover_inc_svc()

uint16_t xc_ble_gatt_cli_discover_inc_svc ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  dummy,
uint16_t  start_hdl,
uint16_t  end_hdl 
)

Command used by a GATT client user to discover included services, exposed by peer device in its attribute database.

The discovery is done between start handle and end handle range. For a complete discovery start handle must be set to 0x0001 and end handle to 0xFFFF.

Wait for

参见
cb_discover_cmp 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]start_hdlSearch start handle
[in]end_hdlSearch end handle
返回
Status of the function execution (
参见
enum hl_err) Consider status only if an error occurs; else wait for execution completion

在文件 xc_gatt_client_api.c34 行定义.

◆ xc_ble_gatt_cli_discover_svc()

uint16_t xc_ble_gatt_cli_discover_svc ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  dummy,
uint8_t  disc_type,
bool  full,
uint16_t  start_hdl,
uint16_t  end_hdl,
uint8_t  uuid_type,
const uint8_t *  p_uuid 
)

Command used by a GATT client user to discover primary or secondary services, exposed by peer device in its attribute database.

All services can be discovered or filtering services having a specific UUID. The discovery is done between start handle and end handle range. For a complete discovery start handle must be set to 0x0001 and end handle to 0xFFFF.

Wait for

参见
cb_discover_cmp 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]disc_typeGATT Service discovery type (
参见
enum gatt_svc_discovery_type)
参数
[in]fullPerform discovery of all information present in the service (True: enable, False: disable)
[in]start_hdlSearch start handle
[in]end_hdlSearch end handle
[in]uuid_typeUUID Type (
参见
enum gatt_uuid_type)
参数
[in]p_uuidPointer to searched Service UUID (meaningful only for discovery by UUID)
返回
Status of the function execution (
参见
enum hl_err) Consider status only if an error occurs; else wait for execution completion

在文件 xc_gatt_client_api.c25 行定义.

◆ xc_ble_gatt_cli_event_register()

uint16_t xc_ble_gatt_cli_event_register ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  start_hdl,
uint16_t  end_hdl 
)

Command used by a GATT client user to register for reception of events (notification / indication) for a given handle range.

参数
[in]conidxConnection index
[in]user_lidGATT User Local identifier
[in]start_hdlAttribute start handle
[in]end_hdlAttribute end handle
返回
Status of the function execution (
参见
enum hl_err)

在文件 xc_gatt_client_api.c99 行定义.

◆ xc_ble_gatt_cli_event_unregister()

uint16_t xc_ble_gatt_cli_event_unregister ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  start_hdl,
uint16_t  end_hdl 
)

Command used by a GATT client user to stop reception of events (notification / indication) onto a specific handle range.

参数
[in]conidxConnection index
[in]user_lidGATT User Local identifier
[in]start_hdlAttribute start handle
[in]end_hdlAttribute end handle
返回
Status of the function execution (
参见
enum hl_err)

在文件 xc_gatt_client_api.c105 行定义.

◆ xc_ble_gatt_cli_indicate_cfm()

uint16_t xc_ble_gatt_cli_indicate_cfm ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  token 
)

Upper layer provide status of attribute event handled by GATT client user. confirmation of indicate by GATT client.

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

在文件 xc_gatt_client_api.c116 行定义.

◆ xc_ble_gatt_cli_mtu_exch()

uint16_t xc_ble_gatt_cli_mtu_exch ( uint8_t  conidx,
uint8_t  user_lid 
)

Request a MTU exchange on legacy attribute bearer. There is no callback executed when the procedure is over.

参数
[in]conidxConnection index
[in]user_lidGATT User Local identifier
返回
Status of the function execution (
参见
enum hl_err)

在文件 xc_gatt_client_api.c111 行定义.

◆ xc_ble_gatt_cli_read()

uint16_t xc_ble_gatt_cli_read ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  dummy,
uint16_t  hdl,
uint16_t  offset,
uint16_t  length 
)

Command used by a GATT client user to read value of an attribute (identified by its handle) present in peer database.

Wait for

参见
cb_read_cmp 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]offsetValue offset
[in]lengthValue length to read (0 = read all)
返回
Status of the function execution (
参见
enum hl_err) Consider status only if an error occurs; else wait for execution completion

在文件 xc_gatt_client_api.c64 行定义.

◆ xc_ble_gatt_cli_read_by_uuid()

uint16_t xc_ble_gatt_cli_read_by_uuid ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  dummy,
uint16_t  start_hdl,
uint16_t  end_hdl,
uint8_t  uuid_type,
const uint8_t *  p_uuid 
)

Command used by a GATT client user to read value of an attribute with a given UUID in peer database.

Wait for

参见
cb_read_cmp 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]start_hdlSearch start handle
[in]end_hdlSearch end handle
[in]uuid_typeUUID Type (
参见
enum gatt_uuid_type)
参数
[in]p_uuidPointer to searched attribute UUID (LSB First)
返回
Status of the function execution (
参见
enum hl_err) Consider status only if an error occurs; else wait for execution completion

在文件 xc_gatt_client_api.c70 行定义.

◆ xc_ble_gatt_cli_write()

uint16_t xc_ble_gatt_cli_write ( uint8_t  conidx,
uint8_t  user_lid,
uint16_t  dummy,
uint8_t  write_type,
uint16_t  hdl,
uint16_t  length,
const uint8_t *  p_data 
)

Command used by a GATT client user to request to write value of an attribute in peer database.

Since user is not aware of MTU size of the bearer used for attribute transmission it cannot be considered reliable.

For a GATT_WRITE_NO_RESP if attribute bearer max transmission size isn't sufficient, a GATT_WRITE (with response) procedure will be used.

For a GATT_WRITE_SIGNED, if attribute bearer max transmission size isn't sufficient, the procedure is aborted with L2CAP_ERR_INVALID_MTU error code.

Wait for

参见
cb_write_cmp 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]write_typeGATT write type (
参见
enum gatt_write_type)
参数
[in]hdlAttribute handle
[in]lengthValue length
[in]p_dataPointer to data value
返回
Status of the function execution (
参见
enum hl_err) Consider status only if an error occurs; else wait for execution completion

在文件 xc_gatt_client_api.c79 行定义.

◆ xc_ble_gatt_user_cli_register()

uint16_t xc_ble_gatt_user_cli_register ( uint16_t  pref_mtu,
uint8_t  prio_level,
const gatt_cli_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 client user can initiate any client procedure, and shall be able to handle all client initiated message 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_client_api.c13 行定义.

◆ xc_ble_gatt_user_unregister()

uint16_t xc_ble_gatt_user_unregister ( uint8_t  user_lid)

Command used to unregister a GATT user (client or server).

参数
[in]user_lidGATT User Local identifier
返回
Status of the function execution (
参见
enum hl_err)

在文件 xc_gatt_client_api.c20 行定义.