![]() |
BLE5.2 1.0
开发文档说明
|
GAP API. Copyright (c) 2022 - 2025, XinChip All rights reserved. 更多...
函数 | |
| void | xc_ble_gapm_reset (void) |
| Called only in the app_init(). It's used to reset the device but setting device configuration is still required to use host stack. Software reset: This will initialize the RW-BLE Host stack – rearrange to default settings the ATT, GAP, GATT, L2CAP and SMP blocks. Furthermore, this will cause the host to send a reset command down to the link layer part. Platform reset: Use platform mechanism to reset hardware. | |
| void | xc_ble_set_dev_config (struct gapm_set_dev_config_cmd *cfg_param) |
| Set the device configuration such as: Device role Manage device address type: Public, Private static or Generated for Privacy Internal IRK used to generate resolvable random address. Set Internal GAP / GATT service start. Set specific write permissions on the appearance and name attributes in internal GAP database. Manage presence of some attribute. Configure Data Length Extension features. The set device configuration first resets the device to close all active link and configured profiles. This command must be sent before adding profiles and start air activities. | |
| void | xc_ble_get_dev_info (struct gapm_get_dev_info_cmd *cmd) |
| Get information about local device such as: Local Device Name Local Device Version Local Device Public BD Address Data Length Extension parameters Antenna information | |
| void | xc_ble_resolve_addr (uint8_t nb_key, gap_addr_t *addr, uint8_t *irk) |
| Resolve provided random address using array of Identity Resolution Key (IRK) exchanged and bonded with devices during pairing operations. Operation will complete successfully if address has been correctly resolved and GAPM_ADDR_SOLVED_IND message will be triggered to inform which key has been used to perform resolution. Else operation complete with GAP_ERR_NOT_FOUND error status code. | |
| void | xc_ble_gen_random_addr (struct gapm_gen_rand_addr_cmd *p_param) |
| Generate a random device address without starting any air operation. This can be useful for privacy in order to generate the reconnection address on demand. | |
| void | xc_ble_get_pub_key (void) |
| Read the local P-256 Public Key. This key is renewed each time this command is called by requester and so each pairing using secure connection. | |
| void | xc_ble_gen_random_nb (void) |
| Used to generate an 8-byte random number. This can be useful to generate LTK random number before distributing it. | |
| void | xc_ble_set_irk (gap_sec_key_t *irk) |
| Command to change the current IRK for a renewed one, it can be used every time no air operation is being performed. | |
| void | xc_ble_get_ral_addr (struct gapm_get_ral_addr_cmd *p_param) |
| Get local or peer resolvable private address | |
| void | xc_ble_set_ral_list (uint8_t size, struct gap_ral_dev_info *ral_info) |
| Request to set the content of the Resolving List. The current content of the indicated list will be cleared and replaced by the indicated content. If number of addresses to be added in the list is greater than list size, a GAP_ERR_INSUFF_RESOURCES status is returned in the GAPM_CMP_EVT message. A device can be present only once in the list. If not the case a GAP_ERR_INVALID_PARAM status is returned. | |
| void | xc_ble_set_white_list (uint8_t size, gap_bdaddr_t *wl_info) |
| Request to set the content of the White List. The current content of the indicated list will be cleared and replaced by the indicated content. If number of addresses to be added in the list is greater than list size, a GAP_ERR_INSUFF_RESOURCES status is returned in the GAPM_CMP_EVT message. A device can be present only once in the list. If not the case a GAP_ERR_INVALID_PARAM status is returned. | |
| void | xc_ble_advertise_create (struct gapm_activity_create_adv_cmd *adv_creat_param) |
| Create an advertising activity. | |
| void | xc_ble_set_adv_data (uint8_t actv_idx, uint16_t adv_data_length, uint8_t *p_adv_data) |
| Set advertising data for a given previously created advertising activity identified by its activity identifier. | |
| void | xc_ble_set_scan_rsp_data (uint8_t actv_idx, uint16_t scan_rsp_data_length, uint8_t *p_scan_rsp_data) |
| Set Scan response data for a given previously created advertising activity identified by its activity identifier. | |
| void | xc_ble_advertise_start (struct gapm_activity_start_cmd *adv_start_param) |
| Start an advertising activity. | |
| void | xc_ble_scan_create (struct gapm_activity_create_cmd *scan_creat_param) |
| Create a scanning activity. | |
| void | xc_ble_scan_start (struct gapm_activity_start_cmd *scan_start_param) |
| Start a scanning activity. | |
| void | xc_ble_init_create (struct gapm_activity_create_cmd *init_create_param) |
| Create a initiating activity. | |
| void | xc_ble_init_start (struct gapm_activity_start_cmd *init_start_param) |
| Start a initiating activity. | |
| void | xc_ble_activity_stop (int actv_idx) |
| Stop an activity or all activities. | |
| void | xc_ble_activity_delete (int actv_idx) |
| Delete an activity or all activities | |
| void | xc_ble_disconnect (int conidx, uint32_t reason) |
| Request for disconnection of the link. This can be requested by master or slave of the connection. | |
| void | xc_ble_update_param (int conidx, uint16_t intv_min, uint16_t intv_max, uint16_t latency, uint16_t time_out) |
| Update connection paramters | |
| void | xc_ble_conn_cfm (int conidx, struct gapc_connection_cfm *p_cfm) |
| Confirm connection request Set specific link security configuration and bonding data, Set connection bond data, Authentication and authorization link configuration. This confirmation message shall be sent by application after receiving a GAPC_CONNECTION_REQ_IND in order to enables local attribute tasks and security manager for the connection. It can be resent later if peer device information is retrieved later (for instance when a master initiates an encryption, information of the LTK can be used to identify peer device). In fact, when encryption is initiated by master device, it uses a couple of encryption diversifier (ediv) and random number (rand_nb) that can be used to retrieve corresponding encryption Long Term Key (LTK) that has been exchanged during a previous connection. By retrieving the LTK, we retrieve a known device and in that case before terminating encryption procedure, application shall update connection parameters. | |
| void | xc_ble_get_peer_info (int conidx, struct gapc_get_info_cmd *get_info) |
| Retrieve information about peer device or about the current active link. | |
| void | xc_ble_param_update_cfm (int conidx, struct gapc_param_update_cfm *update_cfm) |
| Used by to accept or refuse connection parameters proposed by peer device. | |
| void | xc_ble_bond (int conidx, struct gapc_bond_cmd *p_param) |
| Requested by master of the link in order to initiate the bond procedure. It contains pairing requirement of initiator. | |
| void | xc_ble_bond_cfm (int conidx, struct gapc_bond_cfm *p_param) |
| Confirm bond request. | |
| void | xc_ble_get_dev_info_cfm (int conidx, struct gapc_get_dev_info_cfm *p_param) |
| Called when the peer device obtains information about the local device. Device Name, Device Appearance, Icon Device Slave preferred parameters, Device Central address resolution, Device database hash value, Resolvable Private address only after bond. | |
| void | xc_ble_set_dev_info_cfm (int conidx, struct gapc_set_dev_info_cfm *p_param) |
| Send the write confirmation to the stack. | |
| void | xc_ble_encrypt (int conidx, struct gapc_encrypt_cmd *p_param) |
| This operation can be requested only by master of the link in order to initiate encryption procedure. It contains Long Term Key that should be used during the encryption. | |
| void | xc_ble_encrypt_cfm (int conidx, struct gapc_encrypt_cfm *p_param) |
| Confirmation message to send after receiving a GAPC_ENCRYPT_REQ_IND message This message can is used to inform if encryption key has been found, if yes found Long Term Key and its size shall be provided. | |
| void | xc_ble_req_security (int conidx, uint8_t sec_auth) |
| This operation can be requested only by slave of the link in order to initiate security request procedure. It contains authentication level requested by current device. | |
| void | xc_ble_set_pkt_size (int conidx, uint16_t tx_octets, uint16_t tx_time) |
| This operation to define the preferred packet length to be used by the controller | |
| void | xc_ble_set_channel_map (struct gapm_set_channel_map_cmd *p_param) |
| This operation can be requested only by master of the link in order to set the channel map of the device. | |
GAP API. Copyright (c) 2022 - 2025, XinChip All rights reserved.
在文件 xc_gap_api.h 中定义.
| void xc_ble_activity_delete | ( | int | actv_idx | ) |
Delete an activity or all activities
| [in] | actv_idx | Activity index , If less than 0, stop all activities. activities |
在文件 xc_gap_api.c 第 260 行定义.
| void xc_ble_activity_stop | ( | int | actv_idx | ) |
Stop an activity or all activities.
| [in] | actv_idx | Activity index ,If less than 0, stop all activities |
在文件 xc_gap_api.c 第 245 行定义.
| void xc_ble_advertise_create | ( | struct gapm_activity_create_adv_cmd * | adv_creat_param | ) |
Create an advertising activity.
| [in] | adv_creat_param | Pointer to activity create structure. |
在文件 xc_gap_api.c 第 139 行定义.
| void xc_ble_advertise_start | ( | struct gapm_activity_start_cmd * | adv_start_param | ) |
Start an advertising activity.
| [in] | adv_start_param | Pointer to activity start structure. |
在文件 xc_gap_api.c 第 182 行定义.
| void xc_ble_bond | ( | int | conidx, |
| struct gapc_bond_cmd * | p_param | ||
| ) |
Requested by master of the link in order to initiate the bond procedure. It
contains pairing requirement of initiator.
| [in] | conidx | Connection index |
| [in] | p_bond | Pointer to pairing requirement of initiator. |
在文件 xc_gap_api.c 第 344 行定义.
| void xc_ble_bond_cfm | ( | int | conidx, |
| struct gapc_bond_cfm * | p_param | ||
| ) |
Confirm bond request.
| [in] | conidx | Connection index |
| [in] | p_cfm | Pointer to bond confirm data structure. |
在文件 xc_gap_api.c 第 355 行定义.
| void xc_ble_conn_cfm | ( | int | conidx, |
| struct gapc_connection_cfm * | p_cfm | ||
| ) |
Confirm connection request
Set specific link security configuration and bonding data,
Set connection bond data,
Authentication and authorization link configuration.
This confirmation message shall be sent by application after receiving a GAPC_CONNECTION_REQ_IND in
order to enables local attribute tasks and security manager for the connection.
It can be resent later if peer device information is retrieved later (for instance when a master initiates an
encryption, information of the LTK can be used to identify peer device). In fact, when encryption is initiated
by master device, it uses a couple of encryption diversifier (ediv) and random number (rand_nb) that can be
used to retrieve corresponding encryption Long Term Key (LTK) that has been exchanged during a previous
connection. By retrieving the LTK, we retrieve a known device and in that case before terminating encryption
procedure, application shall update connection parameters.
| [in] | conidx | Connection index |
| [in] | p_cfm | Pointer to comfirm parameters structure. |
在文件 xc_gap_api.c 第 308 行定义.
| void xc_ble_disconnect | ( | int | conidx, |
| uint32_t | reason | ||
| ) |
Request for disconnection of the link. This can be requested by master or slave of the connection.
| [in] | conidx | Connection index. |
| [in] | reason | Reason of disconnection, 0x13:User on the remote device terminated the connnection |
在文件 xc_gap_api.c 第 276 行定义.
| void xc_ble_encrypt | ( | int | conidx, |
| struct gapc_encrypt_cmd * | p_param | ||
| ) |
This operation can be requested only by master of the link in order to initiate encryption procedure. It
contains Long Term Key that should be used during the encryption.
| [in] | conidx | Connection index |
| [in] | p_param | Pointer to data structure. |
在文件 xc_gap_api.c 第 393 行定义.
| void xc_ble_encrypt_cfm | ( | int | conidx, |
| struct gapc_encrypt_cfm * | p_param | ||
| ) |
Confirmation message to send after receiving a GAPC_ENCRYPT_REQ_IND message
This message can is used to inform if encryption key has been found, if yes found Long Term Key and its size
shall be provided.
| [in] | conidx | Connection index |
| [in] | p_param | Pointer to data structure |
Confirmation message to send after receiving a GAPC_ENCRYPT_REQ_IND message
This message can is used to inform if encryption key has been found, if yes found Long Term Key and its size
shall be provided.
在文件 xc_gap_api.c 第 406 行定义.
| void xc_ble_gapm_reset | ( | void | ) |
Called only in the app_init(). It's used to reset the device but setting
device configuration is still required to use host stack.
Software reset: This will initialize the RW-BLE Host stack – rearrange to default settings the ATT, GAP, GATT,
L2CAP and SMP blocks. Furthermore, this will cause the host to send a reset command down to the link
layer part. Platform reset: Use platform mechanism to reset hardware.
在文件 xc_gap_api.c 第 13 行定义.
| void xc_ble_gen_random_addr | ( | struct gapm_gen_rand_addr_cmd * | p_param | ) |
Generate a random device address without starting any air operation. This can be useful for privacy in order
to generate the reconnection address on demand.
| [in] | p_param | random address type. |
在文件 xc_gap_api.c 第 60 行定义.
| void xc_ble_gen_random_nb | ( | void | ) |
Used to generate an 8-byte random number. This can be useful to generate LTK
random number before distributing it.
在文件 xc_gap_api.c 第 81 行定义.
| void xc_ble_get_dev_info | ( | struct gapm_get_dev_info_cmd * | cmd | ) |
Get information about local device such as:
Local Device Name
Local Device Version
Local Device Public BD Address
Data Length Extension parameters
Antenna information
| [in] | cmd | Command for information |
在文件 xc_gap_api.c 第 35 行定义.
| void xc_ble_get_dev_info_cfm | ( | int | conidx, |
| struct gapc_get_dev_info_cfm * | p_param | ||
| ) |
Called when the peer device obtains information about the local device.
Device Name,
Device Appearance,
Icon Device Slave preferred parameters,
Device Central address resolution,
Device database hash value,
Resolvable Private address only after bond.
| [in] | conidx | Connection index |
| [in] | p_param | Pointer to data structure. |
在文件 xc_gap_api.c 第 365 行定义.
| void xc_ble_get_peer_info | ( | int | conidx, |
| struct gapc_get_info_cmd * | get_info | ||
| ) |
Retrieve information about peer device or about the current active link.
| [in] | conidx | Connection index |
| [in] | get_info | Pointer to parameters structure operation |
在文件 xc_gap_api.c 第 319 行定义.
| void xc_ble_get_pub_key | ( | void | ) |
Read the local P-256 Public Key. This key is renewed each time this command is called by
requester and so each pairing using secure connection.
在文件 xc_gap_api.c 第 71 行定义.
| void xc_ble_get_ral_addr | ( | struct gapm_get_ral_addr_cmd * | p_param | ) |
Get local or peer resolvable private address
| [in] | p_param | Pointer Read local or peer address cmd ptr. |
在文件 xc_gap_api.c 第 102 行定义.
| void xc_ble_init_create | ( | struct gapm_activity_create_cmd * | init_create_param | ) |
Create a initiating activity.
| [in] | init_creat_param | Pointer to activity create structure. |
在文件 xc_gap_api.c 第 216 行定义.
| void xc_ble_init_start | ( | struct gapm_activity_start_cmd * | init_start_param | ) |
Start a initiating activity.
| [in] | init_start_param | Pointer to activity start structure. |
在文件 xc_gap_api.c 第 228 行定义.
| void xc_ble_param_update_cfm | ( | int | conidx, |
| struct gapc_param_update_cfm * | update_cfm | ||
| ) |
Used by to accept or refuse connection parameters proposed by peer device.
| [in] | conidx | Connection index |
| [in] | update_cfm | Pointer to parameters structure. |
在文件 xc_gap_api.c 第 330 行定义.
| void xc_ble_req_security | ( | int | conidx, |
| uint8_t | sec_auth | ||
| ) |
This operation can be requested only by slave of the link in order to initiate security request procedure. It
contains authentication level requested by current device.
| [in] | conidx | Connection index |
| [in] | p_param | Pointer to data structure. |
This operation can be requested only by slave of the link in order to initiate security request procedure. It
contains authentication level requested by current device.
在文件 xc_gap_api.c 第 418 行定义.
| void xc_ble_resolve_addr | ( | uint8_t | nb_key, |
| gap_addr_t * | addr, | ||
| uint8_t * | irk | ||
| ) |
Resolve provided random address using array of Identity Resolution Key (IRK) exchanged and bonded with
devices during pairing operations.
Operation will complete successfully if address has been correctly resolved and GAPM_ADDR_SOLVED_IND
message will be triggered to inform which key has been used to perform resolution.
Else operation complete with GAP_ERR_NOT_FOUND error status code.
| [in] | nb_key | Number of provided IRK (sahlle be > 0). |
| [in] | addr | Pointer to resolvable random address to solve. |
| [in] | irk | Pointer to array of IRK used for address resolution (MSB -> LSB). |
在文件 xc_gap_api.c 第 45 行定义.
| void xc_ble_scan_create | ( | struct gapm_activity_create_cmd * | scan_creat_param | ) |
Create a scanning activity.
| [in] | scan_creat_param | Pointer to activity create structure. |
在文件 xc_gap_api.c 第 193 行定义.
| void xc_ble_scan_start | ( | struct gapm_activity_start_cmd * | scan_start_param | ) |
Start a scanning activity.
| [in] | scan_start_param | Pointer to activity start structure. |
在文件 xc_gap_api.c 第 205 行定义.
| void xc_ble_set_adv_data | ( | uint8_t | actv_idx, |
| uint16_t | adv_data_length, | ||
| uint8_t * | p_adv_data | ||
| ) |
Set advertising data for a given previously created advertising activity identified by its
activity identifier.
| [in] | actv_idx | Activity identifier |
| [in] | adv_data_length | ADV data length |
| [in] | p_adv_data | Pointer to adv data |
在文件 xc_gap_api.c 第 152 行定义.
| void xc_ble_set_channel_map | ( | struct gapm_set_channel_map_cmd * | p_param | ) |
This operation can be requested only by master of the link in order to set the channel map of the device.
| [in] | p_param | Pointer to data structure. |
在文件 xc_gap_api.c 第 458 行定义.
| void xc_ble_set_dev_config | ( | struct gapm_set_dev_config_cmd * | cfg_param | ) |
Set the device configuration such as:
Device role
Manage device address type: Public, Private static or Generated for Privacy
Internal IRK used to generate resolvable random address.
Set Internal GAP / GATT service start.
Set specific write permissions on the appearance and name attributes in internal GAP database.
Manage presence of some attribute.
Configure Data Length Extension features.
The set device configuration first resets the device to close all active link and configured profiles.
This command must be sent before adding profiles and start air activities.
| [in] | cfg_param | Pointer to the device configurtion structure. |
在文件 xc_gap_api.c 第 24 行定义.
| void xc_ble_set_dev_info_cfm | ( | int | conidx, |
| struct gapc_set_dev_info_cfm * | p_param | ||
| ) |
Send the write confirmation to the stack.
| [in] | conidx | Connection index |
| [in] | p_param | Pointer to data structure. |
在文件 xc_gap_api.c 第 382 行定义.
| void xc_ble_set_irk | ( | gap_sec_key_t * | irk | ) |
Command to change the current IRK for a renewed one, it can be used every time
no air operation is being performed.
| [out] | p_param | Pointer to a security key data structure. |
在文件 xc_gap_api.c 第 91 行定义.
| void xc_ble_set_pkt_size | ( | int | conidx, |
| uint16_t | tx_octets, | ||
| uint16_t | tx_time | ||
| ) |
This operation to define the preferred packet length to be used by the controller
| [in] | conidx | Connection index |
| [in] | tx_octets | Preferred maximum number of payload octets that the local Controller should include in a single Link Layer Data Channel PDU. |
| [in] | tx_time | Preferred maximum number of microseconds that the local Controller should use to transmit a single Link Layer Data Channel PDU |
在文件 xc_gap_api.c 第 430 行定义.
| void xc_ble_set_ral_list | ( | uint8_t | size, |
| struct gap_ral_dev_info * | ral_info | ||
| ) |
Request to set the content of the Resolving List. The current content of the indicated list will be cleared
and replaced by the indicated content.
If number of addresses to be added in the list is greater than list size, a GAP_ERR_INSUFF_RESOURCES status
is returned in the GAPM_CMP_EVT message.
A device can be present only once in the list. If not the case a GAP_ERR_INVALID_PARAM status is returned.
| [in] | size | Number of entries to be added in the list. 0 means that list content has to be cleared. |
| [in] | ral_info | Pointer to list of entries to be added in the list. |
在文件 xc_gap_api.c 第 113 行定义.
| void xc_ble_set_scan_rsp_data | ( | uint8_t | actv_idx, |
| uint16_t | scan_rsp_data_length, | ||
| uint8_t * | p_scan_rsp_data | ||
| ) |
Set Scan response data for a given previously created advertising activity identified by its
activity identifier.
| [in] | actv_idx | Activity identifier |
| [in] | scan_rsp_data_length | Scan response data length |
| [in] | p_scan_rsp_data | Pointer to scan response data. |
在文件 xc_gap_api.c 第 167 行定义.
| void xc_ble_set_white_list | ( | uint8_t | size, |
| gap_bdaddr_t * | wl_info | ||
| ) |
Request to set the content of the White List. The current content of the indicated list will be cleared
and replaced by the indicated content.
If number of addresses to be added in the list is greater than list size, a GAP_ERR_INSUFF_RESOURCES status
is returned in the GAPM_CMP_EVT message.
A device can be present only once in the list. If not the case a GAP_ERR_INVALID_PARAM status is returned.
| [in] | size | Number of entries to be added in the list. 0 means that list content has to be cleared. |
| [in] | wl_info | Pointer to list of entries to be added in the list. |
在文件 xc_gap_api.c 第 126 行定义.
| void xc_ble_update_param | ( | int | conidx, |
| uint16_t | intv_min, | ||
| uint16_t | intv_max, | ||
| uint16_t | latency, | ||
| uint16_t | time_out | ||
| ) |
Update connection paramters
| [in] | conidx | Connection index |
| [in] | p_conn_param | Pointer to update parameters structure. |
在文件 xc_gap_api.c 第 288 行定义.