Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
gatt.h
Go to the documentation of this file.
1
12#ifndef INFUSE_SDK_INCLUDE_INFUSE_BLUETOOTH_GATT_H_
13#define INFUSE_SDK_INCLUDE_INFUSE_BLUETOOTH_GATT_H_
14
15#include <zephyr/bluetooth/conn.h>
16#include <zephyr/bluetooth/addr.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
34 /* Start handle for the characteristic */
36 /* End handle for the characteristic */
38 /* Handle for the value attribute */
39 uint16_t value_handle;
40 /* Handle for the Client Characteristic Configuration (0 if doesn't exist) */
41 uint16_t ccc_handle;
42 /* Characteristic properties (BT_GATT_CHRC_) */
43 uint8_t properties;
44};
45
50 /* Run when connection has been successfully setup or failed */
51 void (*conn_setup_cb)(struct bt_conn *conn, int err, void *user_data);
52 /* Run when connection has terminated, if @a conn_setup_cb has previously run */
53 void (*conn_terminated_cb)(struct bt_conn *conn, int reason, void *user_data);
54 /* User data provided to callbacks */
55 void *user_data;
56};
57
62 /* Cached GATT database hash value */
63 uint8_t db_hash[16];
64 /* Pointer to list of cached remote characteristics */
66 /* Access spinlock */
67 struct k_spinlock lock;
68};
69
76#define BT_CONN_AUTO_CACHE(name, num_characteristics) \
77 static struct bt_gatt_remote_char name##_storage[num_characteristics]; \
78 static struct bt_conn_auto_database_cache name = { \
79 .remote_info = name##_storage, \
80 }
81
86 /* List of UUIDs to discover */
87 const struct bt_uuid **characteristics;
88 /* Cached characteristics from previous connections */
90 /* Pointer to list of characteristics to discover */
92 /* Pending database hash */
93 uint8_t db_hash_pending[16];
94 /* Number of characteristics to discover */
96};
97
109void bt_conn_le_auto_setup(struct bt_conn *conn, struct bt_conn_auto_discovery *discovery,
110 const struct bt_conn_auto_setup_cb *callbacks, uint8_t preferred_phy);
111
120int bt_conn_disconnect_sync(struct bt_conn *conn);
121
131int bt_conn_disconnect_wait(struct bt_conn *conn, k_timeout_t timeout);
132
140int8_t bt_conn_rssi(struct bt_conn *conn);
141
151void bt_conn_rssi_log(struct bt_conn *conn, uint8_t tdf_loggers);
152
157#ifdef __cplusplus
158}
159#endif
160
161#endif /* INFUSE_SDK_INCLUDE_INFUSE_BLUETOOTH_GATT_H_ */
int8_t bt_conn_rssi(struct bt_conn *conn)
Get last measured RSSI on a connection.
void bt_conn_rssi_log(struct bt_conn *conn, uint8_t tdf_loggers)
Start logging the RSSI of the connection.
void bt_conn_le_auto_setup(struct bt_conn *conn, struct bt_conn_auto_discovery *discovery, const struct bt_conn_auto_setup_cb *callbacks, uint8_t preferred_phy)
Setup a connection with automatic MTU exchange and characteristic discovery.
int bt_conn_disconnect_sync(struct bt_conn *conn)
Trigger a disconnection and wait for it to complete.
int bt_conn_disconnect_wait(struct bt_conn *conn, k_timeout_t timeout)
Wait for a connection to disconnect, without initiating it.
Database cache to speed up repeat connections.
Definition gatt.h:61
struct bt_gatt_remote_char * remote_info
Definition gatt.h:65
uint8_t db_hash[16]
Definition gatt.h:63
struct k_spinlock lock
Definition gatt.h:67
Characteristics to discover on the connection.
Definition gatt.h:85
const struct bt_uuid ** characteristics
Definition gatt.h:87
struct bt_gatt_remote_char * remote_info
Definition gatt.h:91
struct bt_conn_auto_database_cache * cache
Definition gatt.h:89
uint8_t num_characteristics
Definition gatt.h:95
uint8_t db_hash_pending[16]
Definition gatt.h:93
Parameters for automatically setup connection.
Definition gatt.h:49
void(* conn_terminated_cb)(struct bt_conn *conn, int reason, void *user_data)
Definition gatt.h:53
void(* conn_setup_cb)(struct bt_conn *conn, int err, void *user_data)
Definition gatt.h:51
void * user_data
Definition gatt.h:55
Remote GATT Characteristic information.
Definition gatt.h:33
uint8_t properties
Definition gatt.h:43
uint16_t attr_start_handle
Definition gatt.h:35
uint16_t ccc_handle
Definition gatt.h:41
uint16_t value_handle
Definition gatt.h:39
uint16_t attr_end_handle
Definition gatt.h:37