KT24-1110_65E-HA-651B/include_lib/btstack/le/ble_api.h

1064 lines
43 KiB
C
Raw Normal View History

2024-11-10 10:44:17 +00:00
/*********************************************************************************************
* Filename : ble_api.h
* Description :
* Author : mx
* Email : lmx@zh-jieli.com
* Last modifiled : 2020-07-01 16:36
* Copyright:(c)JIELI 2011-2020 @ , All Rights Reserved.
*********************************************************************************************/
#ifndef __BLE_API_H__
#define __BLE_API_H__
#include "typedef.h"
#include "btstack/btstack_typedef.h"
///***注意:该文件的枚举与库编译密切相关,主要是给用户提供调用所用。用户不能自己在中间添加值。*/
////----user (command) codes----////
/**
* @brief hci connection handle type
*/
typedef enum {
/*
*/
BLE_CMD_ADV_ENABLE = 1,
BLE_CMD_ADV_PARAM,
BLE_CMD_ADV_DATA,
BLE_CMD_RSP_DATA,
BLE_CMD_DISCONNECT,
BLE_CMD_REGIEST_THREAD,
BLE_CMD_ATT_SEND_INIT,
BLE_CMD_ATT_MTU_SIZE,
BLE_CMD_ATT_VAILD_LEN,
BLE_CMD_ATT_SEND_DATA,
BLE_CMD_REQ_CONN_PARAM_UPDATE,
BLE_CMD_SCAN_ENABLE,
BLE_CMD_SCAN_PARAM,
BLE_CMD_STACK_EXIT,
BLE_CMD_CREATE_CONN,
BLE_CMD_CREATE_CONN_CANCEL,
BLE_CMD_ADV_PARAM_EXT,
BLE_CMD_SEND_TEST_KEY_NUM,
BLE_CMD_LATENCY_HOLD_CNT,
BLE_CMD_SET_DATA_LENGTH,
BLE_CMD_SET_HCI_CFG,
BLE_CMD_SCAN_ENABLE2,
BLE_CMD_ATT_SERVER_REQ_RESUME,
//MULTI API,多机接口
BLE_CMD_MULTI_ATT_SEND_INIT,
BLE_CMD_MULTI_ATT_SET_CONN_HANDLE,
BLE_CMD_MULTI_ATT_SEND_DATA,
BLE_CMD_MULTI_ATT_MTU_SIZE,
BLE_CMD_MULTI_ATT_VAILD_LEN,
//< ble5
BLE_CMD_EXT_ADV_PARAM = 0x40,
BLE_CMD_EXT_ADV_DATA,
BLE_CMD_EXT_RSP_DATA,
BLE_CMD_EXT_ADV_ENABLE,
BLE_CMD_SET_PHY,
BLE_CMD_EXT_SCAN_PARAM,
BLE_CMD_EXT_SCAN_ENABLE,
BLE_CMD_EXT_CREATE_CONN,
BLE_CMD_PERIODIC_ADV_PARAM,
BLE_CMD_PERIODIC_ADV_DATA,
BLE_CMD_PERIODIC_ADV_ENABLE,
BLE_CMD_PERIODIC_ADV_CREAT_SYNC,
//client
BLE_CMD_SEARCH_PROFILE = 0x80,
BLE_CMD_WRITE_CCC,
BLE_CMD_ONNN_PARAM_UPDATA,
} ble_cmd_type_e;
typedef enum {
BLE_CMD_RET_SUCESS = 0, //执行成功
BLE_CMD_RET_BUSY = -100, //命令处理忙
BLE_CMD_PARAM_OVERFLOW, //传数溢出
BLE_CMD_OPT_FAIL, //操作失败
BLE_BUFFER_FULL, //缓存满了
BLE_BUFFER_ERROR, //缓存出错
BLE_CMD_PARAM_ERROR, //传参出错
BLE_CMD_STACK_NOT_RUN, //协议栈没有运行
BLE_CMD_CCC_FAIL, //没有使能通知导致NOTIFY或INDICATE发送失败
} ble_cmd_ret_e;
//--------------------------------------------
ble_cmd_ret_e ble_user_cmd_prepare(ble_cmd_type_e cmd, int argc, ...);
struct conn_update_param_t {
u16 interval_min; //(unit:0.625ms)
u16 interval_max; //(unit:0.625ms)
u16 latency; //(unit: interval)
u16 timeout; //(unit:10ms)
};
typedef enum {
PFL_SERVER_UUID16 = 1, //指定16bit UUID搜索方式
PFL_SERVER_UUID128, //指定128bit UUID搜索方式
PFL_SERVER_ALL, //搜索所有的UUID
} search_profile_type_e;
//------
struct create_conn_param_t {
u16 conn_interval; //0--public address,1--random address
u16 conn_latency; //(unit: interval)
u16 supervision_timeout; //(unit:10ms)
u8 peer_address_type; //0--public address,1--random address
u8 peer_address[6];
} _GNU_PACKED_;
typedef struct {
u8 event_type; //0--ADV_IND,1--ADV_DIRECT_IND,2--ADV_SCAN_IND,3--ADV_NONCONN_IND,4--SCAN_RSP
u8 address_type; //0--public address,1--random address
u8 address[6]; //peer_address
s8 rssi; //range:-127 ~128 dbm
u8 length; //广播包长度
u8 data[0]; //广播包内容
} adv_report_t;
typedef struct {
//base info
u8 type; //< See <btstack/hci_cmds.h> SM_...
u8 size;
u16 con_handle; //connection 's handle, >0
u8 addr_type; //0--public address,1--random address
u8 address[6];
//extend info
u8 data[4];
} sm_just_event_t;
//BLE_CMD_SET_HCI_CFG
typedef enum {
HCI_CFG_OWN_ADDRESS_TYPE = 0, //
HCI_CFG_ADV_FILTER_POLICY, //
HCI_CFG_SCAN_FILTER_POLICY, //
HCI_CFG_INITIATOR_FILTER_POLICY, //
//add here
} hci_cfg_par_e;
typedef enum {
REMOTE_TYPE_UNKNOWN = 0,//未查询or查询对方未响应
REMOTE_TYPE_ANDROID,
REMOTE_TYPE_IOS,
} remote_type_e;
//-----------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------
/**********************************************************************************
@function gatt client
@return
*********************************************************************************/
void gatt_client_init(void);
/**********************************************************************************
@function gatt client ,
@param [in] handler
@return
*********************************************************************************/
void gatt_client_register_packet_handler(btstack_packet_handler_t handler);
/**********************************************************************************
@function
@param [in]
@return
note:
*********************************************************************************/
void le_device_db_init(void);
/**********************************************************************************
@function passkey
@param [in]
@return
*********************************************************************************/
void reset_PK_cb_register(void (*reset_pk)(u32 *));
/**********************************************************************************
@function ble的蓝牙public地址
@param [in] addr
@return 0--success ,0--fail
note: ble_op_set_own_address_type
note:ble非工作状态下才能生效scan,adv,connected
*********************************************************************************/
int le_controller_set_mac(void *addr);
/**********************************************************************************
@function ble的蓝牙public地址
@param [out] addr
@return 0--success ,0--fail
*********************************************************************************/
int le_controller_get_mac(void *addr);
/**********************************************************************************
@function ble的蓝牙random地址
@param [in] addr
@return 0--success ,0--fail
note: ble_op_set_own_address_type
note:ble非工作状态下才能生效scan,adv,connected
*********************************************************************************/
int le_controller_set_random_mac(void *addr);
/**********************************************************************************
@function ble的蓝牙random地址
@param [out] addr
@return 0--success ,0--fail
*********************************************************************************/
int le_controller_get_random_mac(void *addr);
/**********************************************************************************
@function GATT ,default server
@param [in] role 0--server, or 1--client,or 2--server+client
@return
*********************************************************************************/
void ble_stack_gatt_role(u8 role);
/**********************************************************************************
@function client
@param [in] handle con_handle,range>0
@param [in] buffer
@param [in] buffer_size
@return
*********************************************************************************/
void user_client_init(u16 handle, u8 *buffer, u16 buffer_size);
/**********************************************************************************
@function
@param [in] con_handle handle, range>0
@return rssi range:-127 ~128 dbm
*********************************************************************************/
s8 ble_vendor_get_peer_rssi(u16 conn_handle);
/**********************************************************************************
@function 使interval事件上报
@param [in] con_handle handle, range>0
@param [in] enable 1 or 0
@return true or false
*********************************************************************************/
bool ble_vendor_interval_event_enable(u16 conn_handle, int enable);
/**********************************************************************************
@function ATT默认的MTU
@param [in] mtu_size, range: 23~517
@return mtu_size值
*********************************************************************************/
u16 ble_vendor_set_default_att_mtu(u16 mtu_size);
/**********************************************************************************
@function
@param [in]
@return
*********************************************************************************/
void user_client_set_search_complete(void);
/**********************************************************************************
@function ble对应的类型地址
@param [out] address
@param [in] type
1--STATIC_DEVICE_ADDR
2--NON_RESOLVABLE_PRIVATE_ADDR
3--RESOLVABLE_PRIVATE_ADDR
@return
*********************************************************************************/
void ble_vendor_address_generate(u8 *address, u8 type);
/**********************************************************************************
@function edr地址生成唯一对应ble地址
@param [out] ble_address
@param [in] edr_address
@return
*********************************************************************************/
void lib_make_ble_address(u8 *ble_address, u8 *edr_address);
/**********************************************************************************
@function 0--public address
@param [in] address_type Range: 0x00 to 0x03
@return see ble_cmd_ret_e
!!! 广
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_own_address_type(u8 address_type) */
#define ble_op_set_own_address_type(address_type) \
ble_user_cmd_prepare(BLE_CMD_SET_HCI_CFG, 2,HCI_CFG_OWN_ADDRESS_TYPE,(int)address_type)
/**********************************************************************************
@function BLE广播 !!!广广
@param [in] enable 0 or 1
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_adv_enable(int enable) */
#define ble_op_adv_enable(enable) \
ble_user_cmd_prepare(BLE_CMD_ADV_ENABLE, 1, (int)enable)
/**********************************************************************************
@function adv filter policy, default 0
@param [in] type Range: 0x00 to 0x03
@return see ble_cmd_ret_e
!!! 广
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_adv_filter_policy(u8 type) */
#define ble_op_set_adv_filter_policy(type) \
ble_user_cmd_prepare(BLE_CMD_SET_HCI_CFG, 2,HCI_CFG_ADV_FILTER_POLICY,type)
/**********************************************************************************
@function 广!!!广
@param [in] adv_interval 广Range: 0x0020 to 0x4000 (unit: 0.625ms)
@param [in] adv_type 广Range: 0x00 to 0x04
@param [in] adv_channel 广range:Range: 0x01 to 0x07
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_adv_param(u16 adv_interval,u8 adv_type) */
#define ble_op_set_adv_param(adv_interval,adv_type,adv_channel) \
ble_user_cmd_prepare(BLE_CMD_ADV_PARAM, 3, (int)adv_interval, (int)adv_type, (int)adv_channel)
/**********************************************************************************
@function 广!!!广
@param [in] adv_interval 广Range: 0x0020 to 0x4000 (unit: 0.625ms)
@param [in] adv_type 广Range: 0x00 to 0x04
@param [in] adv_channel 广range:Range: 0x01 to 0x07
@param [in] peer_info ()广
peer_info[0]--range 0~1peer_info[1~7]--
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_adv_param_ext(u16 adv_interval,u8 adv_type,u8 adv_channel,const u8 *peer_info) */
#define ble_op_set_adv_param_ext(adv_interval,adv_type,adv_channel,peer_info) \
ble_user_cmd_prepare(BLE_CMD_ADV_PARAM_EXT, 4, (int)adv_interval, (int)adv_type, (int)adv_channel, (void*)peer_info)
/**********************************************************************************
@function 广 Advertising Data内容!!!广
@param [in] adv_len adv Range: 0x00 to 0x1f
@param [in] adv_data ()adv数据包地址
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_adv_data(u8 adv_len,const *u8 adv_data) */
#define ble_op_set_adv_data(adv_len,adv_data) \
ble_user_cmd_prepare(BLE_CMD_ADV_DATA, 2, (int)adv_len, (void*)adv_data)
/**********************************************************************************
@function 广 Scan Response Data内容!!!广
@param [in] rsp_len rsp Range: 0x00 to 0x1f
@param [in] rsp_data ()rsp数据包地址
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_rsp_data(u8 rsp_len,const *u8 rsp_data) */
#define ble_op_set_rsp_data(rsp_len,rsp_data) \
ble_user_cmd_prepare(BLE_CMD_RSP_DATA, 2, (int)rsp_len, (void*)rsp_data)
/**********************************************************************************
@function ble
@param [in] con_handle handlerange>0
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_disconnect(u16 con_handle) */
#define ble_op_disconnect(con_handle) \
ble_user_cmd_prepare(BLE_CMD_DISCONNECT, 1, (int)con_handle)
/**********************************************************************************
@function ATT发送模块RAM大小
@param [in] con_handle con_handle,range>0
@param [in] att_ram_addr ATT发送模块ram地址4
@param [in] att_ram_size ATT发送模块ram大小
@param [in] att_payload_size ATT包payload的最大长度 <= MTUrange20 to MTU size
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_att_send_init(u16 con_handle,u8 *att_ram_addr,int att_ram_size,int att_payload_size) */
#define ble_op_att_send_init(con_handle,att_ram_addr,att_ram_size,att_payload_size) \
ble_user_cmd_prepare(BLE_CMD_ATT_SEND_INIT, 4, con_handle,att_ram_addr,att_ram_size,att_payload_size)
/**********************************************************************************
@function MULTI API: ATT发送模块初始化
@param [in] att_ram_addr ATT发送模块ram地址4
@param [in] att_ram_size ATT发送模块ram大小
@param [in] att_payload_size ATT包payload的最大长度 <= MTUrange20 to MTU size
@return see ble_cmd_ret_e
note:
*********************************************************************************/
/* ble_cmd_ret_e ble_op_multi_att_send_init(u8 *att_ram_addr,int att_ram_size,int att_payload_size) */
#define ble_op_multi_att_send_init(att_ram_addr,att_ram_size,att_payload_size) \
ble_user_cmd_prepare(BLE_CMD_MULTI_ATT_SEND_INIT, 3, att_ram_addr,att_ram_size,att_payload_size)
/**********************************************************************************
@function MULTI API: ATT handle
@param [in] con_handle con_handle,range>0
@param [in] handle_index range:0~7 //多连接的hanlde id
@param [in] role range:0-slave,1-master
@return see ble_cmd_ret_e
note:
*********************************************************************************/
/* ble_cmd_ret_e ble_op_multi_att_send_conn_handle(u16 con_handle,int handle_index,int role) */
#define ble_op_multi_att_send_conn_handle(con_handle,handle_index,role) \
ble_user_cmd_prepare(BLE_CMD_MULTI_ATT_SET_CONN_HANDLE, 3, con_handle,handle_index,role)
/**********************************************************************************
@function MTU大小MTU的大小
@param [in]mtu mtu payload的大小
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_att_set_send_mtu(u16 mtu) */
#define ble_op_att_set_send_mtu(mtu) \
ble_user_cmd_prepare(BLE_CMD_ATT_MTU_SIZE, 1, mtu);
/**********************************************************************************
@function MULTI API: MTU大小MTU的大小
@param [in] con_handle con_handle,range>0
@param [in] mtu mtu payload的大小
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
note:
*********************************************************************************/
/* ble_cmd_ret_e ble_op_multi_att_set_send_mtu(u16 con_handle,u16 mtu) */
#define ble_op_multi_att_set_send_mtu(con_handle,mtu) \
ble_user_cmd_prepare(BLE_CMD_MULTI_ATT_MTU_SIZE, 2, con_handle,mtu);
/**********************************************************************************
@function ATT发送模块cbuffer
@param [out] remain_size_ptr
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_att_get_remain(int *remain_size_ptr) */
#define ble_op_att_get_remain(remain_size_ptr) \
ble_user_cmd_prepare(BLE_CMD_ATT_VAILD_LEN, 1, remain_size_ptr)
/**********************************************************************************
@function MULTI API: ATT发送模块cbuffer
@param [in] con_handle con_handle,range>0
@param [out] remain_size_ptr
@return see ble_cmd_ret_e
note:
*********************************************************************************/
/* ble_cmd_ret_e ble_op_multi_att_get_remain(u16 con_handle,int *remain_size_ptr) */
#define ble_op_multi_att_get_remain(con_handle,remain_size_ptr) \
ble_user_cmd_prepare(BLE_CMD_MULTI_ATT_VAILD_LEN, 2,con_handle, remain_size_ptr)
/**********************************************************************************
@function ATT操作handle发送数据
@param [in] att_handle att handle
@param [in] data
@param [in] len <= cbuffer
@param [in] att_op_type see att_op_type_e (att.h)
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_att_send_data(u16 att_handle,u8 *data,u16 len, att_op_type_e att_op_type) */
#define ble_op_att_send_data(att_handle,data,len,att_op_type) \
ble_user_cmd_prepare(BLE_CMD_ATT_SEND_DATA, 4, att_handle, data, len, att_op_type)
/**********************************************************************************
@function MULTI API: ATT操作handle发送数据
@param [in] con_handle con_handle,range>0
@param [in] att_handle att handle
@param [in] data
@param [in] len <= cbuffer
@param [in] att_op_type see att_op_type_e (att.h)
@return see ble_cmd_ret_e
note:
*********************************************************************************/
/* 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) */
#define ble_op_multi_att_send_data(con_handle,att_handle,data,len,att_op_type) \
ble_user_cmd_prepare(BLE_CMD_MULTI_ATT_SEND_DATA, 5, con_handle,att_handle, data, len, att_op_type)
/**********************************************************************************
@function
@param [in] con_handle con_handle,range>0
@param [in] con_param ()
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_conn_param_request(u16 con_handle,const struct conn_update_param_t *con_param) */
#define ble_op_conn_param_request(con_handle,con_param) \
ble_user_cmd_prepare(BLE_CMD_REQ_CONN_PARAM_UPDATE, 2, con_handle, (void*)con_param)
/**********************************************************************************
@function data length
@param [in] tx_octets
@param [in] tx_time
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_data_length(u16 con_handle,u16 tx_octets,u16 tx_time) */
#define ble_op_set_data_length(con_handle,tx_octets,tx_time) \
ble_user_cmd_prepare(BLE_CMD_SET_DATA_LENGTH, 3, con_handle, tx_octets, tx_time)
/**********************************************************************************
@function ble5.0 广
@param [in] param 广
@param [in] param_len
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_ext_adv_param(u8 *param,u16 param_len) */
#define ble_op_set_ext_adv_param(param,param_len) \
ble_user_cmd_prepare(BLE_CMD_EXT_ADV_PARAM, 2, param, param_len)
/**********************************************************************************
@function ble5.0 adv
@param [in]data
@param [in]data_len
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_ext_adv_data(u8 *data,u16 data_len) */
#define ble_op_set_ext_adv_data(data,data_len) \
ble_user_cmd_prepare(BLE_CMD_EXT_ADV_DATA, 2, data, data_len)
/**********************************************************************************
@function ble5.0 respond
@param [in]data
@param [in]data_len
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_ext_rsp_data(u8 *data,u16 data_len) */
#define ble_op_set_ext_rsp_data(data,data_len) \
ble_user_cmd_prepare(BLE_CMD_EXT_RSP_DATA, 2, data, data_len)
/**********************************************************************************
@function ble5.0 广
@param [in] cmd
@param [in] cmd_len
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_ext_adv_enable(u8 *cmd,u16 cmd_le) */
#define ble_op_set_ext_adv_enable(cmd,len) \
ble_user_cmd_prepare(BLE_CMD_EXT_ADV_ENABLE, 2, cmd, cmd_len)
/**********************************************************************************
@function ble5.0 phy
@param [in]con_handle con_handle,range>0
@param [in]all_phys
@param [in]tx_phy
@param [in]rx_phy
@param [in]phy_options
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_ext_phy(u16 con_handle,u16 all_phys,u16 tx_phy,u16 rx_phy,u16 phy_options) */
#define ble_op_set_ext_phy(con_handle,all_phys,tx_phy,rx_phy,phy_options) \
ble_user_cmd_prepare(BLE_CMD_SET_PHY, 5, con_handle, all_phys, tx_phy, rx_phy, phy_options)
/**********************************************************************************
@function ble5.0 scan
@param [in]param
@param [in]param_len
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_ext_scan_param(u8 *param,u16 param_le) */
#define ble_op_set_ext_scan_param(param,param_len) \
ble_user_cmd_prepare(BLE_CMD_EXT_SCAN_PARAM, 2, param, param_len)
/**********************************************************************************
@function ble5.0 scan
@param [in] cmd
@param [in] cmd_len
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_ext_scan_enable(u8 *cmd,u16 cmd_le) */
#define ble_op_ext_scan_enable(cmd,cmd_len) \
ble_user_cmd_prepare(BLE_CMD_EXT_SCAN_ENABLE, 2, cmd, cmd_len)
/**********************************************************************************
@function ble5.0
@param [in]conn_param
@param [in]param_len
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_ext_create_conn(u8 *conn_param,u16 param_len_len) */
#define ble_op_ext_create_conn(conn_param,param_len) \
ble_user_cmd_prepare(BLE_CMD_EXT_CREATE_CONN, 2, conn_param, param_len)
/**********************************************************************************
@function latency !!!latency模式
@param [in] con_handle con_handle,range>0
@param [in] skip_interval interval的次数
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_latency_skip(u16 con_handle,u16 skip_interval) */
#define ble_op_latency_skip(con_handle,skip_interval) \
ble_user_cmd_prepare(BLE_CMD_LATENCY_HOLD_CNT, 2, con_handle, skip_interval)
/**********************************************************************************
@function
@param [in] con_handle con_handle,range>0
@param [in] key_num
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_test_key_num(u16 con_handle,u8 key_num) */
#define ble_op_test_key_num(con_handle,key_num) \
ble_user_cmd_prepare(BLE_CMD_SEND_TEST_KEY_NUM, 2, con_handle, key_num)
/**********************************************************************************
@function 退ble协议栈
@param [in] control : 0--退stack(default),1--退stack + controller
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_stack_exit(u8 control) */
#define ble_op_stack_exit(control) \
ble_user_cmd_prepare(BLE_CMD_STACK_EXIT, 1, control)
/**********************************************************************************
@function 线
@param [in] thread_callback
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_regist_thread_call(void (*thread_callback)(void)) */
#define ble_op_regist_thread_call(thread_callback) \
ble_user_cmd_prepare(BLE_CMD_REGIEST_THREAD, 1, thread_callback)
/**********************************************************************************
@function
@param [in]
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/**********************************************************************************
@function BLE搜索扫描!!!
@param [in] enable 0 or 1
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
note:filter_duplicate 1
*********************************************************************************/
/* ble_cmd_ret_e ble_op_scan_enable(u8 enable) */
#define ble_op_scan_enable(enable) \
ble_user_cmd_prepare(BLE_CMD_SCAN_ENABLE, 1, enable)
/**********************************************************************************
@function BLE搜索扫描!!!
@param [in] enable 0 or 1
@param [in] filter_duplicate 0 or 1
@param [in]
@param [in]
@return see ble_cmd_ret_e
note:filter_duplicate 1
*********************************************************************************/
/* ble_cmd_ret_e ble_op_scan_enable2(u8 enable,u8 filter_duplicate) */
#define ble_op_scan_enable2(enable,filter_duplicate) \
ble_user_cmd_prepare(BLE_CMD_SCAN_ENABLE2, 2, enable,filter_duplicate)
/**********************************************************************************
@function scan filter policy,default 0
@param [in] type Range: 0x00 to 0x03
@return see ble_cmd_ret_e
!!! ble_op_set_scan_param
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_scan_filter_policy(u8 type) */
#define ble_op_set_scan_filter_policy(type) \
ble_user_cmd_prepare(BLE_CMD_SET_HCI_CFG, 2,HCI_CFG_SCAN_FILTER_POLICY,type)
/**********************************************************************************
@function
@param [in] scan_type Range: 0x00 to 0x01 (unit: 0.625ms)
@param [in] scan_interval Range: 0x0004 to 0x4000 (unit: 0.625ms) >= scan_window
@param [in] scan_window Range: 0x0004 to 0x4000 (unit: 0.625ms), <= scan_interval
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_scan_param(u8 scan_type,u16 scan_interval,u16 scan_window) */
#define ble_op_set_scan_param(scan_type,scan_interval,scan_window) \
ble_user_cmd_prepare(BLE_CMD_SCAN_PARAM, 3, scan_type, scan_interval, scan_window)
/**********************************************************************************
@function creat filter policy,default 0
@param [in] type Range: 0x00 to 0x03
@return see ble_cmd_ret_e
!!! ble_op_create_connection
*********************************************************************************/
/* ble_cmd_ret_e ble_op_set_create_filter_policy(u8 type) */
#define ble_op_set_create_filter_policy(type) \
ble_user_cmd_prepare(BLE_CMD_SET_HCI_CFG, 2,HCI_CFG_INITIATOR_FILTER_POLICY,type)
/**********************************************************************************
@function BLE创建连接监听
@param [in] create_conn_param
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_create_connection(struct create_conn_param_t * create_conn_param) */
#define ble_op_create_connection(create_conn_param) \
ble_user_cmd_prepare(BLE_CMD_CREATE_CONN, 1, create_conn_param)
/**********************************************************************************
@function BLE连接监听
@param [in]
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_create_connection_cancel(void) */
#define ble_op_create_connection_cancel() \
ble_user_cmd_prepare(BLE_CMD_CREATE_CONN_CANCEL,0)
/**********************************************************************************
@function ble
@param [in]
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_search_profile_all(void) */
#define ble_op_search_profile_all() \
ble_user_cmd_prepare(BLE_CMD_SEARCH_PROFILE, 2, PFL_SERVER_ALL, 0)
/**********************************************************************************
@function ble UUID16服务
@param [in] uuid16 uuid
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_search_profile_uuid16(u16 uuid16) */
#define ble_op_search_profile_uuid16(uuid16) \
ble_user_cmd_prepare(BLE_CMD_SEARCH_PROFILE, 2, PFL_SERVER_UUID16, uuid16)
/**********************************************************************************
@function ble UUID128服务
@param [in] uuid16 uuid128
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_search_profile_uuid128(const u8 *uuid128_pt) */
#define ble_op_search_profile_uuid128(uuid128_pt) \
ble_user_cmd_prepare(BLE_CMD_SEARCH_PROFILE, 2, PFL_SERVER_UUID128, uuid128_pt)
/**********************************************************************************
@function ble
@param [in] con_handle con_handle,range>0
@param [in] con_param ()
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/* ble_cmd_ret_e ble_op_conn_param_update(u16 con_handle,struct conn_update_param_t *con_param) */
#define ble_op_conn_param_update(con_handle,con_param) \
ble_user_cmd_prepare(BLE_CMD_ONNN_PARAM_UPDATA, 2, con_handle, con_param)
/**********************************************************************************
@function
@param [in]
@param [in]
@param [in]
@param [in]
@return see ble_cmd_ret_e
*********************************************************************************/
/**********************************************************************************
@function ble (,使sdk默认值)
@param [in] pair_devices_count range: 0~10,10
0:使
@param [in] is_allow_cover 1 or 0,1
@param [in]
@param [in]
@return true or false
note: ,
note: VM
*********************************************************************************/
void ble_list_config_reset(u8 pair_devices_count, u8 is_allow_cover);
/**********************************************************************************
@function ,VM,(,使sdk默认值)
@param [in] enable 1 or 0,1
@param [in]
@param [in]
@param [in]
@return true or false
note:VM
note:
*********************************************************************************/
bool ble_list_pair_accept(u8 enable);
/**********************************************************************************
@function ,
@param [in] conn_addr 6bytes
@param [in] conn_addr_type range: 0~1
@param [in]
@param [in]
@return true or false
note:VM
*********************************************************************************/
bool ble_list_bonding_remote(u8 *conn_addr, u8 conn_addr_type);
/**********************************************************************************
@function ble
@param [in]
@param [in]
@return true or false
note:
*********************************************************************************/
bool ble_list_clear_all(void);
/**********************************************************************************
@function ble
@param [in] conn_addr 6bytes
@param [in] conn_addr_type range: 0~1
@param [in]
@param [in]
@return true or false
note:
*********************************************************************************/
bool ble_list_check_addr_is_exist(u8 *conn_addr, u8 conn_addr_type);
/**********************************************************************************
@function ble
@param [in] conn_addr 6bytes
@param [in] conn_addr_type range: 0~1
@param [in]
@param [in]
@return true or false
note:
*********************************************************************************/
bool ble_list_delete_device(u8 *conn_addr, u8 conn_addr_type);
/**********************************************************************************
@function ble id_address (public address)
@param [out] id_addr
@param [in]
@param [in]
@return true or false
note:
*********************************************************************************/
bool ble_list_get_last_id_addr(u8 *id_addr);
/**********************************************************************************
@function ble id_address (public address)
@param [in] conn_addr 6bytes
@param [in] conn_addr_type range: 0~1
@param [out] id_addr
@param [in]
@param [in]
@return true or false
note:
*********************************************************************************/
bool ble_list_get_id_addr(u8 *conn_addr, u8 conn_addr_type, u8 *id_addr);
/**********************************************************************************
@function ble
@param [in] conn_addr 6bytes
@param [in] conn_addr_type range: 0~1
@param [out] remote_type_e
@param [in]
@param [in]
@return true or false
note:
*********************************************************************************/
bool ble_list_get_remote_type(u8 *conn_addr, u8 conn_addr_type, u8 *output_type);
/**********************************************************************************
@function ble slave: att server MTU交换流程
@param [in] handle con_handle,range>0
@param [in]
@param [in]
@return
*********************************************************************************/
void att_server_set_exchange_mtu(u16 con_handle);
/**********************************************************************************
@function ble slave: att server 使
@param [in] handle con_handle,range>0
@param [in] enable: 1 or 0
@param [in]
@return
note:
*********************************************************************************/
void att_server_flow_enable(u8 enable);
/**********************************************************************************
@function ble slave: att server
@param [in] handle con_handle,range>0
@param [in] hold_flag:1--0--
@param [in]
@return
note: att_server_flow_enable 使,
*********************************************************************************/
void att_server_flow_hold(hci_con_handle_t con_handle, u8 hold_flag);
/**********************************************************************************
@function ble slave: server
@param [in] handle con_handle,range>0
@param [in] callback
@param [in]
@return
note: HCI_EVENT_ENCRYPTION_CHANGE
*********************************************************************************/
void att_server_set_check_remote(u16 con_handle, void (*callback)(u16 con_handle, remote_type_e remote_type));
/**********************************************************************************
@function att模块是否支持多机
@param [in] server_max
@param [in] client_max
@param [in]
@return 0--success ,0--fail
note:
*********************************************************************************/
int att_send_check_multi_dev(u8 server_max, u8 client_max);
/**********************************************************************************
@function GATT服务的profile
@param [in] profile_data
@param [in]
@param [in]
@return 0--success ,0--fail
note:
*********************************************************************************/
int att_server_change_profile(u8 const *profile_data);
#endif