ble_gatt_client
|
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <endian.h>
#include <byteswap.h>
#include <netinet/in.h>
Go to the source code of this file.
Data Structures | |
struct | bt_security |
struct | bt_power |
struct | bt_voice |
struct | __attribute__ |
struct | uint128_t |
Macros | |
#define | AF_BLUETOOTH 31 |
#define | PF_BLUETOOTH AF_BLUETOOTH |
#define | BTPROTO_L2CAP 0 |
#define | BTPROTO_HCI 1 |
#define | BTPROTO_SCO 2 |
#define | BTPROTO_RFCOMM 3 |
#define | BTPROTO_BNEP 4 |
#define | BTPROTO_CMTP 5 |
#define | BTPROTO_HIDP 6 |
#define | BTPROTO_AVDTP 7 |
#define | SOL_HCI 0 |
#define | SOL_L2CAP 6 |
#define | SOL_SCO 17 |
#define | SOL_RFCOMM 18 |
#define | SOL_BLUETOOTH 274 |
#define | BT_SECURITY 4 |
#define | BT_SECURITY_SDP 0 |
#define | BT_SECURITY_LOW 1 |
#define | BT_SECURITY_MEDIUM 2 |
#define | BT_SECURITY_HIGH 3 |
#define | BT_DEFER_SETUP 7 |
#define | BT_FLUSHABLE 8 |
#define | BT_FLUSHABLE_OFF 0 |
#define | BT_FLUSHABLE_ON 1 |
#define | BT_POWER 9 |
#define | BT_POWER_FORCE_ACTIVE_OFF 0 |
#define | BT_POWER_FORCE_ACTIVE_ON 1 |
#define | BT_CHANNEL_POLICY 10 |
#define | BT_CHANNEL_POLICY_BREDR_ONLY 0 |
#define | BT_CHANNEL_POLICY_BREDR_PREFERRED 1 |
#define | BT_CHANNEL_POLICY_AMP_PREFERRED 2 |
#define | BT_VOICE 11 |
#define | BT_SNDMTU 12 |
#define | BT_RCVMTU 13 |
#define | BT_VOICE_TRANSPARENT 0x0003 |
#define | BT_VOICE_CVSD_16BIT 0x0060 |
#define | htobs(d) (d) |
#define | htobl(d) (d) |
#define | htobll(d) (d) |
#define | btohs(d) (d) |
#define | btohl(d) (d) |
#define | btohll(d) (d) |
#define | bt_get_unaligned(ptr) |
#define | bt_put_unaligned(val, ptr) |
#define | BDADDR_BREDR 0x00 |
#define | BDADDR_LE_PUBLIC 0x01 |
#define | BDADDR_LE_RANDOM 0x02 |
#define | BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}}) |
#define | BDADDR_ALL (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}) |
#define | BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}) |
#define | ntoh64(x) (x) |
#define | hton64(x) ntoh64(x) |
#define | hton128(x, y) ntoh128(x, y) |
#define | htob128(x, y) btoh128(x, y) |
Enumerations | |
enum | { BT_CONNECTED = 1, BT_OPEN, BT_BOUND, BT_LISTEN, BT_CONNECT, BT_CONNECT2, BT_CONFIG, BT_DISCONN, BT_CLOSED } |
Functions | |
static uint64_t | bt_get_le64 (const void *ptr) |
static uint64_t | bt_get_be64 (const void *ptr) |
static uint32_t | bt_get_le32 (const void *ptr) |
static uint32_t | bt_get_be32 (const void *ptr) |
static uint16_t | bt_get_le16 (const void *ptr) |
static uint16_t | bt_get_be16 (const void *ptr) |
static void | bt_put_le64 (uint64_t val, const void *ptr) |
static void | bt_put_be64 (uint64_t val, const void *ptr) |
static void | bt_put_le32 (uint32_t val, const void *ptr) |
static void | bt_put_be32 (uint32_t val, const void *ptr) |
static void | bt_put_le16 (uint16_t val, const void *ptr) |
static void | bt_put_be16 (uint16_t val, const void *ptr) |
static int | bacmp (const bdaddr_t *ba1, const bdaddr_t *ba2) |
static void | bacpy (bdaddr_t *dst, const bdaddr_t *src) |
void | baswap (bdaddr_t *dst, const bdaddr_t *src) |
bdaddr_t * | strtoba (const char *str) |
char * | batostr (const bdaddr_t *ba) |
int | ba2str (const bdaddr_t *ba, char *str) |
int | str2ba (const char *str, bdaddr_t *ba) |
int | ba2oui (const bdaddr_t *ba, char *oui) |
int | bachk (const char *str) |
int | baprintf (const char *format,...) |
int | bafprintf (FILE *stream, const char *format,...) |
int | basprintf (char *str, const char *format,...) |
int | basnprintf (char *str, size_t size, const char *format,...) |
void * | bt_malloc (size_t size) |
void | bt_free (void *ptr) |
int | bt_error (uint16_t code) |
const char * | bt_compidtostr (int id) |
static void | bswap_128 (const void *src, void *dst) |
static void | ntoh128 (const uint128_t *src, uint128_t *dst) |
static void | btoh128 (const uint128_t *src, uint128_t *dst) |
#define AF_BLUETOOTH 31 |
Definition at line 41 of file bluetooth.h.
Referenced by hci_devinfo(), hci_for_each_dev(), hci_inquiry(), hci_open_dev(), is_io_l2cap_based(), and l2cap_le_att_connect().
#define BDADDR_ALL (&(bdaddr_t) {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}) |
Definition at line 310 of file bluetooth.h.
#define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}}) |
Definition at line 309 of file bluetooth.h.
Referenced by hci_get_route(), and main().
#define BDADDR_BREDR 0x00 |
Definition at line 305 of file bluetooth.h.
#define BDADDR_LE_PUBLIC 0x01 |
Definition at line 306 of file bluetooth.h.
Referenced by main().
#define BDADDR_LE_RANDOM 0x02 |
Definition at line 307 of file bluetooth.h.
Referenced by main().
#define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}) |
Definition at line 311 of file bluetooth.h.
#define BT_CHANNEL_POLICY 10 |
Definition at line 87 of file bluetooth.h.
#define BT_CHANNEL_POLICY_AMP_PREFERRED 2 |
Definition at line 112 of file bluetooth.h.
#define BT_CHANNEL_POLICY_BREDR_ONLY 0 |
Definition at line 94 of file bluetooth.h.
#define BT_CHANNEL_POLICY_BREDR_PREFERRED 1 |
Definition at line 101 of file bluetooth.h.
#define BT_DEFER_SETUP 7 |
Definition at line 73 of file bluetooth.h.
#define BT_FLUSHABLE 8 |
Definition at line 75 of file bluetooth.h.
#define BT_FLUSHABLE_OFF 0 |
Definition at line 77 of file bluetooth.h.
#define BT_FLUSHABLE_ON 1 |
Definition at line 78 of file bluetooth.h.
#define bt_get_unaligned | ( | ptr | ) |
Definition at line 158 of file bluetooth.h.
Referenced by bt_get_be16(), bt_get_be32(), bt_get_be64(), bt_get_le16(), bt_get_le32(), and bt_get_le64().
#define BT_POWER 9 |
Definition at line 80 of file bluetooth.h.
#define BT_POWER_FORCE_ACTIVE_OFF 0 |
Definition at line 84 of file bluetooth.h.
#define BT_POWER_FORCE_ACTIVE_ON 1 |
Definition at line 85 of file bluetooth.h.
#define bt_put_unaligned | ( | val, | |
ptr | |||
) |
Definition at line 166 of file bluetooth.h.
Referenced by bt_put_be16(), bt_put_be32(), bt_put_be64(), bt_put_le16(), bt_put_le32(), and bt_put_le64().
#define BT_RCVMTU 13 |
Definition at line 120 of file bluetooth.h.
#define BT_SECURITY 4 |
Definition at line 63 of file bluetooth.h.
Referenced by bt_att_get_security(), bt_att_set_security(), and l2cap_le_att_connect().
#define BT_SECURITY_HIGH 3 |
Definition at line 71 of file bluetooth.h.
Referenced by main().
#define BT_SECURITY_LOW 1 |
Definition at line 69 of file bluetooth.h.
Referenced by bt_att_new(), bt_gatt_client_write_without_response(), and main().
#define BT_SECURITY_MEDIUM 2 |
Definition at line 70 of file bluetooth.h.
Referenced by main().
#define BT_SECURITY_SDP 0 |
Definition at line 68 of file bluetooth.h.
#define BT_SNDMTU 12 |
Definition at line 119 of file bluetooth.h.
#define BT_VOICE 11 |
Definition at line 114 of file bluetooth.h.
#define BT_VOICE_CVSD_16BIT 0x0060 |
Definition at line 123 of file bluetooth.h.
#define BT_VOICE_TRANSPARENT 0x0003 |
Definition at line 122 of file bluetooth.h.
#define btohl | ( | d | ) | (d) |
Definition at line 144 of file bluetooth.h.
#define btohll | ( | d | ) | (d) |
Definition at line 145 of file bluetooth.h.
#define btohs | ( | d | ) | (d) |
Definition at line 143 of file bluetooth.h.
Referenced by hci_read_local_version(), and hci_read_remote_version().
#define BTPROTO_AVDTP 7 |
Definition at line 52 of file bluetooth.h.
#define BTPROTO_BNEP 4 |
Definition at line 49 of file bluetooth.h.
#define BTPROTO_CMTP 5 |
Definition at line 50 of file bluetooth.h.
#define BTPROTO_HCI 1 |
Definition at line 46 of file bluetooth.h.
Referenced by hci_devinfo(), hci_for_each_dev(), hci_inquiry(), and hci_open_dev().
#define BTPROTO_HIDP 6 |
Definition at line 51 of file bluetooth.h.
#define BTPROTO_L2CAP 0 |
Definition at line 45 of file bluetooth.h.
Referenced by is_io_l2cap_based(), and l2cap_le_att_connect().
#define BTPROTO_RFCOMM 3 |
Definition at line 48 of file bluetooth.h.
#define BTPROTO_SCO 2 |
Definition at line 47 of file bluetooth.h.
#define htob128 | ( | x, | |
y | |||
) | btoh128(x, y) |
Definition at line 397 of file bluetooth.h.
#define htobl | ( | d | ) | (d) |
Definition at line 141 of file bluetooth.h.
#define htobll | ( | d | ) | (d) |
Definition at line 142 of file bluetooth.h.
#define htobs | ( | d | ) | (d) |
Definition at line 140 of file bluetooth.h.
Referenced by hci_le_conn_update(), hci_send_cmd(), hci_send_req(), and l2cap_le_att_connect().
#define hton128 | ( | x, | |
y | |||
) | ntoh128(x, y) |
Definition at line 396 of file bluetooth.h.
#define hton64 | ( | x | ) | ntoh64(x) |
Definition at line 395 of file bluetooth.h.
#define ntoh64 | ( | x | ) | (x) |
Definition at line 358 of file bluetooth.h.
#define PF_BLUETOOTH AF_BLUETOOTH |
Definition at line 42 of file bluetooth.h.
Referenced by l2cap_le_att_connect().
#define SOL_BLUETOOTH 274 |
Definition at line 60 of file bluetooth.h.
Referenced by bt_att_get_security(), bt_att_set_security(), and l2cap_le_att_connect().
#define SOL_HCI 0 |
Definition at line 54 of file bluetooth.h.
Referenced by hci_send_req().
#define SOL_L2CAP 6 |
Definition at line 55 of file bluetooth.h.
#define SOL_RFCOMM 18 |
Definition at line 57 of file bluetooth.h.
#define SOL_SCO 17 |
Definition at line 56 of file bluetooth.h.
anonymous enum |
Enumerator | |
---|---|
BT_CONNECTED | |
BT_OPEN | |
BT_BOUND | |
BT_LISTEN | |
BT_CONNECT | |
BT_CONNECT2 | |
BT_CONFIG | |
BT_DISCONN | |
BT_CLOSED |
Definition at line 126 of file bluetooth.h.
int ba2oui | ( | const bdaddr_t * | ba, |
char * | oui | ||
) |
Definition at line 107 of file bluetooth.c.
int ba2str | ( | const bdaddr_t * | ba, |
char * | str | ||
) |
Definition at line 86 of file bluetooth.c.
Referenced by l2cap_le_att_connect().
int bachk | ( | const char * | str | ) |
Definition at line 112 of file bluetooth.c.
Referenced by str2ba().
|
inlinestatic |
Definition at line 314 of file bluetooth.h.
Referenced by __other_bdaddr(), __same_bdaddr(), and hci_send_req().
|
inlinestatic |
Definition at line 318 of file bluetooth.h.
Referenced by hci_create_connection(), hci_delete_stored_link_key(), hci_devba(), hci_le_add_resolving_list(), hci_le_add_white_list(), hci_le_rm_resolving_list(), hci_le_rm_white_list(), hci_read_bd_addr(), hci_read_remote_name_cancel(), hci_read_remote_name_with_clock_offset(), hci_read_stored_link_key(), hci_switch_role(), hci_write_stored_link_key(), l2cap_le_att_connect(), and main().
int bafprintf | ( | FILE * | stream, |
const char * | format, | ||
... | |||
) |
Definition at line 149 of file bluetooth.c.
int baprintf | ( | const char * | format, |
... | |||
) |
Definition at line 137 of file bluetooth.c.
int basnprintf | ( | char * | str, |
size_t | size, | ||
const char * | format, | ||
... | |||
) |
Definition at line 173 of file bluetooth.c.
int basprintf | ( | char * | str, |
const char * | format, | ||
... | |||
) |
Definition at line 161 of file bluetooth.c.
void baswap | ( | bdaddr_t * | dst, |
const bdaddr_t * | src | ||
) |
Definition at line 50 of file bluetooth.c.
Referenced by strtoba().
char* batostr | ( | const bdaddr_t * | ba | ) |
Definition at line 60 of file bluetooth.c.
References bt_malloc().
|
inlinestatic |
Definition at line 346 of file bluetooth.h.
Referenced by bt_uuid_to_le(), btoh128(), convert_uuid_le(), gatt_db_attribute_get_service_uuid(), le_to_uuid(), and uuid_to_le().
const char* bt_compidtostr | ( | int | id | ) |
Definition at line 270 of file bluetooth.c.
int bt_error | ( | uint16_t | code | ) |
Definition at line 196 of file bluetooth.c.
References HCI_ACL_CONNECTION_EXISTS, HCI_AUTHENTICATION_FAILURE, HCI_CLASSIFICATION_NOT_SUPPORTED, HCI_COMMAND_DISALLOWED, HCI_CONNECTION_TERMINATED, HCI_CONNECTION_TIMEOUT, HCI_ENCRYPTION_MODE_NOT_ACCEPTED, HCI_HARDWARE_FAILURE, HCI_HOST_TIMEOUT, HCI_INSUFFICIENT_SECURITY, HCI_INVALID_LMP_PARAMETERS, HCI_INVALID_PARAMETERS, HCI_LMP_ERROR_TRANSACTION_COLLISION, HCI_LMP_PDU_NOT_ALLOWED, HCI_MAX_NUMBER_OF_CONNECTIONS, HCI_MAX_NUMBER_OF_SCO_CONNECTIONS, HCI_MEMORY_FULL, HCI_NO_CONNECTION, HCI_OE_LOW_RESOURCES, HCI_OE_POWER_OFF, HCI_OE_USER_ENDED_CONNECTION, HCI_PAGE_TIMEOUT, HCI_PAIRING_NOT_ALLOWED, HCI_PAIRING_NOT_SUPPORTED, HCI_PARAMETER_OUT_OF_RANGE, HCI_PIN_OR_KEY_MISSING, HCI_QOS_NOT_SUPPORTED, HCI_QOS_REJECTED, HCI_QOS_UNACCEPTABLE_PARAMETER, HCI_REJECTED_LIMITED_RESOURCES, HCI_REJECTED_PERSONAL, HCI_REJECTED_SECURITY, HCI_REPEATED_ATTEMPTS, HCI_ROLE_SWITCH_PENDING, HCI_SCO_OFFSET_REJECTED, HCI_SLOT_VIOLATION, HCI_TRANSACTION_COLLISION, HCI_UNKNOWN_COMMAND, HCI_UNKNOWN_LMP_PDU, HCI_UNSUPPORTED_FEATURE, HCI_UNSUPPORTED_LMP_PARAMETER_VALUE, and HCI_UNSUPPORTED_REMOTE_FEATURE.
void bt_free | ( | void * | ptr | ) |
Definition at line 190 of file bluetooth.c.
Referenced by hci_lmtostr().
|
inlinestatic |
Definition at line 200 of file bluetooth.h.
References bt_get_unaligned.
|
inlinestatic |
Definition at line 190 of file bluetooth.h.
References bt_get_unaligned.
|
inlinestatic |
Definition at line 180 of file bluetooth.h.
References bt_get_unaligned.
|
inlinestatic |
Definition at line 195 of file bluetooth.h.
References bt_get_unaligned.
|
inlinestatic |
Definition at line 185 of file bluetooth.h.
References bt_get_unaligned.
|
inlinestatic |
Definition at line 175 of file bluetooth.h.
References bt_get_unaligned.
void* bt_malloc | ( | size_t | size | ) |
Definition at line 185 of file bluetooth.c.
Referenced by batostr(), hci_commandstostr(), hci_dflagstostr(), hci_lmtostr(), lmp_featurestostr(), and strtoba().
|
inlinestatic |
Definition at line 230 of file bluetooth.h.
References bt_put_unaligned.
|
inlinestatic |
Definition at line 220 of file bluetooth.h.
References bt_put_unaligned.
|
inlinestatic |
Definition at line 210 of file bluetooth.h.
References bt_put_unaligned.
|
inlinestatic |
Definition at line 225 of file bluetooth.h.
References bt_put_unaligned.
Referenced by bt_uuid_to_le().
|
inlinestatic |
Definition at line 215 of file bluetooth.h.
References bt_put_unaligned.
|
inlinestatic |
Definition at line 205 of file bluetooth.h.
References bt_put_unaligned.
Definition at line 365 of file bluetooth.h.
References bswap_128().
Definition at line 360 of file bluetooth.h.
int str2ba | ( | const char * | str, |
bdaddr_t * | ba | ||
) |
Definition at line 92 of file bluetooth.c.
References bachk().
Referenced by hci_devid(), main(), and strtoba().
bdaddr_t* strtoba | ( | const char * | str | ) |
Definition at line 73 of file bluetooth.c.
References baswap(), bt_malloc(), and str2ba().