TuyaOS
tuya_bt.h
浏览该文件的文档.
1
11#ifndef TUYA_BT_H__
12#define TUYA_BT_H__
13#include "tuya_cloud_types.h"
14#include "tuya_cloud_com_defs.h"
15#include "base_event_info.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21typedef BYTE_T TUYA_BLE_ABILITY_T;
22#define TUYA_BLE_ABILITY_NONE 0x0
23#define TUYA_BLE_ABILITY_NETCFG 0x1
24#define TUYA_BLE_ABILITY_DP_CTRL 0x2
25#define TUYA_BLE_ABILITY_ALL 0xFF
26
30typedef enum {
31 TUYA_BT_UNBONDING_UNCONN = 0,
32 TUYA_BT_UNBONDING_CONN,
33 TUYA_BT_BONDING_UNCONN,
34 TUYA_BT_BONDING_CONN,
35 TUYA_BT_UNKNOW_STATUS
37
41typedef enum {
42 TUYA_BLE_OP_UNBIND = 0,
43 TUYA_BLE_OP_BIND,
45
46
50typedef struct {
51 CHAR_T *uuid; //uuid
52 CHAR_T *auth_key;//authentication key
54
55//callback function for user dp query
56typedef VOID_T(*BT_DP_QUERY_CB)(VOID_T);
57typedef UINT_T(*BT_DP_GET_TM_CB)(CHAR_T* time_str);
58
59typedef struct {
60 UINT8_T priority_flag; //0:wifi first 1:bt first
61 UINT8_T share_flag; //0:no shared device 1:tuya shared device
62 UINT8_T dp_rept_with_time; //0:without time 1:with time
63 UINT8_T rsvd; //reserved param
64 BT_DP_QUERY_CB query_dp_cb; //callback function for dp query
65 BT_DP_GET_TM_CB get_timestamp_cb;
67
77OPERATE_RET ty_bt_init_env(IN CONST TY_BT_SDK_PARAM_S *p);
78
79OPERATE_RET ty_ble_init_env_for_mftest(VOID_T);
80
90OPERATE_RET tuya_set_bt_device_name(CHAR_T* dev_name);
91
102OPERATE_RET ty_bt_update_local_key(UINT8_T* p_buf, UINT8_T len);
103
113OPERATE_RET bt_netcfg_init(VOID_T);
114
124OPERATE_RET bt_netcfg_uninit(VOID_T);
125
136OPERATE_RET ty_bt_dp_report(IN CONST DP_REPT_TYPE_E dp_rept_type, IN CONST VOID_T* data);
137
148OPERATE_RET tuya_ble_monitor_init(VOID_T);
149
159BOOL_T is_bt_connected(VOID_T);
160
161//callback function for getting the connection status of bluetooth
162typedef VOID (*GET_BT_CONN_STAT_CB)(IN CONST TUYA_BT_CONN_STAT stat);
163
173OPERATE_RET tuya_ble_reg_get_bt_stat_cb(IN CONST GET_BT_CONN_STAT_CB bt_conn_stat_cb);
174
185
195OPERATE_RET tuya_set_bt_device_name(CHAR_T* dev_name);
196
207
208#if defined(BT_REMOTE_CTRL) && (BT_REMOTE_CTRL==1)
209
220VOID_T tuya_ble_init_beacon_key(VOID_T);
221
232OPERATE_RET tuya_ble_save_beacon_key(BOOL_T force);
233
244VOID_T tuya_ble_clear_beacon_key(VOID_T);
245
256VOID_T tuya_ble_clear_rmt_ctrl_info(UINT8_T stat);
257
258
259//callback function for advertisement scanning data processing
260typedef VOID (*TUYA_BLE_APP_SCAN_HANDLE)(UCHAR_T *data, UCHAR_T len, UCHAR_T type, UCHAR_T* mac);
261
271OPERATE_RET tuya_ble_reg_app_scan_adv_cb(TUYA_BLE_APP_SCAN_HANDLE cb);
272
273//callback function for validity check for bind or unbind operation
274typedef OPERATE_RET(*BLE_SCAN_ADV_BIND_CHECK_CB)(TUYA_BLE_BIND_TYPE type, UCHAR_T *data, UCHAR_T len);
275//callback function for result notify for bind or unbind operation
276typedef VOID_T(*BLE_SCAN_ADV_BIND_RSLT_NOTIFY_CB)(TUYA_BLE_BIND_TYPE type, int rslt);
277
278typedef struct {
279 BLE_SCAN_ADV_BIND_CHECK_CB bind_check;
280 BLE_SCAN_ADV_BIND_RSLT_NOTIFY_CB bind_notify;
281} TUYA_BLE_SCAN_ADV_HANDLE_CBS;
282
292OPERATE_RET tuya_ble_reg_app_scan_adv_handle_cbs(TUYA_BLE_SCAN_ADV_HANDLE_CBS* cbs);
293
303VOID_T tuya_ble_set_bind_window(UINT_T time_out);
304
314VOID_T tuya_ble_open_bind_window(VOID_T);
315#endif
316
326VOID_T tuya_ble_set_serv_switch(BOOL_T swith);
327
338
348VOID_T tuya_ble_restart_adv(VOID_T);
349
350
360VOID_T tuya_ble_connect_enable(BOOL_T enable);
361
371VOID_T tuya_ble_set_auto_close(BOOL_T auto_close);
372
382VOID_T tuya_ble_set_startup_attr(TUYA_BLE_ABILITY_T attr);
383
384
385#ifdef __cplusplus
386}
387#endif
388
389#endif
390
tuya simple event module
Definition: tuya_bt.h:59
parameters for bluetooth
Definition: tuya_bt.h:50
OPERATE_RET ty_bt_init_env(IN CONST TY_BT_SDK_PARAM_S *p)
Init the running environment for bluetooth.
VOID_T tuya_ble_set_auto_close(BOOL_T auto_close)
Close or open ble adv when mqtt disconnect or connected
BOOL_T is_bt_connected(VOID_T)
Check bluetooth is connected.
TUYA_BT_CONN_STAT
connection status for bluetooth
Definition: tuya_bt.h:30
VOID_T tuya_ble_restart_adv(VOID_T)
Resend the ble adv data to hal and start ble adv
OPERATE_RET tuya_ble_reg_get_bt_stat_cb(IN CONST GET_BT_CONN_STAT_CB bt_conn_stat_cb)
Register callback function for getting the connection status of bluetooth
VOID_T tuya_ble_set_startup_attr(TUYA_BLE_ABILITY_T attr)
Set abilitiy attribute of bluetooth
BOOL_T tuya_ble_is_serv_opened(VOID_T)
Check bluetooth service is available
TUYA_BT_CONN_STAT tuya_bt_get_connect_status(VOID)
Get connection status of bluetooth
OPERATE_RET tuya_set_bt_device_name(CHAR_T *dev_name)
Set name for bluetooth device.
VOID_T tuya_ble_set_serv_switch(BOOL_T swith)
Set enable switch for bluetooth service
OPERATE_RET bt_netcfg_init(VOID_T)
Init network configuration by bluetooth
VOID_T tuya_ble_connect_enable(BOOL_T enable)
Control the BLE fearture
OPERATE_RET ty_bt_dp_report(IN CONST DP_REPT_TYPE_E dp_rept_type, IN CONST VOID_T *data)
Report dp by bluetooth
VOID_T tuya_ble_set_bt_para(TUYA_BLE_BT_PARA *para)
Set parameters for bluetooth.
OPERATE_RET tuya_ble_monitor_init(VOID_T)
Monitor for bluetooth
OPERATE_RET ty_bt_update_local_key(UINT8_T *p_buf, UINT8_T len)
Update local key
OPERATE_RET bt_netcfg_uninit(VOID_T)
Uninit network configuration by bluetooth
TUYA_BLE_BIND_TYPE
bind type for bluetooth remote controller
Definition: tuya_bt.h:41