4.7. BLE应用接口
概述
介绍BLE的应用层的接口使用方法
4.7.1. API参考
Defines
-
ble_op_set_own_address_type(address_type)
配置设备的地址类型,默认为 0(public address).
\function ble_cmd_ret_e ble_op_set_own_address_type(u8 address_type).
Note
!!!注意:设置的时候必须在、设置广播参数、或者扫描参数、或者创建连接参数前配置好.
- Parameters
address_type – [in] Range: 0x00 to 0x03.
- Returns
see ble_cmd_ret_e.
-
ble_op_adv_enable(enable)
开关BLE广播.
\function ble_cmd_ret_e ble_op_adv_enable(int enable).
Note
!!!注意:开广播前必现先配置好广播的参数.
- Parameters
enable – [in] 广播使能 :0(dis) or 1(en).
- Returns
see ble_cmd_ret_e.
-
ble_op_set_adv_filter_policy(type)
配置广播过滤策略(决定链路层如何处理扫描、连接请求);默认为 0.
\function ble_cmd_ret_e ble_op_set_adv_filter_policy(u8 type).
Note
!!!注意:设置的时候必须在“设置广播参数ble_op_set_adv_param前配置好.
- Parameters
type – [in] 类型 :Range: 0x00 to 0x03.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_adv_param(adv_interval, adv_type, adv_channel)
配置广播参数.
\function ble_cmd_ret_e ble_op_set_adv_param(u16 adv_interval,u8 adv_type).
Note
!!!注意:设置的时候必现在广播关闭的状态下.
- Parameters
adv_interval – [in] 广播周期,Range: 0x0020 to 0x4000 (unit: 0.625ms).
adv_type – [in] 广播类型,Range: 0x00 to 0x04.
adv_channel – [in] 广播类型通道,range:Range: 0x01 to 0x07.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_adv_param_ext(adv_interval, adv_type, adv_channel, peer_info)
配置广播参数+配对信息(相比配对广播参数,这个函数主要是针对定向广播使用).
\function ble_cmd_ret_e ble_op_set_adv_param_ext(u16 adv_interval,u8 adv_type,u8 adv_channel,const u8 *peer_info).
Note
!!!注意:设置的时候必现在广播关闭的状态下.
- Parameters
adv_interval – [in] 广播周期,Range: 0x0020 to 0x4000 (unit: 0.625ms).
adv_type – [in] 广播类型,Range: 0x00 to 0x04.
adv_channel – [in] 广播类型通道,range:Range: 0x01 to 0x07.
peer_info – [in] (全局变量地址),定向广播时,填入对方的地址信息.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_adv_data(adv_len, adv_data)
配置广播 Advertising Data内容.
\function ble_cmd_ret_e ble_op_set_adv_data(u8 adv_len,const *u8 adv_data).
Note
!!!注意:设置的时候必现在广播关闭的状态下.
- Parameters
adv_len – [in] adv 数据包长度,Range: 0x00 to 0x1f.
adv_data – [in] (全局变量地址),adv数据包地址.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_rsp_data(rsp_len, rsp_data)
配置广播 Scan Response Data内容.
\function ble_cmd_ret_e ble_op_set_rsp_data(u8 rsp_len,const *u8 rsp_data).
Note
!!!注意:设置的时候必现在广播关闭的状态下.
- Parameters
rsp_len – [in] rsp 包长度,Range: 0x00 to 0x1f.
adv_data – [in] (全局变量地址),rsp数据包地址.
- Returns
see ble_cmd_ret_e.
-
ble_op_disconnect(con_handle)
请求断开 ble 连接.
\function ble_cmd_ret_e ble_op_disconnect(u16 con_handle).
- Parameters
con_handle – [in] range: >0.
- Returns
see ble_cmd_ret_e.
-
ble_op_disconnect_ext(con_handle, reason)
请求断开 ble 连接,by reason
\function ble_cmd_ret_e ble_op_disconnect(u16 con_handle).
- Parameters
con_handle – [in] range: >0.
reason – [in] range: see spec.
- Returns
see ble_cmd_ret_e.
-
ble_op_att_send_init(con_handle, att_ram_addr, att_ram_size, att_payload_size)
配置ATT发送模块RAM大小.
\function ble_cmd_ret_e ble_op_att_send_init(u16 con_handle,u8 *att_ram_addr,int att_ram_size,int att_payload_size).
- Parameters
con_handle – [in] range: >0.
att_ram_addr – [in] 传入ATT发送模块ram地址,地址按4字节对齐.
att_ram_size – [in] 传入ATT发送模块ram大小.
att_payload_size – [in] 发送ATT包payload的最大长度 <= MTU的payload,range:20 to MTU的payload size.
- Returns
see ble_cmd_ret_e.
-
ble_op_multi_att_send_init(att_ram_addr, att_ram_size, att_payload_size)
MULTI API: 配置ATT发送模块初始化.
\function ble_cmd_ret_e ble_op_multi_att_send_init(u8 *att_ram_addr,int att_ram_size,int att_payload_size).
Note
多机处理,只需要初始化一次就可以.
- Parameters
att_ram_addr – [in] 传入ATT发送模块ram地址,地址按4字节对齐.
att_ram_size – [in] 传入ATT发送模块ram大小.
att_payload_size – [in] 发送ATT包payload的最大长度 <= MTU的payload,range:20 to MTU的payload size.
- Returns
see ble_cmd_ret_e.
-
ble_op_multi_att_send_conn_handle(con_handle, handle_index, role)
MULTI API: 配置ATT模块 使用的连接con_handle.
\function ble_cmd_ret_e ble_op_multi_att_send_conn_handle(u16 con_handle,int handle_index,int0 rolev).
Note
多机处理.
- Parameters
con_handle – [in] range:>0.
handle_index – [in] range: 0~7 //多连接的hanlde id.
role – [in] range: 0-gatt_sever,1-gatt_client.
- Returns
see ble_cmd_ret_e.
-
ble_op_att_set_send_mtu(mtu)
根据对方的接收MTU大小,配置本地可发送MTU的payload大小.
\function ble_cmd_ret_e ble_op_att_set_send_mtu(u16 mtu).
- Parameters
mtu – [in] 对方mtu payload的大小.
- Returns
see ble_cmd_ret_e.
-
ble_op_multi_att_set_send_mtu(con_handle, mtu)
MULTI API: 根据对方的接收MTU大小,配置本地可发送的MTU的大小.
\function ble_cmd_ret_e ble_op_multi_att_set_send_mtu(u16 con_handle,u16 mtu).
- Parameters
con_handle – [in] 连接 con_handle,range:>0.
mtu – [in] 对方mtu payload的大小.
- Returns
see ble_cmd_ret_e.
-
ble_op_att_get_remain(remain_size_ptr)
获取ATT发送模块,cbuffer可写入数据的长度.
\function ble_cmd_ret_e ble_op_att_get_remain(int *remain_size_ptr).
- Parameters
remain_size_ptr – [out] 输出可写入长度值.
- Returns
see ble_cmd_ret_e.
-
ble_op_multi_att_get_remain(con_handle, remain_size_ptr)
MULTI API: 获取ATT发送模块,cbuffer 可写入数据的长度.
\function ble_cmd_ret_e ble_op_multi_att_get_remain(u16 con_handle,int *remain_size_ptr).
- Parameters
con_handle – [in] range:>0.
remain_size_ptr – [out] 输出可写入长度值.
- Returns
see ble_cmd_ret_e.
-
ble_op_att_send_data(att_handle, data, len, att_op_type)
ATT操作handle发送数据.
\function ble_cmd_ret_e ble_op_att_send_data(u16 att_handle,u8 *data,u16 len, att_op_type_e att_op_type).
- Parameters
att_handle – [in] att操作的handle.
data – [in] 数据地址.
len – [in] 数据长度 <= cbuffer 可写入的长度.
att_op_type – [in] see att_op_type_e (att.h).
- Returns
see ble_cmd_ret_e.
-
ble_op_multi_att_send_data(con_handle, att_handle, data, len, att_op_type)
MULTI API: ATT操作handle发送数据.
\function ble_cmd_ret_e ble_op_multi_att_send_data(u16 con_handle,u16 att_handle,u8 *data,u16 len, att_op_type_e att_op_type).
Note
多机处理.
- Parameters
con_handle – [in] 连接 con_handle,range:>0.
att_handle – [in] att操作handle.
data – [in] 数据地址.
len – [in] 数据长度 <= cbuffer 可写入的长度.
att_op_type – [in] see att_op_type_e (att.h).
- Returns
see ble_cmd_ret_e.
-
ble_op_att_clear_send_data(void)
ATT操作,清缓存发送的数据缓存
\function ble_op_att_clear_data(void).
- Returns
see ble_cmd_ret_e.
-
ble_op_conn_param_request(con_handle, con_param)
从机请求更新连接参数,走l2cap命令.
\function ble_cmd_ret_e ble_op_conn_param_request(u16 con_handle,const struct conn_update_param_t *con_param).
- Parameters
con_handle – [in] 连接 con_handle,range:>0.
con_param – [in] (全局变量地址),连接参数.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_data_length(con_handle, tx_octets, tx_time)
发起data length 交换.(btctrl的feature打开支持DLE)
\function ble_cmd_ret_e ble_op_set_data_length(u16 con_handle,u16 tx_octets,u16 tx_time).
- Parameters
tx_octets – [in] DLE发送长度.
tx_time – [in] DLE发送事件.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_ext_adv_param(param, param_len)
ble5.0 配置广播参数.
\function ble_cmd_ret_e ble_op_set_ext_adv_param(u8 *param,u16 param_len).
- Parameters
param – [in] 广播参数.
tx_time – [in] 参数长度.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_ext_adv_data(data, data_len)
ble5.0 配置 adv 数据包.
\function ble_cmd_ret_e ble_op_set_ext_adv_data(u8 *data,u16 data_len).
- Parameters
data – [in] 数据包内容.
data_len – [in] 数据包长度.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_ext_rsp_data(data, data_len)
ble5.0 配置 respond 数据包.
\function ble_cmd_ret_e ble_op_set_ext_rsp_data(u8 *data,u16 data_len).
- Parameters
data – [in] 数据包内容.
data_len – [in] 数据包长度.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_ext_adv_enable(cmd, cmd_len)
ble5.0 开关广播.
\function ble_cmd_ret_e ble_op_set_ext_adv_enable(u8 *cmd,u16 cmd_le).
- Parameters
cmd – [in] 命令信息.
cmd_len – [in] 命令长度.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_ext_phy(con_handle, all_phys, tx_phy, rx_phy, phy_options)
ble5.0 配置phy.
\function ble_cmd_ret_e ble_op_set_ext_phy(u16 con_handle,u16 all_phys,u16 tx_phy,u16 rx_phy,u16 phy_options).
- Parameters
con_handle – [in] 连接 con_handle,range:>0.
all_phys – [in] 0.
tx_phy – [in] CONN_SET_CODED_PHY.
rx_phy – [in] CONN_SET_CODED_PHY.
phy_options – [in] CONN_SET_PHY_OPTIONS.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_ext_scan_param(param, param_len)
ble5.0 配置 主机scan 参数.
\function ble_cmd_ret_e ble_op_set_ext_scan_param(u8 *param,u16 param_le).
- Parameters
param – [in] 参数内容.
param_len – [in] 参数长度.
- Returns
see ble_cmd_ret_e.
-
ble_op_ext_scan_enable(cmd, cmd_len)
ble5.0 配置 主机scan 开关.
\function ble_cmd_ret_e ble_op_ext_scan_enable(u8 *cmd,u16 cmd_le).
- Parameters
cmd – [in] 命令信息.
cmd_len – [in] 命令长度.
- Returns
see ble_cmd_ret_e.
-
ble_op_ext_create_conn(conn_param, param_len)
ble5.0 配置 主机创建连接监听.
\function ble_cmd_ret_e ble_op_ext_create_conn(u8 *conn_param,u16 param_len_len).
- Parameters
conn_param – [in] 连接参数信息.
param_len – [in] 参数长度.
- Returns
see ble_cmd_ret_e.
-
ble_op_latency_skip(con_handle, skip_interval)
忽略进入latency 作用的次数
\function ble_cmd_ret_e ble_op_latency_skip(u16 con_handle,u16 skip_interval).
Note
!!!注意:让设备不进入latency模式,加快响应速度,但会耗电.
- Parameters
con_handle – [in] range:>0.
skip_interval – [in] 忽略的interval的次数.
- Returns
see ble_cmd_ret_e.
-
ble_op_test_key_num(con_handle, key_num)
测试盒识别按键测试.
\function ble_cmd_ret_e ble_op_test_key_num(u16 con_handle,u8 key_num).
- Parameters
con_handle – [in] range:>0.
key_num – [in] 按键.
- Returns
see ble_cmd_ret_e.
-
ble_op_stack_exit(control)
退出ble协议栈.
\function ble_cmd_ret_e ble_op_stack_exit(u8 control).
Note
若已调用btstack_exit退出,则无需调用此接口
- Parameters
control – [in] : 0—退出stack(默认),1—退出stack + controller.
- Returns
see ble_cmd_ret_e.
-
ble_op_regist_thread_call(thread_callback)
挂载协议栈线程调用.
\function ble_cmd_ret_e ble_op_regist_thread_call(void (*thread_callback)(void)).
Note
用于同步线程处理,慎用
- Parameters
thread_callback – [in] 回调函数.
- Returns
see ble_cmd_ret_e.
-
ble_op_scan_enable(enable)
开关BLE搜索扫描.
\function ble_cmd_ret_e ble_op_scan_enable(u8 enable).
Note
filter_duplicate 默认为 1.
Note
!!!注意:开搜索前必现先配置好搜索的参数ble_op_set_scan_param.
- Parameters
enable – [in] 0 or 1.
- Returns
see ble_cmd_ret_e.
-
ble_op_scan_enable2(enable, filter_duplicate)
开关BLE搜索扫描2.
\function ble_cmd_ret_e ble_op_scan_enable2(u8 enable,u8 filter_duplicate).
Note
filter_duplicate 默认为 1.
Note
!!!注意:开搜索前必现先配置好搜索的参数ble_op_set_scan_param.
- Parameters
enable – [in] 0 or 1.
filter_duplicate – [in] 0 or 1.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_scan_filter_policy(type)
配置scan filter policy,默认type为0.
\function ble_cmd_ret_e ble_op_set_scan_filter_policy(u8 type).
Note
!!!注意:设置的时候必须在 设置扫描参数 ble_op_set_scan_param 前配置好.
- Parameters
type – [in] Range: 0x00 to 0x03.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_scan_param(scan_type, scan_interval, scan_window)
配置搜索参数.
\function ble_cmd_ret_e ble_op_set_scan_param(u8 scan_type,u16 scan_interval,u16 scan_window).
- Parameters
scan_type – [in] 搜索类型 Range: 0x00 to 0x01 (unit: 0.625ms).
scan_interval – [in] 搜索周期 Range: 0x0004 to 0x4000 (unit: 0.625ms) >= scan_window.
scan_window – [in] 搜索窗口 Range: 0x0004 to 0x4000 (unit: 0.625ms), <= scan_interval.
- Returns
see ble_cmd_ret_e.
-
ble_op_set_create_filter_policy(type)
配置creat filter policy,默认type: 0.
\function ble_cmd_ret_e ble_op_set_create_filter_policy(u8 type).
Note
!!!注意:设置的时候必须在 设置创建连接参数 ble_op_create_connection 前配置好.
- Parameters
type – [in] Range: 0x00 to 0x03.
- Returns
see ble_cmd_ret_e.
-
ble_op_create_connection(create_conn_param)
BLE创建连接监听.
\function ble_cmd_ret_e ble_op_create_connection(struct create_conn_param_t * create_conn_param).
- Parameters
create_conn_param – [in] 连接参数.
- Returns
see ble_cmd_ret_e.
-
ble_op_create_connection_ext(create_conn_param_ext)
BLE创建连接监听,扩展传入参数
\function ble_cmd_ret_e ble_op_create_connection_ext(cosnt struct create_conn_param_ext_t * create_conn_param_ext).
- Parameters
create_conn_param_ext – [in] 连接参数.
- Returns
see ble_cmd_ret_e.
-
ble_op_create_connection_cancel()
取消BLE连接监听.
\function ble_cmd_ret_e ble_op_create_connection_cancel(void).
- Returns
see ble_cmd_ret_e.
-
ble_op_search_profile_all()
ble 主机搜索所有服务.
\function ble_cmd_ret_e ble_op_search_profile_all(void).
- Returns
see ble_cmd_ret_e.
-
ble_op_search_profile_uuid16(uuid16)
ble 主机搜索指定UUID16服务.
\function ble_cmd_ret_e ble_op_search_profile_uuid16(u16 uuid16).
- Parameters
uuid16 – [in] uuid.
- Returns
see ble_cmd_ret_e.
-
ble_op_search_profile_uuid128(uuid128_pt)
ble 主机搜索指定UUID128服务.
\function ble_cmd_ret_e ble_op_search_profile_uuid128(const u8 *uuid128_pt).
- Parameters
uuid128_pt – [in] uuid.
- Returns
see ble_cmd_ret_e.
-
ble_op_conn_param_update(con_handle, con_param)
ble 主机更新连接参数.
\function ble_cmd_ret_e ble_op_conn_param_update(u16 con_handle,struct conn_update_param_t *con_param).
- Parameters
con_handle – [in] range:>0.
con_param – [in] (全局变量地址),连接参数.
- Returns
see ble_cmd_ret_e.
Enums
-
enum ble_cmd_type_e
hci connection handle type
-—user (command) codes-—
Values:
-
enumerator BLE_CMD_ADV_ENABLE
-
enumerator BLE_CMD_ADV_PARAM
-
enumerator BLE_CMD_ADV_DATA
-
enumerator BLE_CMD_RSP_DATA
-
enumerator BLE_CMD_DISCONNECT
-
enumerator BLE_CMD_REGIEST_THREAD
-
enumerator BLE_CMD_ATT_SEND_INIT
-
enumerator BLE_CMD_ATT_MTU_SIZE
-
enumerator BLE_CMD_ATT_VAILD_LEN
-
enumerator BLE_CMD_ATT_SEND_DATA
-
enumerator BLE_CMD_REQ_CONN_PARAM_UPDATE
-
enumerator BLE_CMD_SCAN_ENABLE
-
enumerator BLE_CMD_SCAN_PARAM
-
enumerator BLE_CMD_STACK_EXIT
-
enumerator BLE_CMD_CREATE_CONN
-
enumerator BLE_CMD_CREATE_CONN_CANCEL
-
enumerator BLE_CMD_ADV_PARAM_EXT
-
enumerator BLE_CMD_SEND_TEST_KEY_NUM
-
enumerator BLE_CMD_LATENCY_HOLD_CNT
-
enumerator BLE_CMD_SET_DATA_LENGTH
-
enumerator BLE_CMD_SET_HCI_CFG
-
enumerator BLE_CMD_SCAN_ENABLE2
-
enumerator BLE_CMD_ATT_SERVER_REQ_RESUME
-
enumerator BLE_CMD_MULTI_ATT_SEND_INIT
-
enumerator BLE_CMD_MULTI_ATT_SET_CONN_HANDLE
-
enumerator BLE_CMD_MULTI_ATT_SEND_DATA
-
enumerator BLE_CMD_MULTI_ATT_MTU_SIZE
-
enumerator BLE_CMD_MULTI_ATT_VAILD_LEN
-
enumerator BLE_CMD_SM_REQ_RESUME
-
enumerator BLE_CMD_CREATE_CONN_EXT
-
enumerator BLE_CMD_DISCONNECT_EXT
-
enumerator BLE_CMD_ATT_CLEAR_SEND_DATA
-
enumerator BLE_CMD_EXT_ADV_PARAM
-
enumerator BLE_CMD_EXT_ADV_DATA
-
enumerator BLE_CMD_EXT_RSP_DATA
-
enumerator BLE_CMD_EXT_ADV_ENABLE
-
enumerator BLE_CMD_SET_PHY
-
enumerator BLE_CMD_EXT_SCAN_PARAM
-
enumerator BLE_CMD_EXT_SCAN_ENABLE
-
enumerator BLE_CMD_EXT_CREATE_CONN
-
enumerator BLE_CMD_PERIODIC_ADV_PARAM
-
enumerator BLE_CMD_PERIODIC_ADV_DATA
-
enumerator BLE_CMD_PERIODIC_ADV_ENABLE
-
enumerator BLE_CMD_PERIODIC_ADV_CREAT_SYNC
-
enumerator BLE_CMD_PERIODIC_ADV_TERMINATE_SYNC
-
enumerator BLE_CMD_PERIODIC_ADV_CREATE_SYNC_CANCEL
-
enumerator BLE_CMD_SEARCH_PROFILE
-
enumerator BLE_CMD_WRITE_CCC
-
enumerator BLE_CMD_ONNN_PARAM_UPDATA
-
enumerator BLE_CMD_ADV_ENABLE
-
enum ble_cmd_ret_e
Values:
-
enumerator BLE_CMD_RET_SUCESS
-
enumerator BLE_CMD_RET_BUSY
-
enumerator BLE_CMD_PARAM_OVERFLOW
-
enumerator BLE_CMD_OPT_FAIL
-
enumerator BLE_BUFFER_FULL
-
enumerator BLE_BUFFER_ERROR
-
enumerator BLE_CMD_PARAM_ERROR
-
enumerator BLE_CMD_STACK_NOT_RUN
-
enumerator BLE_CMD_CCC_FAIL
-
enumerator BLE_CMD_RET_SUCESS
-
enum search_profile_type_e
Values:
-
enumerator PFL_SERVER_UUID16
-
enumerator PFL_SERVER_UUID128
-
enumerator PFL_SERVER_ALL
-
enumerator PFL_SERVER_UUID16
Functions
-
ble_cmd_ret_e ble_user_cmd_prepare(ble_cmd_type_e cmd, int argc, ...)
-
void gatt_client_init(void)
Gatt client角色初始化.
-
void gatt_client_register_packet_handler(btstack_packet_handler_t handler)
注册gatt client角色,事件回调函数.
- Parameters
handler – [in] 事件处理函数.
-
void le_device_db_init(void)
初始化配对表.
Note
上电初始化一次.
-
void reset_PK_cb_register(void (*reset_pk)(u32*))
注册passkey输入回调.
- Parameters
reset_pk – [in] 复位按键输入.
-
int le_controller_set_mac(void *addr)
设置ble蓝牙的public地址.
Note
可以结合接口 ble_op_set_ownaddress_type 配置选择地址类型.
Note
修改地址必须在ble非工作状态下才能生效( 没有scan,没有adv,没有connected).
- Parameters
addr – [in] public地址.
- Returns
0->success ,非0->fail.
-
int le_controller_get_mac(void *addr)
获取ble蓝牙的public地址.
- Parameters
addr – [out] pulic地址.
- Returns
0->success ,非0->fail.
-
int le_controller_set_random_mac(void *addr)
初始化ble蓝牙random地址.
Note
结合接口ble_op_set_own_address_type 配置选择地址类型.
Note
修改地址必须在ble非工作状态下才能生效(内有scan,没有adv,没connected).
- Parameters
addr – [in] random地址.
- Returns
0->success ,非0->fail.
-
int le_controller_get_random_mac(void *addr)
获取ble蓝牙的random地址.
- Parameters
addr – [out] random地址.
- Returns
0->success ,非0->fail.
-
void ble_stack_gatt_role(u8 role)
配置协议栈 GATT 角色处理,default server.
- Parameters
role – [in] GATT role: 0—server ,1—client ,2—server + client.
-
void user_client_init(u16 handle, u8 *buffer, u16 buffer_size)
client 连接后初始化.
- Parameters
handle – [in] range :>0.
buffer – [in] 配置缓存地址.
buffer_size – [in] 缓存大小.
-
s8 ble_vendor_get_peer_rssi(u16 conn_handle)
获取链路对方的信号强度.
- Parameters
con_handle – [in] range :>0.
- Returns
rssi 强度 ,range :-127 ~128 dbm.
-
bool ble_vendor_interval_event_enable(u16 conn_handle, int enable)
使能周期interval事件上报.
- Parameters
con_handle – [in] range :>0.
enable – [in] 1 or 0.
- Returns
true or false.
-
u16 ble_vendor_set_default_att_mtu(u16 mtu_size)
配置协议栈ATT默认的MTU大小.
- Parameters
mtu_size – [in] 配置MUT大小 ,range :23 ~517.
- Returns
配置后mtu_size的值.
-
void user_client_set_search_complete(void)
设置 client 搜索结束.
-
bool ble_vendor_random_address_generate(u8 *address, u8 type)
提供生成ble对应的类型地址.
Note
生成RESOLVABLE_PRIVATE_ADDR,需要等协议栈初始化IRK后才能生成.
- Parameters
address – [out] 类型对应地址.
type – [in] ble_type (eg:1.STATIC_DEVICE_ADDR. 2.NON_RESOLVABLE_PRIVATE_ADDR. 3.RESOLVABLE_PRIVATE_ADDR).
- Returns
true or false.
-
void lib_make_ble_address(u8 *ble_address, u8 *edr_address)
根据提供的edr地址生成唯一对应的ble地址.
Note
用户可以自定义edr和ble地址关联规则,重写这个接口
- Parameters
ble_adress – [out] BLE_address.
edr_adress – [in] EDR_address.
-
void ble_list_config_reset(u8 pair_devices_count, u8 is_allow_cover)
ble master&slave 配置配对表(可以不设置,使用sdk默认值).
Note
上电调用配置,若配置的个数跟之前不一样,默认清所有的配对表数据.
Note
VM 掉电记录保护.
Note
主从机共用一个配对表.
- Parameters
pair_devices_count – [in] 记录配对设备,range: 0~10,默认10.若配置为0:则不使用配对表记录管理,不限制配对个数.
is_allow_cover – [in] 是否允许循环覆盖记录 1 or 0,默认1.
- Returns
true or false.
-
bool ble_list_pair_accept(u8 enable)
配置是否接受新设备请求配对,记录在VM,(可以不设置,使用sdk默认值).
Note
VM 掉电记录保护.
Note
是否覆盖是由接口 ble_list_config_reset 的参数 is_allow_cover 决定.
- Parameters
enable – [in] 允许新设备配对开关,1 or 0,默认1.
- Returns
true or false.
-
u16 ble_list_get_count(void)
获取配对表已有配对个数.
- Returns
0~10.
-
bool ble_list_bonding_remote(u8 *conn_addr, u8 conn_addr_type)
绑定已配对的指定设备,清除其他配对设备.
Note
VM 掉电记录保护.
- Parameters
conn_addr – [in] 对方地址6bytes.
conn_addr_type – [in] 对方地址类型range: 0~1.
- Returns
true or false.
-
bool ble_list_clear_all(void)
ble 清空配对表.
- Returns
true or false.
-
bool ble_list_check_addr_is_exist(u8 *conn_addr, u8 conn_addr_type)
ble 检测连接地址是否在已配对表中.
- Parameters
conn_addr – [in] 对方地址6bytes.
conn_addr_type – [in] 对方地址类型range: 0~1.
- Returns
true or false.
-
bool ble_list_delete_device(u8 *conn_addr, u8 conn_addr_type)
ble 把设备从配对表中删除.
- Parameters
conn_addr – [in] 对方地址6bytes.
conn_addr_type – [in] 对方地址类型range: 0~1.
- Returns
true or false.
-
bool ble_list_get_last_id_addr(u8 *id_addr)
ble 获取配对表中最后连接设备的 id_address (public address).
- Parameters
id_addr – [out] 输出最后连接设备的id地址.
- Returns
true or false.
-
bool ble_list_get_id_addr(u8 *conn_addr, u8 conn_addr_type, u8 *id_addr)
ble 获取已配对设备连接地址对应的 id_address (public address or static address).
- Parameters
conn_addr – [in] 对方连接地址6bytes.
conn_addr_type – [in] 对方连接地址类型range: 0~1.
id_addr – [out] 输出已配对设备的id地址.
- Returns
true or false.
-
bool ble_list_get_remote_type(u8 *conn_addr, u8 conn_addr_type, u8 *output_type)
ble 获取已配对设备的系统类型.
Note
只支持作为从机获取手机类型.
- Parameters
conn_addr – [in] 对方连接地址6bytes.
conn_addr_type – [in] 对方连接地址类型range: 0~1.
output_type – [out] 见 remote_type_e 定义.
- Returns
true or false.
-
void att_server_set_exchange_mtu(u16 con_handle)
ble slave: att server 连接后主动发起请求MTU交换流程.
- Parameters
handle – [in] range:>0.
-
void att_server_flow_enable(u8 enable)
ble slave: att server 使能流控功能.
Note
蓝牙初始化后可调用.
- Parameters
handle – [in] range:>0.
enable – [in] 1 or 0.
-
void att_server_flow_hold(hci_con_handle_t con_handle, u8 hold_flag)
ble slave: att server 控制收数流控.
Note
蓝牙初始化后可调用,对方client要使用write的方式发送数据才能有流控生效
- Parameters
handle – [in] range:>0.
hold_flag – [in] 1—停止收发数据,0—开始正常收发数.
-
void att_server_set_check_remote(u16 con_handle, void (*callback)(u16 con_handle, remote_type_e remote_type))
ble slave: server 配对连接时,检查对方操作系统.
Note
在第一次配对连接时调用,HCI_EVENT_ENCRYPTION_CHANGE 事件后.
- Parameters
handle – [in] range:>0.
callback – [in] 检查完回调.
-
int att_send_check_multi_dev(u8 server_max, u8 client_max)
检测协议栈att模块是否支持多机.
- Parameters
server_max – [in] 传入判断的从机个数.
client_max – [in] 传入判断的主机个数·.
- Returns
0->success ,非0->fail.
-
int att_server_change_profile(u8 const *profile_data)
可修改GATT服务的profile.
Note
蓝牙未连接状态下,可调用修改.
- Parameters
profile_data – [in] gatt profile.
- Returns
0->success ,非0->fail.
Variables
-
struct create_conn_param_t _GNU_PACKED_
-
struct conn_update_param_t
-
struct create_conn_param_t
-
struct create_conn_param_ext_t
-
struct adv_report_t
-
struct sm_just_event_t