TuyaOS
tuya_bt.h
浏览该文件的文档.
1
11#ifndef TUYA_BT_H__
12#define TUYA_BT_H__
13
14#include "tuya_cloud_types.h"
15#include "tuya_cloud_com_defs.h"
16#include "base_event_info.h"
17#include "tal_bluetooth_def.h"
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23typedef BYTE_T TUYA_BLE_ABILITY_T;
24#define TUYA_BLE_ABILITY_NONE 0x0
25#define TUYA_BLE_ABILITY_NETCFG 0x1
26#define TUYA_BLE_ABILITY_DP_CTRL 0x2
27#define TUYA_BLE_ABILITY_ALL 0xFF
28
32typedef enum {
33 TUYA_BT_UNBONDING_UNCONN = 0,
34 TUYA_BT_UNBONDING_CONN,
35 TUYA_BT_BONDING_UNCONN,
36 TUYA_BT_BONDING_CONN,
37 TUYA_BT_UNKNOW_STATUS
39
43typedef enum {
44 TUYA_BT_SERV_OPENED = 0,
45 TUYA_BT_SERV_OPENING,
46 TUYA_BT_SERV_CLOSED,
47 TUYA_BT_SERV_CLOSING
49
53typedef enum {
54 TUYA_BLE_OP_UNBIND = 0,
55 TUYA_BLE_OP_BIND,
57
58
62typedef struct {
63 CHAR_T *uuid; //uuid
64 CHAR_T *auth_key;//authentication key
66
67//callback function for user dp query
68typedef VOID_T(*BT_DP_QUERY_CB)(VOID_T);
69typedef UINT_T(*BT_DP_GET_TM_CB)(CHAR_T* time_str);
70
71typedef struct {
72 UINT8_T priority_flag; //0:wifi first 1:bt first
73 UINT8_T share_flag; //0:no shared device 1:tuya shared device
74 UINT8_T dp_rept_with_time; //0:without time 1:with time
75 UINT8_T rsvd; //reserved param
76 BT_DP_QUERY_CB query_dp_cb; //callback function for dp query
77 BT_DP_GET_TM_CB get_timestamp_cb;
79
80#if defined(ENABLE_BT_MF) && (ENABLE_BT_MF == 1)
81OPERATE_RET ty_ble_init_for_mftest(VOID_T);
82OPERATE_RET ty_ble_deinit_for_mftest(VOID_T);
83#endif
84
94OPERATE_RET tuya_set_bt_device_name(CHAR_T* dev_name);
95
106OPERATE_RET ty_bt_update_local_key(UINT8_T* p_buf, UINT8_T len);
107
118
130OPERATE_RET ty_bt_dp_report(IN CONST DP_REPT_TYPE_E dp_rept_type, IN CONST VOID_T* data, IN BOOL_T sync);
131
142OPERATE_RET tuya_ble_monitor_init(VOID_T);
143
153BOOL_T is_bt_connected(VOID_T);
154
155//callback function for getting the connection status of bluetooth
156typedef VOID (*GET_BT_CONN_STAT_CB)(IN CONST TUYA_BT_CONN_STAT stat);
157
167OPERATE_RET tuya_ble_reg_get_bt_stat_cb(IN CONST GET_BT_CONN_STAT_CB bt_conn_stat_cb);
168
179
189OPERATE_RET tuya_set_bt_device_name(CHAR_T* dev_name);
190
201
202#if defined(ENABLE_BT_REMOTE_CTRL) && (ENABLE_BT_REMOTE_CTRL==1)
203
214VOID_T tuya_ble_init_beacon_key(VOID_T);
215
226OPERATE_RET tuya_ble_save_beacon_key(BOOL_T force);
227
238VOID_T tuya_ble_clear_beacon_key(VOID_T);
239
250VOID_T tuya_ble_clear_rmt_ctrl_info(UINT8_T stat);
251
252
253//callback function for advertisement scanning data processing
254typedef VOID (*TUYA_BLE_APP_SCAN_HANDLE)(UCHAR_T *data, UCHAR_T len, UCHAR_T type, UCHAR_T* mac);
255
265OPERATE_RET tuya_ble_reg_app_scan_adv_cb(TUYA_BLE_APP_SCAN_HANDLE cb);
266
276BOOL_T tuya_ble_is_user_registed(VOID_T);
277
278//callback function for advertisement scanning raw data processing
279typedef VOID (*TUYA_BLE_RAW_SCAN_HANDLE)(TAL_BLE_ADV_REPORT_T *scan_info);
280
290OPERATE_RET tuya_ble_reg_raw_scan_adv_cb(TUYA_BLE_RAW_SCAN_HANDLE cb);
291
292
293//callback function for validity check for bind or unbind operation
294typedef OPERATE_RET(*BLE_SCAN_ADV_BIND_CHECK_CB)(TUYA_BLE_BIND_TYPE type, UCHAR_T *data, UCHAR_T len);
295//callback function for result notify for bind or unbind operation
296typedef VOID_T(*BLE_SCAN_ADV_BIND_RSLT_NOTIFY_CB)(TUYA_BLE_BIND_TYPE type, int rslt);
297
298typedef struct {
299 BLE_SCAN_ADV_BIND_CHECK_CB bind_check;
300 BLE_SCAN_ADV_BIND_RSLT_NOTIFY_CB bind_notify;
301} TUYA_BLE_SCAN_ADV_HANDLE_CBS;
302
312OPERATE_RET tuya_ble_reg_app_scan_adv_handle_cbs(TUYA_BLE_SCAN_ADV_HANDLE_CBS* cbs);
313
323VOID_T tuya_ble_set_bind_window(UINT_T time_out);
324
334VOID_T tuya_ble_open_bind_window(VOID_T);
335
345VOID_T tuya_ble_disable_clr_bind_info(VOID_T);
346#endif
347
359OPERATE_RET tuya_ble_start_user_beacon_adv(UCHAR_T *data, UCHAR_T len, UINT_T sec_time);
360
370VOID_T tuya_ble_set_serv_switch(BOOL_T swith);
371
382
392VOID_T tuya_ble_restart_adv(VOID_T);
393
404
414VOID_T tuya_ble_set_startup_attr(TUYA_BLE_ABILITY_T attr);
415
426
436VOID_T tuya_ble_rept_netcfg_stat(IN UINT_T type);
437
448VOID_T tuya_ble_dp_response_query(IN CONST BYTE_T *dpid, IN CONST BYTE_T num);
449
459OPERATE_RET tuya_svc_bt_init(VOID_T);
460
461VOID_T tuya_enable_ble_dp_ctrl(BOOL_T swith);
462VOID_T tuya_enable_ble_timer(BOOL_T swith);
463VOID_T tuya_enable_ble_netcfg(BOOL_T swith);
464VOID_T tuya_enable_ble_active(BOOL_T swith);
465VOID_T tuya_enable_ble_mftst(BOOL_T swith);
466BOOL_T tuya_ble_is_mftst_enable(VOID_T);
467
468
469#ifdef __cplusplus
470}
471#endif
472
473#endif
474
tuya simple event module
Definition: tal_bluetooth_def.h:104
Definition: tuya_bt.h:71
parameters for bluetooth
Definition: tuya_bt.h:62
BOOL_T is_bt_connected(VOID_T)
Check bluetooth is connected.
TUYA_BT_CONN_STAT
connection status for bluetooth
Definition: tuya_bt.h:32
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_lowpower_handle(VOID_T)
stop ble netcfg and plug_play when dev under lowpower status
TUYA_BT_SERV_STAT
status for bluetooth service
Definition: tuya_bt.h:43
VOID_T tuya_ble_rept_netcfg_stat(IN UINT_T type)
Report netcfg status
VOID_T tuya_ble_dp_response_query(IN CONST BYTE_T *dpid, IN CONST BYTE_T num)
Response dp query with report flag
VOID_T tuya_ble_disable_expt_unbind(VOID_T)
Disable function for execept unbinding
VOID_T tuya_ble_set_startup_attr(TUYA_BLE_ABILITY_T attr)
Set abilitiy attribute of bluetooth
TUYA_BT_CONN_STAT tuya_bt_get_connect_status(VOID)
Get connection status of bluetooth
OPERATE_RET tuya_ble_start_user_beacon_adv(UCHAR_T *data, UCHAR_T len, UINT_T sec_time)
Start user defined advertising of bluetooth with time limited
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 ty_bt_dp_report(IN CONST DP_REPT_TYPE_E dp_rept_type, IN CONST VOID_T *data, IN BOOL_T sync)
Report dp by bluetooth
OPERATE_RET tuya_svc_bt_init(VOID_T)
Init tuya bluetooth service
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
TUYA_BLE_BIND_TYPE
bind type for bluetooth remote controller
Definition: tuya_bt.h:53
VOID_T ty_bt_support_dp_sync_report(BOOL_T flag)
Support dp sync report by bluetooth
TUYA_BT_SERV_STAT tuya_ble_get_serv_stat(VOID_T)
Get status of bluetooth service