1#ifndef __TKL_BLUETOOTH_DEF_H__
2#define __TKL_BLUETOOTH_DEF_H__
4#include "tuya_cloud_types.h"
5#include "tuya_error_code.h"
7#define TKL_BLE_ROLE_SERVER (0x01)
8#define TKL_BLE_ROLE_CLIENT (0x02)
10#define TKL_BLE_GAP_ADDR_TYPE_PUBLIC (0x00)
11#define TKL_BLE_GAP_ADDR_TYPE_RANDOM (0x01)
13#define TKL_BLE_SCAN_TYPE_ACTIVE (0x00)
14#define TKL_BLE_SCAN_TYPE_PASSIVE (0x01)
16#define TKL_BLE_GAP_ADV_SET_DATA_SIZE_MAX (31)
18#define TKL_BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED (255)
23#define TKL_BLE_GAP_ADV_TYPE_CONN_SCANNABLE_UNDIRECTED (0x01)
25#define TKL_BLE_GAP_ADV_TYPE_CONN_NONSCANNABLE_DIR_HIGHDUTY_CYCLE (0x02)
29#define TKL_BLE_GAP_ADV_TYPE_CONN_NONSCANNABLE_DIRECTED (0x03)
32#define TKL_BLE_GAP_ADV_TYPE_NONCONN_SCANNABLE_UNDIRECTED (0x04)
34#define TKL_BLE_GAP_ADV_TYPE_NONCONN_NONSCANNABLE_UNDIRECTED (0x05)
36#define TKL_BLE_GAP_ADV_TYPE_EXTENDED_CONN_NONSCANNABLE_UNDIRECTED (0x06)
38#define TKL_BLE_GAP_ADV_TYPE_EXTENDED_CONN_NONSCANNABLE_DIRECTED (0x07)
40#define TKL_BLE_GAP_ADV_TYPE_EXTENDED_NONCONN_SCANNABLE_UNDIRECTED (0x08)
43#define TKL_BLE_GAP_ADV_TYPE_EXTENDED_NONCONN_SCANNABLE_DIRECTED (0x09)
46#define TKL_BLE_GAP_ADV_TYPE_EXTENDED_NONCONN_NONSCANNABLE_UNDIRECTED (0x0A)
48#define TKL_BLE_GAP_ADV_TYPE_EXTENDED_NONCONN_NONSCANNABLE_DIRECTED (0x0B)
51#define TKL_BLE_GAP_PHY_AUTO (0x00)
52#define TKL_BLE_GAP_PHY_1MBPS (0x01)
53#define TKL_BLE_GAP_PHY_2MBPS (0x02)
54#define TKL_BLE_GAP_PHY_CODED (0x04)
56#define TKL_BLE_GAP_ADV_STATE_IDLE (0x00)
57#define TKL_BLE_GAP_ADV_STATE_START (0x01)
58#define TKL_BLE_GAP_ADV_STATE_ADVERTISING (0x02)
59#define TKL_BLE_GAP_ADV_STATE_STOP (0x04)
61#define TKL_BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION (0x13)
62#define TKL_BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_LOW_RESOURCES (0x14)
63#define TKL_BLE_HCI_REMOTE_DEV_TERMINATION_DUE_TO_POWER_OFF (0x15)
64#define TKL_BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION (0x16)
66#define TKL_BLE_GATT_SERVICE_MAX_NUM (6)
67#define TKL_BLE_GATT_CHAR_MAX_NUM (6)
69#define TKL_BLE_GATT_INVALID_HANDLE (0xFFFF)
86 TKL_BLE_NONCONN_ADV_DATA,
87 TKL_BLE_EXTENDED_ADV_DATA,
88} TKL_BLE_GAP_ADV_TYPE_E;
132 USHORT_T connection_timeout;
136 TKL_BLE_UUID_TYPE_16,
137 TKL_BLE_UUID_TYPE_32,
138 TKL_BLE_UUID_TYPE_128,
139} TKL_BLE_UUID_TYPE_E;
154 TKL_BLE_GATT_CHAR_PROP_BROADCAST = 0x01,
155 TKL_BLE_GATT_CHAR_PROP_READ = 0x02,
156 TKL_BLE_GATT_CHAR_PROP_WRITE_NO_RSP = 0x04,
157 TKL_BLE_GATT_CHAR_PROP_WRITE = 0x08,
158 TKL_BLE_GATT_CHAR_PROP_NOTIFY = 0x10,
159 TKL_BLE_GATT_CHAR_PROP_INDICATE = 0x20,
160 TKL_BLE_GATT_CHAR_PROP_WRITE_AUTHEN_SIGNED = 0x40,
161 TKL_BLE_GATT_CHAR_PROP_EXT_PROP = 0x80,
162}TKL_BLE_CHAR_PROP_TYPE_E;
166 TKL_BLE_GATT_PERM_NONE = 0x01,
167 TKL_BLE_GATT_PERM_READ = 0x02,
168 TKL_BLE_GATT_PERM_WRITE = 0x04,
169 TKL_BLE_GATT_PERM_READ_ENCRYPT = 0x08,
170 TKL_BLE_GATT_PERM_WRITE_ENCRYPT = 0x10,
171 TKL_BLE_GATT_PERM_READ_AUTHEN = 0x20,
172 TKL_BLE_GATT_PERM_WRITE_AUTHEN = 0x40,
173 TKL_BLE_GATT_PERM_PREPARE_WRITE = 0x80,
174} TKL_BLE_ATTR_PERM_E;
186 TKL_BLE_UUID_UNKNOWN = 0x0000,
187 TKL_BLE_UUID_SERVICE_PRIMARY = 0x2800,
188 TKL_BLE_UUID_SERVICE_SECONDARY = 0x2801,
189 TKL_BLE_UUID_SERVICE_INCLUDE = 0x2802,
190 TKL_BLE_UUID_CHARACTERISTIC = 0x2803,
191} TKL_BLE_SERVICE_TYPE_E;
209 TKL_BLE_EVT_STACK_INIT = 0x01,
211 TKL_BLE_EVT_STACK_DEINIT,
213 TKL_BLE_EVT_STACK_RESET,
215 TKL_BLE_GAP_EVT_CONNECT,
217 TKL_BLE_GAP_EVT_DISCONNECT,
219 TKL_BLE_GAP_EVT_ADV_STATE,
221 TKL_BLE_GAP_EVT_ADV_REPORT,
223 TKL_BLE_GAP_EVT_CONN_PARAM_REQ,
225 TKL_BLE_GAP_EVT_CONN_PARAM_UPDATE,
227 TKL_BLE_GAP_EVT_CONN_RSSI,
228} TKL_BLE_GAP_EVT_TYPE_E;
231 TKL_BLE_GATT_EVT_MTU_REQUEST = 0x01 ,
233 TKL_BLE_GATT_EVT_MTU_RSP,
235 TKL_BLE_GATT_EVT_PRIM_SEV_DISCOVERY,
237 TKL_BLE_GATT_EVT_CHAR_DISCOVERY,
239 TKL_BLE_GATT_EVT_CHAR_DESC_DISCOVERY,
241 TKL_BLE_GATT_EVT_NOTIFY_TX,
243 TKL_BLE_GATT_EVT_WRITE_REQ,
245 TKL_BLE_GATT_EVT_NOTIFY_INDICATE_RX,
247 TKL_BLE_GATT_EVT_READ_RX,
249 TKL_BLE_GATT_EVT_SUBSCRIBE,
251 TKL_BLE_GATT_EVT_READ_CHAR_VALUE,
253} TKL_BLE_GATT_EVT_TYPE_E;
320 UCHAR_T cur_notify : 1;
Definition: tkl_bluetooth_def.h:176
TKL_BLE_UUID_T char_uuid
Definition: tkl_bluetooth_def.h:179
UCHAR_T value_len
Definition: tkl_bluetooth_def.h:182
UCHAR_T permission
Definition: tkl_bluetooth_def.h:181
UCHAR_T property
Definition: tkl_bluetooth_def.h:180
USHORT_T handle
Definition: tkl_bluetooth_def.h:177
Definition: tkl_bluetooth_def.h:298
USHORT_T char_handle
Definition: tkl_bluetooth_def.h:299
TKL_BLE_DATA_T report
Definition: tkl_bluetooth_def.h:300
Definition: tkl_bluetooth_def.h:77
USHORT_T length
Definition: tkl_bluetooth_def.h:78
UCHAR_T * p_data
Definition: tkl_bluetooth_def.h:79
GAP address parameters.
Definition: tkl_bluetooth_def.h:72
UCHAR_T type
Definition: tkl_bluetooth_def.h:73
GAP advertising parameters.
Definition: tkl_bluetooth_def.h:91
USHORT_T adv_interval_max
Definition: tkl_bluetooth_def.h:96
UCHAR_T adv_type
Definition: tkl_bluetooth_def.h:92
UCHAR_T adv_channel_map
Definition: tkl_bluetooth_def.h:97
USHORT_T adv_interval_min
Definition: tkl_bluetooth_def.h:95
TKL_BLE_GAP_ADDR_T direct_addr
Definition: tkl_bluetooth_def.h:93
GAP adv report parameters.
Definition: tkl_bluetooth_def.h:102
UCHAR_T channel_index
Definition: tkl_bluetooth_def.h:106
CHAR_T rssi
Definition: tkl_bluetooth_def.h:105
TKL_BLE_DATA_T data
Definition: tkl_bluetooth_def.h:107
TKL_BLE_GAP_ADV_TYPE_E adv_type
Definition: tkl_bluetooth_def.h:103
TKL_BLE_GAP_ADDR_T peer_addr
Definition: tkl_bluetooth_def.h:104
Definition: tkl_bluetooth_def.h:255
UCHAR_T role
Definition: tkl_bluetooth_def.h:256
TKL_BLE_GAP_ADDR_T peer_addr
Definition: tkl_bluetooth_def.h:257
TKL_BLE_GAP_CONN_PARAMS_T conn_params
Definition: tkl_bluetooth_def.h:258
Definition of LE connection request parameter.
Definition: tkl_bluetooth_def.h:126
USHORT_T conn_interval_max
Definition: tkl_bluetooth_def.h:128
USHORT_T conn_latency
Definition: tkl_bluetooth_def.h:129
USHORT_T conn_interval_min
Definition: tkl_bluetooth_def.h:127
USHORT_T conn_sup_timeout
Definition: tkl_bluetooth_def.h:130
Definition: tkl_bluetooth_def.h:261
INT_T reason
Definition: tkl_bluetooth_def.h:263
UCHAR_T role
Definition: tkl_bluetooth_def.h:262
Definition: tkl_bluetooth_def.h:303
TKL_BLE_GAP_EVT_TYPE_E type
Definition: tkl_bluetooth_def.h:304
TKL_BLE_GAP_CONN_PARAMS_T conn_param
Definition: tkl_bluetooth_def.h:312
TKL_BLE_GAP_DISCONNECT_EVT_T disconnect
Definition: tkl_bluetooth_def.h:310
TKL_BLE_GAP_CONNECT_EVT_T connect
Definition: tkl_bluetooth_def.h:309
INT_T result
Definition: tkl_bluetooth_def.h:306
TKL_BLE_GAP_ADV_REPORT_T adv_report
Definition: tkl_bluetooth_def.h:311
USHORT_T conn_handle
Definition: tkl_bluetooth_def.h:305
CHAR_T link_rssi
Definition: tkl_bluetooth_def.h:313
GAP scanning parameters.
Definition: tkl_bluetooth_def.h:111
UCHAR_T extended
Definition: tkl_bluetooth_def.h:112
USHORT_T interval
Definition: tkl_bluetooth_def.h:119
USHORT_T timeout
Definition: tkl_bluetooth_def.h:121
UCHAR_T active
Definition: tkl_bluetooth_def.h:116
USHORT_T window
Definition: tkl_bluetooth_def.h:120
UCHAR_T scan_phys
Definition: tkl_bluetooth_def.h:118
UCHAR_T scan_channel_map
Definition: tkl_bluetooth_def.h:122
Definition: tkl_bluetooth_def.h:203
UCHAR_T svc_num
Definition: tkl_bluetooth_def.h:204
Definition: tkl_bluetooth_def.h:288
UCHAR_T char_num
Definition: tkl_bluetooth_def.h:289
Definition: tkl_bluetooth_def.h:283
USHORT_T handle
Definition: tkl_bluetooth_def.h:285
TKL_BLE_UUID_T uuid
Definition: tkl_bluetooth_def.h:284
Definition: tkl_bluetooth_def.h:294
USHORT_T cccd_handle
Definition: tkl_bluetooth_def.h:295
Definition: tkl_bluetooth_def.h:329
TKL_BLE_SUBSCRBE_EVT_T subscribe
Definition: tkl_bluetooth_def.h:343
TKL_BLE_DATA_REPORT_T data_report
Definition: tkl_bluetooth_def.h:341
USHORT_T conn_handle
Definition: tkl_bluetooth_def.h:331
TKL_BLE_GATT_EVT_TYPE_E type
Definition: tkl_bluetooth_def.h:330
INT_T result
Definition: tkl_bluetooth_def.h:332
TKL_BLE_DATA_REPORT_T write_report
Definition: tkl_bluetooth_def.h:340
TKL_BLE_NOTIFY_RESULT_EVT_T notify_result
Definition: tkl_bluetooth_def.h:339
USHORT_T exchange_mtu
Definition: tkl_bluetooth_def.h:335
TKL_BLE_GATT_DESC_DISC_TYPE_T desc_disc
Definition: tkl_bluetooth_def.h:338
TKL_BLE_GATT_SVC_DISC_TYPE_T svc_disc
Definition: tkl_bluetooth_def.h:336
TKL_BLE_GATT_CHAR_DISC_TYPE_T char_disc
Definition: tkl_bluetooth_def.h:337
TKL_BLE_READ_CHAR_EVT_T char_read
Definition: tkl_bluetooth_def.h:344
TKL_BLE_DATA_REPORT_T data_read
Definition: tkl_bluetooth_def.h:342
Definition: tkl_bluetooth_def.h:277
UCHAR_T svc_num
Definition: tkl_bluetooth_def.h:278
Definition: tkl_bluetooth_def.h:271
USHORT_T start_handle
Definition: tkl_bluetooth_def.h:273
TKL_BLE_UUID_T uuid
Definition: tkl_bluetooth_def.h:272
USHORT_T end_handle
Definition: tkl_bluetooth_def.h:274
Definition: tkl_bluetooth_def.h:266
USHORT_T char_handle
Definition: tkl_bluetooth_def.h:267
INT_T result
Definition: tkl_bluetooth_def.h:268
Definition: tkl_bluetooth_def.h:324
USHORT_T char_handle
Definition: tkl_bluetooth_def.h:325
Definition: tkl_bluetooth_def.h:193
TKL_BLE_CHAR_PARAMS_T * p_char
Definition: tkl_bluetooth_def.h:200
USHORT_T handle
Definition: tkl_bluetooth_def.h:194
TKL_BLE_SERVICE_TYPE_E type
Definition: tkl_bluetooth_def.h:197
UCHAR_T char_num
Definition: tkl_bluetooth_def.h:199
TKL_BLE_UUID_T svc_uuid
Definition: tkl_bluetooth_def.h:196
Definition: tkl_bluetooth_def.h:316
UCHAR_T cur_indicate
Definition: tkl_bluetooth_def.h:322
UCHAR_T prev_notify
Definition: tkl_bluetooth_def.h:319
UCHAR_T prev_indicate
Definition: tkl_bluetooth_def.h:321
USHORT_T char_handle
Definition: tkl_bluetooth_def.h:317
Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.
Definition: tkl_bluetooth_def.h:142
UINT_T uuid32
Definition: tkl_bluetooth_def.h:147
TKL_BLE_UUID_TYPE_E uuid_type
Definition: tkl_bluetooth_def.h:143
USHORT_T uuid16
Definition: tkl_bluetooth_def.h:146