ble_gatt_client
|
manage the services / characteristics data model More...
#include <stdbool.h>
#include <errno.h>
#include "bluetooth.h"
#include "uuid.h"
#include "util.h"
#include "queue.h"
#include "timeout.h"
#include "att.h"
#include "gatt-db.h"
Go to the source code of this file.
Data Structures | |
struct | gatt_db |
struct | notify |
struct | pending_read |
struct | pending_write |
struct | gatt_db_attribute |
struct | gatt_db_service |
struct | notify_data |
struct | clear_range |
struct | find_by_type_value_data |
struct | read_by_type_data |
struct | find_information_data |
struct | foreach_data |
Macros | |
#define | MAX(a, b) ((a) > (b) ? (a) : (b)) |
#define | MAX_CHAR_DECL_VALUE_LEN 19 |
#define | MAX_INCLUDED_VALUE_LEN 6 |
#define | ATTRIBUTE_TIMEOUT 5000 |
Functions | |
static void | pending_read_result (struct pending_read *p, int err, const uint8_t *data, size_t length) |
static void | pending_read_free (void *data) |
static void | pending_write_result (struct pending_write *p, int err) |
static void | pending_write_free (void *data) |
static void | attribute_destroy (struct gatt_db_attribute *attribute) |
static struct gatt_db_attribute * | new_attribute (struct gatt_db_service *service, uint16_t handle, const bt_uuid_t *type, const uint8_t *val, uint16_t len) |
struct gatt_db * | gatt_db_ref (struct gatt_db *db) |
struct gatt_db * | gatt_db_new (void) |
static void | notify_destroy (void *data) |
static bool | match_notify_id (const void *a, const void *b) |
static void | handle_notify (void *data, void *user_data) |
static void | notify_service_changed (struct gatt_db *db, struct gatt_db_service *service, bool added) |
static void | gatt_db_service_destroy (void *data) |
static void | gatt_db_destroy (struct gatt_db *db) |
void | gatt_db_unref (struct gatt_db *db) |
bool | gatt_db_isempty (struct gatt_db *db) |
static int | uuid_to_le (const bt_uuid_t *uuid, uint8_t *dst) |
static bool | le_to_uuid (const uint8_t *src, size_t len, bt_uuid_t *uuid) |
static struct gatt_db_service * | gatt_db_service_create (const bt_uuid_t *uuid, uint16_t handle, bool primary, uint16_t num_handles) |
bool | gatt_db_remove_service (struct gatt_db *db, struct gatt_db_attribute *attrib) |
bool | gatt_db_clear (struct gatt_db *db) |
static void | gatt_db_service_get_handles (const struct gatt_db_service *service, uint16_t *start_handle, uint16_t *end_handle) |
static bool | match_range (const void *a, const void *b) |
bool | gatt_db_clear_range (struct gatt_db *db, uint16_t start_handle, uint16_t end_handle) |
static struct gatt_db_service * | find_insert_loc (struct gatt_db *db, uint16_t start, uint16_t end, struct gatt_db_service **after) |
struct gatt_db_attribute * | gatt_db_insert_service (struct gatt_db *db, uint16_t handle, const bt_uuid_t *uuid, bool primary, uint16_t num_handles) |
struct gatt_db_attribute * | gatt_db_add_service (struct gatt_db *db, const bt_uuid_t *uuid, bool primary, uint16_t num_handles) |
unsigned int | gatt_db_register (struct gatt_db *db, gatt_db_attribute_cb_t service_added, gatt_db_attribute_cb_t service_removed, void *user_data, gatt_db_destroy_func_t destroy) |
bool | gatt_db_unregister (struct gatt_db *db, unsigned int id) |
static uint16_t | get_attribute_index (struct gatt_db_service *service, int end_offset) |
static uint16_t | get_handle_at_index (struct gatt_db_service *service, int index) |
static struct gatt_db_attribute * | attribute_update (struct gatt_db_service *service, int index) |
static void | set_attribute_data (struct gatt_db_attribute *attribute, gatt_db_read_t read_func, gatt_db_write_t write_func, uint32_t permissions, void *user_data) |
static struct gatt_db_attribute * | service_insert_characteristic (struct gatt_db_service *service, uint16_t handle, const bt_uuid_t *uuid, uint32_t permissions, uint8_t properties, gatt_db_read_t read_func, gatt_db_write_t write_func, void *user_data) |
struct gatt_db_attribute * | gatt_db_service_insert_characteristic (struct gatt_db_attribute *attrib, uint16_t handle, const bt_uuid_t *uuid, uint32_t permissions, uint8_t properties, gatt_db_read_t read_func, gatt_db_write_t write_func, void *user_data) |
struct gatt_db_attribute * | gatt_db_service_add_characteristic (struct gatt_db_attribute *attrib, const bt_uuid_t *uuid, uint32_t permissions, uint8_t properties, gatt_db_read_t read_func, gatt_db_write_t write_func, void *user_data) |
static struct gatt_db_attribute * | service_insert_descriptor (struct gatt_db_service *service, uint16_t handle, const bt_uuid_t *uuid, uint32_t permissions, gatt_db_read_t read_func, gatt_db_write_t write_func, void *user_data) |
struct gatt_db_attribute * | gatt_db_service_insert_descriptor (struct gatt_db_attribute *attrib, uint16_t handle, const bt_uuid_t *uuid, uint32_t permissions, gatt_db_read_t read_func, gatt_db_write_t write_func, void *user_data) |
struct gatt_db_attribute * | gatt_db_service_add_descriptor (struct gatt_db_attribute *attrib, const bt_uuid_t *uuid, uint32_t permissions, gatt_db_read_t read_func, gatt_db_write_t write_func, void *user_data) |
struct gatt_db_attribute * | gatt_db_service_add_included (struct gatt_db_attribute *attrib, struct gatt_db_attribute *include) |
bool | gatt_db_service_set_active (struct gatt_db_attribute *attrib, bool active) |
bool | gatt_db_service_get_active (struct gatt_db_attribute *attrib) |
bool | gatt_db_service_set_claimed (struct gatt_db_attribute *attrib, bool claimed) |
bool | gatt_db_service_get_claimed (struct gatt_db_attribute *attrib) |
void | gatt_db_read_by_group_type (struct gatt_db *db, uint16_t start_handle, uint16_t end_handle, const bt_uuid_t type, struct queue *queue) |
static void | find_by_type (void *data, void *user_data) |
unsigned int | gatt_db_find_by_type (struct gatt_db *db, uint16_t start_handle, uint16_t end_handle, const bt_uuid_t *type, gatt_db_attribute_cb_t func, void *user_data) |
unsigned int | gatt_db_find_by_type_value (struct gatt_db *db, uint16_t start_handle, uint16_t end_handle, const bt_uuid_t *type, const void *value, size_t value_len, gatt_db_attribute_cb_t func, void *user_data) |
static void | read_by_type (void *data, void *user_data) |
void | gatt_db_read_by_type (struct gatt_db *db, uint16_t start_handle, uint16_t end_handle, const bt_uuid_t type, struct queue *queue) |
static void | find_information (void *data, void *user_data) |
void | gatt_db_find_information (struct gatt_db *db, uint16_t start_handle, uint16_t end_handle, struct queue *queue) |
void | gatt_db_foreach_service (struct gatt_db *db, const bt_uuid_t *uuid, gatt_db_attribute_cb_t func, void *user_data) |
static void | foreach_service_in_range (void *data, void *user_data) |
void | gatt_db_foreach_service_in_range (struct gatt_db *db, const bt_uuid_t *uuid, gatt_db_attribute_cb_t func, void *user_data, uint16_t start_handle, uint16_t end_handle) |
void | gatt_db_service_foreach (struct gatt_db_attribute *attrib, const bt_uuid_t *uuid, gatt_db_attribute_cb_t func, void *user_data) |
void | gatt_db_service_foreach_char (struct gatt_db_attribute *attrib, gatt_db_attribute_cb_t func, void *user_data) |
void | gatt_db_service_foreach_desc (struct gatt_db_attribute *attrib, gatt_db_attribute_cb_t func, void *user_data) |
void | gatt_db_service_foreach_incl (struct gatt_db_attribute *attrib, gatt_db_attribute_cb_t func, void *user_data) |
static bool | find_service_for_handle (const void *data, const void *user_data) |
struct gatt_db_attribute * | gatt_db_get_attribute (struct gatt_db *db, uint16_t handle) |
static bool | find_service_with_uuid (const void *data, const void *user_data) |
struct gatt_db_attribute * | gatt_db_get_service_with_uuid (struct gatt_db *db, const bt_uuid_t *uuid) |
const bt_uuid_t * | gatt_db_attribute_get_type (const struct gatt_db_attribute *attrib) |
uint16_t | gatt_db_attribute_get_handle (const struct gatt_db_attribute *attrib) |
bool | gatt_db_attribute_get_service_uuid (const struct gatt_db_attribute *attrib, bt_uuid_t *uuid) |
bool | gatt_db_attribute_get_service_handles (const struct gatt_db_attribute *attrib, uint16_t *start_handle, uint16_t *end_handle) |
bool | gatt_db_attribute_get_service_data (const struct gatt_db_attribute *attrib, uint16_t *start_handle, uint16_t *end_handle, bool *primary, bt_uuid_t *uuid) |
bool | gatt_db_attribute_get_char_data (const struct gatt_db_attribute *attrib, uint16_t *handle, uint16_t *value_handle, uint8_t *properties, bt_uuid_t *uuid) |
bool | gatt_db_attribute_get_incl_data (const struct gatt_db_attribute *attrib, uint16_t *handle, uint16_t *start_handle, uint16_t *end_handle) |
uint32_t | gatt_db_attribute_get_permissions (const struct gatt_db_attribute *attrib) |
static bool | read_timeout (void *user_data) |
bool | gatt_db_attribute_read (struct gatt_db_attribute *attrib, uint16_t offset, uint8_t opcode, struct bt_att *att, gatt_db_attribute_read_t func, void *user_data) |
static bool | find_pending (const void *a, const void *b) |
bool | gatt_db_attribute_read_result (struct gatt_db_attribute *attrib, unsigned int id, int err, const uint8_t *value, size_t length) |
static bool | write_timeout (void *user_data) |
bool | gatt_db_attribute_write (struct gatt_db_attribute *attrib, uint16_t offset, const uint8_t *value, size_t len, uint8_t opcode, struct bt_att *att, gatt_db_attribute_write_t func, void *user_data) |
bool | gatt_db_attribute_write_result (struct gatt_db_attribute *attrib, unsigned int id, int err) |
bool | gatt_db_attribute_reset (struct gatt_db_attribute *attrib) |
Variables | |
static const bt_uuid_t | primary_service_uuid |
static const bt_uuid_t | secondary_service_uuid |
static const bt_uuid_t | characteristic_uuid |
static const bt_uuid_t | included_service_uuid |
manage the services / characteristics data model
Definition in file gatt-db.c.
#define ATTRIBUTE_TIMEOUT 5000 |
Definition at line 50 of file gatt-db.c.
Referenced by gatt_db_attribute_read(), and gatt_db_attribute_write().
#define MAX | ( | a, | |
b | |||
) | ((a) > (b) ? (a) : (b)) |
Definition at line 45 of file gatt-db.c.
Referenced by gatt_db_insert_service().
#define MAX_CHAR_DECL_VALUE_LEN 19 |
Definition at line 48 of file gatt-db.c.
Referenced by service_insert_characteristic().
#define MAX_INCLUDED_VALUE_LEN 6 |
Definition at line 49 of file gatt-db.c.
Referenced by gatt_db_service_add_included().
|
static |
Definition at line 156 of file gatt-db.c.
References pending_read_free(), gatt_db_attribute::pending_reads, pending_write_free(), gatt_db_attribute::pending_writes, queue_destroy(), and gatt_db_attribute::value.
Referenced by gatt_db_service_destroy(), and new_attribute().
|
static |
Definition at line 675 of file gatt-db.c.
References gatt_db_service::attributes, and gatt_db_attribute::handle.
Referenced by gatt_db_service_add_included().
|
static |
Definition at line 1022 of file gatt-db.c.
References gatt_db_service::active, gatt_db_service::attributes, bt_uuid_cmp(), find_by_type_value_data::end_handle, find_by_type_value_data::func, gatt_db_attribute::handle, gatt_db_service::num_handles, find_by_type_value_data::num_of_res, find_by_type_value_data::start_handle, find_by_type_value_data::user_data, gatt_db_attribute::uuid, find_by_type_value_data::uuid, gatt_db_attribute::value, find_by_type_value_data::value, and find_by_type_value_data::value_len.
Referenced by gatt_db_find_by_type(), and gatt_db_find_by_type_value().
|
static |
Definition at line 1157 of file gatt-db.c.
References gatt_db_service::active, gatt_db_service::attributes, find_information_data::end_handle, gatt_db_attribute::handle, gatt_db_service::num_handles, find_information_data::queue, queue_push_tail(), and find_information_data::start_handle.
Referenced by gatt_db_find_information().
|
static |
Definition at line 498 of file gatt-db.c.
References queue_entry::data, gatt_db_service_get_handles(), queue_entry::next, queue_get_entries(), and gatt_db::services.
Referenced by gatt_db_insert_service().
|
static |
Definition at line 1634 of file gatt-db.c.
References pending_read::id, and PTR_TO_UINT.
Referenced by gatt_db_attribute_read_result(), and gatt_db_attribute_write_result().
|
static |
Definition at line 1338 of file gatt-db.c.
References gatt_db_service_get_handles(), and PTR_TO_UINT.
Referenced by gatt_db_get_attribute().
|
static |
Definition at line 1374 of file gatt-db.c.
References gatt_db_service::attributes, bt_uuid_cmp(), and gatt_db_attribute_get_service_uuid().
Referenced by gatt_db_get_service_with_uuid().
|
static |
Definition at line 1215 of file gatt-db.c.
References gatt_db_service::attributes, bt_uuid_cmp(), foreach_data::end, foreach_data::func, gatt_db_attribute_get_service_uuid(), get_handle_at_index(), foreach_data::start, foreach_data::user_data, and foreach_data::uuid.
Referenced by gatt_db_foreach_service_in_range().
struct gatt_db_attribute* gatt_db_add_service | ( | struct gatt_db * | db, |
const bt_uuid_t * | uuid, | ||
bool | primary, | ||
uint16_t | num_handles | ||
) |
Definition at line 596 of file gatt-db.c.
References gatt_db_insert_service(), and gatt_db::next_handle.
bool gatt_db_attribute_get_char_data | ( | const struct gatt_db_attribute * | attrib, |
uint16_t * | handle, | ||
uint16_t * | value_handle, | ||
uint8_t * | properties, | ||
bt_uuid_t * | uuid | ||
) |
Definition at line 1495 of file gatt-db.c.
References bt_uuid_cmp(), get_le16(), gatt_db_attribute::handle, le_to_uuid(), gatt_db_attribute::uuid, gatt_db_attribute::value, and gatt_db_attribute::value_len.
Referenced by notify_chrc_create(), and print_chrc().
uint16_t gatt_db_attribute_get_handle | ( | const struct gatt_db_attribute * | attrib | ) |
Definition at line 1409 of file gatt-db.c.
References gatt_db_attribute::handle.
Referenced by discover_descs(), discover_descs_cb(), discover_incl_cb(), notify_chrc_create(), print_desc(), and register_service_changed().
bool gatt_db_attribute_get_incl_data | ( | const struct gatt_db_attribute * | attrib, |
uint16_t * | handle, | ||
uint16_t * | start_handle, | ||
uint16_t * | end_handle | ||
) |
Definition at line 1532 of file gatt-db.c.
References bt_uuid_cmp(), get_le16(), gatt_db_attribute::handle, gatt_db_attribute::uuid, gatt_db_attribute::value, and gatt_db_attribute::value_len.
Referenced by print_incl().
uint32_t gatt_db_attribute_get_permissions | ( | const struct gatt_db_attribute * | attrib | ) |
Definition at line 1569 of file gatt-db.c.
References gatt_db_attribute::permissions.
bool gatt_db_attribute_get_service_data | ( | const struct gatt_db_attribute * | attrib, |
uint16_t * | start_handle, | ||
uint16_t * | end_handle, | ||
bool * | primary, | ||
bt_uuid_t * | uuid | ||
) |
Definition at line 1465 of file gatt-db.c.
References gatt_db_service::attributes, bt_uuid_cmp(), gatt_db_service_get_handles(), le_to_uuid(), gatt_db_attribute::service, gatt_db_attribute::uuid, gatt_db_attribute::value, and gatt_db_attribute::value_len.
Referenced by print_service().
bool gatt_db_attribute_get_service_handles | ( | const struct gatt_db_attribute * | attrib, |
uint16_t * | start_handle, | ||
uint16_t * | end_handle | ||
) |
Definition at line 1448 of file gatt-db.c.
References gatt_db_service_get_handles(), and gatt_db_attribute::service.
Referenced by discover_chrcs_cb(), discover_descs_cb(), discover_incl_cb(), discover_secondary_cb(), and log_service_event().
bool gatt_db_attribute_get_service_uuid | ( | const struct gatt_db_attribute * | attrib, |
bt_uuid_t * | uuid | ||
) |
Definition at line 1417 of file gatt-db.c.
References gatt_db_service::attributes, bswap_128(), bt_uuid128_create(), bt_uuid16_create(), get_le16(), gatt_db_attribute::service, gatt_db_attribute::value, and gatt_db_attribute::value_len.
Referenced by find_service_with_uuid(), foreach_service_in_range(), gatt_db_insert_service(), log_service_event(), and print_incl().
const bt_uuid_t* gatt_db_attribute_get_type | ( | const struct gatt_db_attribute * | attrib | ) |
Definition at line 1400 of file gatt-db.c.
References gatt_db_attribute::uuid.
Referenced by find_ccc(), notify_chrc_create(), and print_desc().
bool gatt_db_attribute_read | ( | struct gatt_db_attribute * | attrib, |
uint16_t | offset, | ||
uint8_t | opcode, | ||
struct bt_att * | att, | ||
gatt_db_attribute_read_t | func, | ||
void * | user_data | ||
) |
Definition at line 1590 of file gatt-db.c.
References pending_read::attrib, ATTRIBUTE_TIMEOUT, BT_ATT_ERROR_INVALID_OFFSET, pending_read::func, func, pending_read::id, new0, gatt_db_attribute::pending_reads, queue_push_tail(), gatt_db_attribute::read_func, gatt_db_attribute::read_id, read_timeout(), timeout_add(), pending_read::timeout_id, pending_read::user_data, gatt_db_attribute::user_data, gatt_db_attribute::value, and gatt_db_attribute::value_len.
bool gatt_db_attribute_read_result | ( | struct gatt_db_attribute * | attrib, |
unsigned int | id, | ||
int | err, | ||
const uint8_t * | value, | ||
size_t | length | ||
) |
Definition at line 1642 of file gatt-db.c.
References find_pending(), pending_read_result(), gatt_db_attribute::pending_reads, queue_remove_if(), and UINT_TO_PTR.
bool gatt_db_attribute_reset | ( | struct gatt_db_attribute * | attrib | ) |
Definition at line 1752 of file gatt-db.c.
References gatt_db_attribute::value, and gatt_db_attribute::value_len.
bool gatt_db_attribute_write | ( | struct gatt_db_attribute * | attrib, |
uint16_t | offset, | ||
const uint8_t * | value, | ||
size_t | len, | ||
uint8_t | opcode, | ||
struct bt_att * | att, | ||
gatt_db_attribute_write_t | func, | ||
void * | user_data | ||
) |
Definition at line 1674 of file gatt-db.c.
References pending_write::attrib, ATTRIBUTE_TIMEOUT, pending_write::func, func, pending_write::id, new0, gatt_db_attribute::pending_writes, queue_push_tail(), timeout_add(), pending_write::timeout_id, pending_write::user_data, gatt_db_attribute::user_data, gatt_db_attribute::value, gatt_db_attribute::value_len, gatt_db_attribute::write_func, gatt_db_attribute::write_id, and write_timeout().
bool gatt_db_attribute_write_result | ( | struct gatt_db_attribute * | attrib, |
unsigned int | id, | ||
int | err | ||
) |
Definition at line 1734 of file gatt-db.c.
References find_pending(), pending_write_result(), gatt_db_attribute::pending_writes, queue_remove_if(), and UINT_TO_PTR.
bool gatt_db_clear | ( | struct gatt_db * | db | ) |
Definition at line 442 of file gatt-db.c.
References gatt_db_service_destroy(), gatt_db::next_handle, queue_remove_all(), and gatt_db::services.
Referenced by init_fail().
bool gatt_db_clear_range | ( | struct gatt_db * | db, |
uint16_t | start_handle, | ||
uint16_t | end_handle | ||
) |
Definition at line 481 of file gatt-db.c.
References clear_range::end, gatt_db_service_destroy(), match_range(), queue_remove_all(), gatt_db::services, and clear_range::start.
Referenced by discover_primary_cb(), discover_secondary_cb(), process_service_changed(), service_changed_complete(), and service_changed_failure().
|
static |
Definition at line 312 of file gatt-db.c.
References gatt_db_service_destroy(), notify_destroy(), gatt_db::notify_list, queue_destroy(), and gatt_db::services.
Referenced by gatt_db_unref().
unsigned int gatt_db_find_by_type | ( | struct gatt_db * | db, |
uint16_t | start_handle, | ||
uint16_t | end_handle, | ||
const bt_uuid_t * | type, | ||
gatt_db_attribute_cb_t | func, | ||
void * | user_data | ||
) |
Definition at line 1056 of file gatt-db.c.
References find_by_type_value_data::end_handle, find_by_type(), find_by_type_value_data::func, func, find_by_type_value_data::num_of_res, queue_foreach(), gatt_db::services, find_by_type_value_data::start_handle, type, find_by_type_value_data::user_data, and find_by_type_value_data::uuid.
Referenced by register_service_changed().
unsigned int gatt_db_find_by_type_value | ( | struct gatt_db * | db, |
uint16_t | start_handle, | ||
uint16_t | end_handle, | ||
const bt_uuid_t * | type, | ||
const void * | value, | ||
size_t | value_len, | ||
gatt_db_attribute_cb_t | func, | ||
void * | user_data | ||
) |
Definition at line 1077 of file gatt-db.c.
References find_by_type_value_data::end_handle, find_by_type(), find_by_type_value_data::func, func, find_by_type_value_data::num_of_res, queue_foreach(), gatt_db::services, find_by_type_value_data::start_handle, type, find_by_type_value_data::user_data, find_by_type_value_data::uuid, find_by_type_value_data::value, and find_by_type_value_data::value_len.
void gatt_db_find_information | ( | struct gatt_db * | db, |
uint16_t | start_handle, | ||
uint16_t | end_handle, | ||
struct queue * | queue | ||
) |
Definition at line 1187 of file gatt-db.c.
References find_information_data::end_handle, find_information(), find_information_data::queue, queue_foreach(), gatt_db::services, and find_information_data::start_handle.
void gatt_db_foreach_service | ( | struct gatt_db * | db, |
const bt_uuid_t * | uuid, | ||
gatt_db_attribute_cb_t | func, | ||
void * | user_data | ||
) |
Definition at line 1200 of file gatt-db.c.
References gatt_db_foreach_service_in_range().
Referenced by print_services(), print_services_by_handle(), and print_services_by_uuid().
void gatt_db_foreach_service_in_range | ( | struct gatt_db * | db, |
const bt_uuid_t * | uuid, | ||
gatt_db_attribute_cb_t | func, | ||
void * | user_data, | ||
uint16_t | start_handle, | ||
uint16_t | end_handle | ||
) |
Definition at line 1237 of file gatt-db.c.
References foreach_data::end, foreach_service_in_range(), foreach_data::func, func, queue_foreach(), gatt_db::services, foreach_data::start, foreach_data::user_data, and foreach_data::uuid.
Referenced by gatt_db_foreach_service(), and service_changed_cb().
struct gatt_db_attribute* gatt_db_get_attribute | ( | struct gatt_db * | db, |
uint16_t | handle | ||
) |
Definition at line 1349 of file gatt-db.c.
References gatt_db_service::attributes, find_service_for_handle(), gatt_db_attribute::handle, gatt_db_service::num_handles, queue_find(), gatt_db::services, and UINT_TO_PTR.
Referenced by discover_incl_cb(), notify_chrc_create(), and print_incl().
struct gatt_db_attribute* gatt_db_get_service_with_uuid | ( | struct gatt_db * | db, |
const bt_uuid_t * | uuid | ||
) |
Definition at line 1385 of file gatt-db.c.
References gatt_db_service::attributes, find_service_with_uuid(), queue_find(), and gatt_db::services.
struct gatt_db_attribute* gatt_db_insert_service | ( | struct gatt_db * | db, |
uint16_t | handle, | ||
const bt_uuid_t * | uuid, | ||
bool | primary, | ||
uint16_t | num_handles | ||
) |
Definition at line 531 of file gatt-db.c.
References gatt_db_service::attributes, bt_uuid_cmp(), gatt_db_service::db, find_insert_loc(), gatt_db_attribute_get_service_uuid(), gatt_db_service_create(), gatt_db_service_destroy(), gatt_db_attribute::handle, MAX, gatt_db::next_handle, gatt_db_service::num_handles, primary_service_uuid, queue_push_after(), queue_push_head(), secondary_service_uuid, gatt_db::services, type, and gatt_db_attribute::uuid.
Referenced by discover_primary_cb(), discover_secondary_cb(), and gatt_db_add_service().
bool gatt_db_isempty | ( | struct gatt_db * | db | ) |
Definition at line 339 of file gatt-db.c.
References queue_isempty(), and gatt_db::services.
struct gatt_db* gatt_db_new | ( | void | ) |
Definition at line 218 of file gatt-db.c.
References gatt_db_ref(), new0, gatt_db::next_handle, gatt_db::notify_list, queue_destroy(), queue_new(), and gatt_db::services.
Referenced by client_create().
void gatt_db_read_by_group_type | ( | struct gatt_db * | db, |
uint16_t | start_handle, | ||
uint16_t | end_handle, | ||
const bt_uuid_t | type, | ||
struct queue * | queue | ||
) |
Definition at line 968 of file gatt-db.c.
References gatt_db_service::active, gatt_db_service::attributes, bt_uuid_cmp(), queue_entry::data, gatt_db_attribute::handle, queue_entry::next, gatt_db_service::num_handles, queue_get_entries(), queue_push_tail(), gatt_db::services, gatt_db_attribute::uuid, and gatt_db_attribute::value_len.
void gatt_db_read_by_type | ( | struct gatt_db * | db, |
uint16_t | start_handle, | ||
uint16_t | end_handle, | ||
const bt_uuid_t | type, | ||
struct queue * | queue | ||
) |
Definition at line 1136 of file gatt-db.c.
References read_by_type_data::end_handle, read_by_type_data::queue, queue_foreach(), read_by_type(), gatt_db::services, read_by_type_data::start_handle, type, and read_by_type_data::uuid.
Definition at line 208 of file gatt-db.c.
References gatt_db::ref_count.
Referenced by bt_gatt_client_new(), gatt_db_new(), and notify_service_changed().
unsigned int gatt_db_register | ( | struct gatt_db * | db, |
gatt_db_attribute_cb_t | service_added, | ||
gatt_db_attribute_cb_t | service_removed, | ||
void * | user_data, | ||
gatt_db_destroy_func_t | destroy | ||
) |
Definition at line 605 of file gatt-db.c.
References notify::destroy, notify::id, new0, gatt_db::next_notify_id, gatt_db::notify_list, queue_push_tail(), notify::service_added, notify::service_removed, and notify::user_data.
Referenced by client_create().
bool gatt_db_remove_service | ( | struct gatt_db * | db, |
struct gatt_db_attribute * | attrib | ||
) |
Definition at line 425 of file gatt-db.c.
References gatt_db_service_destroy(), queue_remove(), gatt_db_attribute::service, and gatt_db::services.
struct gatt_db_attribute* gatt_db_service_add_characteristic | ( | struct gatt_db_attribute * | attrib, |
const bt_uuid_t * | uuid, | ||
uint32_t | permissions, | ||
uint8_t | properties, | ||
gatt_db_read_t | read_func, | ||
gatt_db_write_t | write_func, | ||
void * | user_data | ||
) |
Definition at line 785 of file gatt-db.c.
References gatt_db_attribute::service, and service_insert_characteristic().
struct gatt_db_attribute* gatt_db_service_add_descriptor | ( | struct gatt_db_attribute * | attrib, |
const bt_uuid_t * | uuid, | ||
uint32_t | permissions, | ||
gatt_db_read_t | read_func, | ||
gatt_db_write_t | write_func, | ||
void * | user_data | ||
) |
Definition at line 852 of file gatt-db.c.
References gatt_db_attribute::service, and service_insert_descriptor().
struct gatt_db_attribute* gatt_db_service_add_included | ( | struct gatt_db_attribute * | attrib, |
struct gatt_db_attribute * | include | ||
) |
Definition at line 868 of file gatt-db.c.
References attribute_update(), gatt_db_service::attributes, get_attribute_index(), gatt_db_attribute::handle, MAX_INCLUDED_VALUE_LEN, new_attribute(), gatt_db_service::num_handles, put_le16(), gatt_db_attribute::service, set_attribute_data(), gatt_db_attribute::value, and gatt_db_attribute::value_len.
Referenced by discover_incl_cb().
|
static |
Definition at line 384 of file gatt-db.c.
References gatt_db_service::attributes, gatt_db_service_destroy(), new0, new_attribute(), primary_service_uuid, secondary_service_uuid, type, and uuid_to_le().
Referenced by gatt_db_insert_service().
|
static |
Definition at line 297 of file gatt-db.c.
References gatt_db_service::active, attribute_destroy(), gatt_db_service::attributes, gatt_db_service::db, notify_service_changed(), and gatt_db_service::num_handles.
Referenced by gatt_db_clear(), gatt_db_clear_range(), gatt_db_destroy(), gatt_db_insert_service(), gatt_db_remove_service(), and gatt_db_service_create().
void gatt_db_service_foreach | ( | struct gatt_db_attribute * | attrib, |
const bt_uuid_t * | uuid, | ||
gatt_db_attribute_cb_t | func, | ||
void * | user_data | ||
) |
Definition at line 1258 of file gatt-db.c.
References gatt_db_service::attributes, bt_uuid_cmp(), func, gatt_db_service::num_handles, gatt_db_attribute::service, and gatt_db_attribute::uuid.
Referenced by gatt_db_service_foreach_char(), and gatt_db_service_foreach_incl().
void gatt_db_service_foreach_char | ( | struct gatt_db_attribute * | attrib, |
gatt_db_attribute_cb_t | func, | ||
void * | user_data | ||
) |
Definition at line 1284 of file gatt-db.c.
References gatt_db_service_foreach().
Referenced by print_service().
void gatt_db_service_foreach_desc | ( | struct gatt_db_attribute * | attrib, |
gatt_db_attribute_cb_t | func, | ||
void * | user_data | ||
) |
Definition at line 1291 of file gatt-db.c.
References gatt_db_service::attributes, bt_uuid_cmp(), func, gatt_db_service::num_handles, gatt_db_attribute::service, and gatt_db_attribute::uuid.
Referenced by notify_chrc_create(), and print_chrc().
void gatt_db_service_foreach_incl | ( | struct gatt_db_attribute * | attrib, |
gatt_db_attribute_cb_t | func, | ||
void * | user_data | ||
) |
Definition at line 1330 of file gatt-db.c.
References gatt_db_service_foreach().
Referenced by print_service().
bool gatt_db_service_get_active | ( | struct gatt_db_attribute * | attrib | ) |
Definition at line 941 of file gatt-db.c.
References gatt_db_service::active, and gatt_db_attribute::service.
Referenced by discover_primary_cb(), and discover_secondary_cb().
bool gatt_db_service_get_claimed | ( | struct gatt_db_attribute * | attrib | ) |
Definition at line 960 of file gatt-db.c.
References gatt_db_service::claimed, and gatt_db_attribute::service.
|
static |
Definition at line 454 of file gatt-db.c.
References gatt_db_service::attributes, gatt_db_attribute::handle, and gatt_db_service::num_handles.
Referenced by find_insert_loc(), find_service_for_handle(), gatt_db_attribute_get_service_data(), gatt_db_attribute_get_service_handles(), and match_range().
struct gatt_db_attribute* gatt_db_service_insert_characteristic | ( | struct gatt_db_attribute * | attrib, |
uint16_t | handle, | ||
const bt_uuid_t * | uuid, | ||
uint32_t | permissions, | ||
uint8_t | properties, | ||
gatt_db_read_t | read_func, | ||
gatt_db_write_t | write_func, | ||
void * | user_data | ||
) |
Definition at line 766 of file gatt-db.c.
References gatt_db_attribute::service, and service_insert_characteristic().
Referenced by discover_descs().
struct gatt_db_attribute* gatt_db_service_insert_descriptor | ( | struct gatt_db_attribute * | attrib, |
uint16_t | handle, | ||
const bt_uuid_t * | uuid, | ||
uint32_t | permissions, | ||
gatt_db_read_t | read_func, | ||
gatt_db_write_t | write_func, | ||
void * | user_data | ||
) |
Definition at line 835 of file gatt-db.c.
References gatt_db_attribute::service, and service_insert_descriptor().
Referenced by discover_descs_cb().
bool gatt_db_service_set_active | ( | struct gatt_db_attribute * | attrib, |
bool | active | ||
) |
Definition at line 922 of file gatt-db.c.
References gatt_db_service::active, gatt_db_service::db, notify_service_changed(), and gatt_db_attribute::service.
Referenced by discover_chrcs_cb(), and discover_descs_cb().
bool gatt_db_service_set_claimed | ( | struct gatt_db_attribute * | attrib, |
bool | claimed | ||
) |
Definition at line 949 of file gatt-db.c.
References gatt_db_service::claimed, and gatt_db_attribute::service.
void gatt_db_unref | ( | struct gatt_db * | db | ) |
Definition at line 328 of file gatt-db.c.
References gatt_db_destroy(), and gatt_db::ref_count.
Referenced by bt_gatt_client_free(), client_create(), and notify_service_changed().
bool gatt_db_unregister | ( | struct gatt_db * | db, |
unsigned int | id | ||
) |
Definition at line 638 of file gatt-db.c.
References match_notify_id(), notify_destroy(), gatt_db::notify_list, queue_find(), queue_remove(), and UINT_TO_PTR.
|
static |
Definition at line 655 of file gatt-db.c.
References gatt_db_service::attributes, and gatt_db_service::num_handles.
Referenced by gatt_db_service_add_included(), service_insert_characteristic(), and service_insert_descriptor().
|
static |
Definition at line 668 of file gatt-db.c.
References gatt_db_service::attributes, and gatt_db_attribute::handle.
Referenced by foreach_service_in_range(), service_insert_characteristic(), and service_insert_descriptor().
|
static |
Definition at line 267 of file gatt-db.c.
References notify_data::added, notify_data::attr, notify::service_added, notify::service_removed, notify::user_data, and notify_data::user_data.
Referenced by notify_service_changed().
|
static |
Definition at line 361 of file gatt-db.c.
References bswap_128(), bt_uuid128_create(), bt_uuid16_create(), bt_uuid32_create(), get_le16(), and get_le32().
Referenced by gatt_db_attribute_get_char_data(), and gatt_db_attribute_get_service_data().
|
static |
Definition at line 254 of file gatt-db.c.
References notify::id, and PTR_TO_UINT.
Referenced by gatt_db_unregister().
|
static |
Definition at line 470 of file gatt-db.c.
References clear_range::end, gatt_db_service_get_handles(), and clear_range::start.
Referenced by gatt_db_clear_range().
|
static |
Definition at line 169 of file gatt-db.c.
References attribute_destroy(), gatt_db_attribute::handle, malloc0, new0, gatt_db_attribute::pending_reads, gatt_db_attribute::pending_writes, queue_new(), gatt_db_attribute::service, type, gatt_db_attribute::uuid, gatt_db_attribute::value, and gatt_db_attribute::value_len.
Referenced by gatt_db_service_add_included(), gatt_db_service_create(), service_insert_characteristic(), and service_insert_descriptor().
|
static |
Definition at line 244 of file gatt-db.c.
References notify::destroy, and notify::user_data.
Referenced by gatt_db_destroy(), and gatt_db_unregister().
|
static |
Definition at line 278 of file gatt-db.c.
References notify_data::added, notify_data::attr, gatt_db_service::attributes, gatt_db_ref(), gatt_db_unref(), handle_notify(), gatt_db::notify_list, queue_foreach(), and queue_isempty().
Referenced by gatt_db_service_destroy(), and gatt_db_service_set_active().
|
static |
Definition at line 132 of file gatt-db.c.
References pending_read_result().
Referenced by attribute_destroy().
|
static |
Definition at line 121 of file gatt-db.c.
References pending_read::attrib, pending_read::func, pending_read::timeout_id, timeout_remove(), and pending_read::user_data.
Referenced by gatt_db_attribute_read_result(), pending_read_free(), and read_timeout().
|
static |
Definition at line 149 of file gatt-db.c.
References pending_write_result().
Referenced by attribute_destroy().
|
static |
Definition at line 139 of file gatt-db.c.
References pending_write::attrib, pending_write::func, pending_write::timeout_id, timeout_remove(), and pending_write::user_data.
Referenced by gatt_db_attribute_write_result(), pending_write_free(), and write_timeout().
|
static |
Definition at line 1108 of file gatt-db.c.
References gatt_db_service::active, gatt_db_service::attributes, bt_uuid_cmp(), read_by_type_data::end_handle, gatt_db_attribute::handle, gatt_db_service::num_handles, read_by_type_data::queue, queue_push_tail(), read_by_type_data::start_handle, gatt_db_attribute::uuid, and read_by_type_data::uuid.
Referenced by gatt_db_read_by_type().
|
static |
Definition at line 1577 of file gatt-db.c.
References pending_read::attrib, pending_read_result(), gatt_db_attribute::pending_reads, queue_remove(), pending_read::timeout_id, and pending_read::user_data.
Referenced by gatt_db_attribute_read().
|
static |
Definition at line 701 of file gatt-db.c.
References gatt_db_service::attributes, get_attribute_index(), get_handle_at_index(), MAX_CHAR_DECL_VALUE_LEN, new_attribute(), put_le16(), set_attribute_data(), uuid_to_le(), and gatt_db_attribute::value.
Referenced by gatt_db_service_add_characteristic(), and gatt_db_service_insert_characteristic().
|
static |
Definition at line 803 of file gatt-db.c.
References gatt_db_service::attributes, get_attribute_index(), get_handle_at_index(), new_attribute(), and set_attribute_data().
Referenced by gatt_db_service_add_descriptor(), and gatt_db_service_insert_descriptor().
|
static |
Definition at line 688 of file gatt-db.c.
References gatt_db_attribute::permissions, gatt_db_attribute::read_func, gatt_db_attribute::user_data, and gatt_db_attribute::write_func.
Referenced by gatt_db_service_add_included(), service_insert_characteristic(), and service_insert_descriptor().
|
static |
Definition at line 347 of file gatt-db.c.
References bswap_128(), bt_uuid_len(), bt_uuid_to_uuid128(), put_le16(), bt_uuid_t::type, bt_uuid_t::u128, bt_uuid_t::u16, and bt_uuid_t::value.
Referenced by gatt_db_service_create(), and service_insert_characteristic().
|
static |
Definition at line 1661 of file gatt-db.c.
References pending_write::attrib, pending_write_result(), gatt_db_attribute::pending_writes, queue_remove(), pending_write::timeout_id, and pending_write::user_data.
Referenced by gatt_db_attribute_write().
|
static |
|
static |
|
static |
Definition at line 52 of file gatt-db.c.
Referenced by gatt_db_insert_service(), and gatt_db_service_create().
|
static |
Definition at line 54 of file gatt-db.c.
Referenced by gatt_db_insert_service(), and gatt_db_service_create().