ble_gatt_client
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
att.h
Go to the documentation of this file.
1 /*
2  *
3  * BlueZ - Bluetooth protocol stack for Linux
4  *
5  * Copyright (C) 2014 Google Inc.
6  *
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 #include <stdbool.h>
25 #include <stdint.h>
26 
27 #include "att-types.h"
28 
29 struct bt_att;
30 
31 struct bt_att *bt_att_new(int fd, bool ext_signed);
32 
33 struct bt_att *bt_att_ref(struct bt_att *att);
34 void bt_att_unref(struct bt_att *att);
35 
36 bool bt_att_set_close_on_unref(struct bt_att *att, bool do_close);
37 
38 int bt_att_get_fd(struct bt_att *att);
39 
40 typedef void (*bt_att_response_func_t)(uint8_t opcode, const void *pdu,
41  uint16_t length, void *user_data);
42 typedef void (*bt_att_notify_func_t)(uint8_t opcode, const void *pdu,
43  uint16_t length, void *user_data);
44 typedef void (*bt_att_destroy_func_t)(void *user_data);
45 typedef void (*bt_att_debug_func_t)(const char *str, void *user_data);
46 typedef void (*bt_att_timeout_func_t)(unsigned int id, uint8_t opcode,
47  void *user_data);
48 typedef void (*bt_att_disconnect_func_t)(int err, void *user_data);
49 typedef bool (*bt_att_counter_func_t)(uint32_t *sign_cnt, void *user_data);
50 
51 bool bt_att_set_debug(struct bt_att *att, bt_att_debug_func_t callback,
52  void *user_data, bt_att_destroy_func_t destroy);
53 
54 uint16_t bt_att_get_mtu(struct bt_att *att);
55 bool bt_att_set_mtu(struct bt_att *att, uint16_t mtu);
56 
57 bool bt_att_set_timeout_cb(struct bt_att *att, bt_att_timeout_func_t callback,
58  void *user_data,
59  bt_att_destroy_func_t destroy);
60 
61 unsigned int bt_att_send(struct bt_att *att, uint8_t opcode,
62  const void *pdu, uint16_t length,
63  bt_att_response_func_t callback,
64  void *user_data,
65  bt_att_destroy_func_t destroy);
66 bool bt_att_cancel(struct bt_att *att, unsigned int id);
67 bool bt_att_cancel_all(struct bt_att *att);
68 
69 unsigned int bt_att_send_error_rsp(struct bt_att *att, uint8_t opcode,
70  uint16_t handle, int error);
71 
72 unsigned int bt_att_register(struct bt_att *att, uint8_t opcode,
73  bt_att_notify_func_t callback,
74  void *user_data,
75  bt_att_destroy_func_t destroy);
76 bool bt_att_unregister(struct bt_att *att, unsigned int id);
77 
78 unsigned int bt_att_register_disconnect(struct bt_att *att,
79  bt_att_disconnect_func_t callback,
80  void *user_data,
81  bt_att_destroy_func_t destroy);
82 bool bt_att_unregister_disconnect(struct bt_att *att, unsigned int id);
83 
84 bool bt_att_unregister_all(struct bt_att *att);
85 
86 int bt_att_get_security(struct bt_att *att);
87 bool bt_att_set_security(struct bt_att *att, int level);
88 
89 bool bt_att_set_local_key(struct bt_att *att, uint8_t sign_key[16],
90  bt_att_counter_func_t func, void *user_data);
91 bool bt_att_set_remote_key(struct bt_att *att, uint8_t sign_key[16],
92  bt_att_counter_func_t func, void *user_data);
93 bool bt_att_has_crypto(struct bt_att *att);
void(* bt_att_destroy_func_t)(void *user_data)
Definition: att.h:44
void(* bt_att_disconnect_func_t)(int err, void *user_data)
Definition: att.h:48
int fd
socket
Definition: att.c:68
command_func_t func
void(* bt_att_debug_func_t)(const char *str, void *user_data)
Definition: att.h:45
unsigned int bt_att_register(struct bt_att *att, uint8_t opcode, bt_att_notify_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
Definition: att.c:1389
unsigned int bt_att_send_error_rsp(struct bt_att *att, uint8_t opcode, uint16_t handle, int error)
Definition: att.c:1368
bool bt_att_has_crypto(struct bt_att *att)
Definition: att.c:1524
int bt_att_get_fd(struct bt_att *att)
Definition: att.c:1087
bool bt_att_set_mtu(struct bt_att *att, uint16_t mtu)
Definition: att.c:1119
bool bt_att_set_security(struct bt_att *att, int level)
Definition: att.c:1467
uint16_t bt_att_get_mtu(struct bt_att *att)
Definition: att.c:1111
bool bt_att_cancel_all(struct bt_att *att)
Definition: att.c:1320
bool bt_att_set_timeout_cb(struct bt_att *att, bt_att_timeout_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
Definition: att.c:1141
uint16_t mtu
actual number of bytes for pdu ATT exchange
Definition: att.c:96
unsigned int bt_att_register_disconnect(struct bt_att *att, bt_att_disconnect_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
Definition: att.c:1158
bool bt_att_unregister_all(struct bt_att *att)
Definition: att.c:1437
bool bt_att_unregister_disconnect(struct bt_att *att, unsigned int id)
Definition: att.c:1189
bool ext_signed
true, requires key signature
Definition: att.c:116
struct bt_att * bt_att_ref(struct bt_att *att)
Definition: att.c:1055
bool(* bt_att_counter_func_t)(uint32_t *sign_cnt, void *user_data)
Definition: att.h:49
void(* bt_att_notify_func_t)(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
Definition: att.h:42
unsigned int bt_att_send(struct bt_att *att, uint8_t opcode, const void *pdu, uint16_t length, bt_att_response_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
Definition: att.c:1220
void bt_att_unref(struct bt_att *att)
Definition: att.c:1065
bool bt_att_cancel(struct bt_att *att, unsigned int id)
Definition: att.c:1278
Definition: att.c:64
bool bt_att_set_local_key(struct bt_att *att, uint8_t sign_key[16], bt_att_counter_func_t func, void *user_data)
Definition: att.c:1506
void(* bt_att_response_func_t)(uint8_t opcode, const void *pdu, uint16_t length, void *user_data)
Definition: att.h:40
bool bt_att_set_remote_key(struct bt_att *att, uint8_t sign_key[16], bt_att_counter_func_t func, void *user_data)
Definition: att.c:1515
bool bt_att_set_debug(struct bt_att *att, bt_att_debug_func_t callback, void *user_data, bt_att_destroy_func_t destroy)
Definition: att.c:1095
void(* bt_att_timeout_func_t)(unsigned int id, uint8_t opcode, void *user_data)
Definition: att.h:46
uint8_t opcode
Definition: att.c:140
bool bt_att_unregister(struct bt_att *att, unsigned int id)
Definition: att.c:1421
struct bt_att * bt_att_new(int fd, bool ext_signed)
Definition: att.c:991
bool bt_att_set_close_on_unref(struct bt_att *att, bool do_close)
Definition: att.c:1079
int bt_att_get_security(struct bt_att *att)
Definition: att.c:1448