diff --git a/android/gatt.c b/android/gatt.c
index 14fd164..f53884b 100644
--- a/android/gatt.c
+++ b/android/gatt.c
struct notification_data {
struct hal_gatt_srvc_id service;
struct hal_gatt_gatt_id ch;
- struct connection *conn;
+ struct app_connection *conn;
guint notif_id;
guint ind_id;
int ref;
int conn_cnt;
};
-struct connection {
+struct app_connection {
struct gatt_device *device;
struct gatt_app *app;
int32_t id;
static bool match_connection_by_id(const void *data, const void *user_data)
{
- const struct connection *conn = data;
+ const struct app_connection *conn = data;
const int32_t id = PTR_TO_INT(user_data);
return conn->id == id;
static bool match_connection_by_device_and_app(const void *data,
const void *user_data)
{
- const struct connection *conn = data;
- const struct connection *match = user_data;
+ const struct app_connection *conn = data;
+ const struct app_connection *match = user_data;
return conn->device == match->device && conn->app == match->app;
}
-static struct connection *find_connection_by_id(int32_t conn_id)
+static struct app_connection *find_connection_by_id(int32_t conn_id)
{
return queue_find(app_connections, match_connection_by_id,
INT_TO_PTR(conn_id));
static bool match_connection_by_device(const void *data, const void *user_data)
{
- const struct connection *conn = data;
+ const struct app_connection *conn = data;
const struct gatt_device *dev = user_data;
return conn->device == dev;
static bool match_connection_by_app(const void *data, const void *user_data)
{
- const struct connection *conn = data;
+ const struct app_connection *conn = data;
const struct gatt_app *app = user_data;
return conn->app == app;
status);
}
-static void send_client_disconnection_notify(struct connection *connection,
+static void send_client_disconnection_notify(struct app_connection *connection,
int32_t status)
{
struct hal_ev_gatt_client_disconnect ev;
HAL_EV_GATT_CLIENT_DISCONNECT, sizeof(ev), &ev);
}
-static void send_client_connection_notify(struct connection *connection,
+static void send_client_connection_notify(struct app_connection *connection,
int32_t status)
{
struct hal_ev_gatt_client_connect ev;
sizeof(ev), &ev);
}
-static void send_app_disconnect_notify(struct connection *connection,
+static void send_app_disconnect_notify(struct app_connection *connection,
int32_t status)
{
if (connection->app->type == APP_CLIENT)
/* TODO: handle APP_SERVER */
}
-static void send_app_connect_notify(struct connection *connection,
+static void send_app_connect_notify(struct app_connection *connection,
int32_t status)
{
if (connection->app->type == APP_CLIENT)
static void disconnect_notify_by_device(void *data, void *user_data)
{
- struct connection *conn = data;
+ struct app_connection *conn = data;
struct gatt_device *dev = user_data;
if (dev != conn->device)
static void destroy_connection(void *data)
{
- struct connection *conn = data;
+ struct app_connection *conn = data;
if (!queue_find(gatt_devices, match_by_value, conn->device))
goto cleanup;
sizeof(ev), &ev);
}
-static void send_client_all_primary(struct connection *connection,
+static void send_client_all_primary(struct app_connection *connection,
int32_t status)
{
struct hal_ev_gatt_client_search_complete ev;
static void primary_cb(uint8_t status, GSList *services, void *user_data)
{
- struct connection *conn = user_data;
+ struct app_connection *conn = user_data;
GSList *l;
int32_t gatt_status;
uint8_t instance_id;
static void send_app_connect_notifications(void *data, void *user_data)
{
- struct connection *conn = data;
+ struct app_connection *conn = data;
struct connect_data *con_data = user_data;
if (conn->device == con_data->dev)
return device_ref(dev);
}
-static struct connection *create_connection(struct gatt_device *device,
+static struct app_connection *create_connection(struct gatt_device *device,
struct gatt_app *app)
{
- struct connection *new_conn;
+ struct app_connection *new_conn;
static int32_t last_conn_id = 1;
/* Check if already connected */
- new_conn = new0(struct connection, 1);
+ new_conn = new0(struct app_connection, 1);
if (!new_conn)
return NULL;
return new_conn;
}
-static void trigger_disconnection(struct connection *connection)
+static void trigger_disconnection(struct app_connection *connection)
{
/* Notify client */
if (queue_remove(app_connections, connection))
static void app_disconnect_devices(struct gatt_app *client)
{
- struct connection *conn;
+ struct app_connection *conn;
/* find every connection for client record and trigger disconnect */
conn = queue_remove_if(app_connections, match_connection_by_app,
}
}
-static bool trigger_connection(struct connection *connection)
+static bool trigger_connection(struct app_connection *connection)
{
switch (connection->device->state) {
case DEVICE_DISCONNECTED:
HAL_OP_GATT_CLIENT_UNREGISTER, status);
}
-static struct connection *find_conn(const bdaddr_t *addr, int32_t app_id,
+static struct app_connection *find_conn(const bdaddr_t *addr, int32_t app_id,
int32_t app_type)
{
- struct connection conn_match;
+ struct app_connection conn_match;
struct gatt_device *dev = NULL;
struct gatt_app *app;
static void handle_client_connect(const void *buf, uint16_t len)
{
const struct hal_cmd_gatt_client_connect *cmd = buf;
- struct connection conn_match;
- struct connection *conn;
+ struct app_connection conn_match;
+ struct app_connection *conn;
struct gatt_device *device;
struct gatt_app *client;
bdaddr_t addr;
static void handle_client_disconnect(const void *buf, uint16_t len)
{
const struct hal_cmd_gatt_client_disconnect *cmd = buf;
- struct connection *conn;
+ struct app_connection *conn;
uint8_t status;
DBG("");
static void handle_client_search_service(const void *buf, uint16_t len)
{
const struct hal_cmd_gatt_client_search_service *cmd = buf;
- struct connection *conn;
+ struct app_connection *conn;
uint8_t status;
DBG("");
struct get_included_data {
struct service *prim;
- struct connection *conn;
+ struct app_connection *conn;
};
static int get_inst_id_of_prim_services(const struct gatt_device *dev)
static void get_included_cb(uint8_t status, GSList *included, void *user_data)
{
struct get_included_data *data = user_data;
- struct connection *conn = data->conn;
+ struct app_connection *conn = data->conn;
struct service *service = data->prim;
struct service *incl;
int instance_id;
GATT_FAILURE);
}
-static bool search_included_services(struct connection *connection,
+static bool search_included_services(struct app_connection *connection,
struct service *service)
{
struct get_included_data *data;
}
static bool find_service(int32_t conn_id, struct element_id *service_id,
- struct connection **connection,
+ struct app_connection **connection,
struct service **service)
{
struct service *srvc;
- struct connection *conn;
+ struct app_connection *conn;
conn = find_connection_by_id(conn_id);
if (!conn) {
static void handle_client_get_included_service(const void *buf, uint16_t len)
{
const struct hal_cmd_gatt_client_get_included_service *cmd = buf;
- struct connection *conn;
+ struct app_connection *conn;
struct service *prim_service;
struct service *incl_service;
struct element_id match_id;
const struct hal_cmd_gatt_client_get_characteristic *cmd = buf;
struct characteristic *ch;
struct element_id match_id;
- struct connection *conn;
+ struct app_connection *conn;
struct service *srvc;
uint8_t status;
}
struct discover_desc_data {
- struct connection *conn;
+ struct app_connection *conn;
struct service *srvc;
struct characteristic *ch;
gpointer user_data)
{
struct discover_desc_data *data = user_data;
- struct connection *conn = data->conn;
+ struct app_connection *conn = data->conn;
struct service *srvc = data->srvc;
struct characteristic *ch = data->ch;
struct descriptor *descr;
free(data);
}
-static bool build_descr_cache(struct connection *connection,
+static bool build_descr_cache(struct app_connection *connection,
struct service *srvc,
struct characteristic *ch)
{
struct service *srvc;
struct element_id srvc_id;
struct element_id char_id;
- struct connection *conn;
+ struct app_connection *conn;
int32_t conn_id;
uint8_t primary;
uint8_t status;
const struct hal_cmd_gatt_client_read_characteristic *cmd = buf;
struct char_op_data *cb_data;
struct characteristic *ch;
- struct connection *conn;
+ struct app_connection *conn;
struct service *srvc;
struct element_id srvc_id;
struct element_id char_id;
const struct hal_cmd_gatt_client_write_characteristic *cmd = buf;
struct char_op_data *cb_data = NULL;
struct characteristic *ch;
- struct connection *conn;
+ struct app_connection *conn;
struct service *srvc;
struct element_id srvc_id;
struct element_id char_id;
struct element_id char_id;
struct element_id descr_id;
struct element_id srvc_id;
- struct connection *conn;
+ struct app_connection *conn;
int32_t conn_id = 0;
uint8_t primary;
uint8_t status;
struct element_id srvc_id;
struct element_id char_id;
struct element_id descr_id;
- struct connection *conn;
+ struct app_connection *conn;
int32_t conn_id;
uint8_t primary;
uint8_t status;
static void handle_client_execute_write(const void *buf, uint16_t len)
{
const struct hal_cmd_gatt_client_execute_write *cmd = buf;
- struct connection *conn;
+ struct app_connection *conn;
uint8_t status;
uint8_t flags;
struct notification_data *notification;
struct characteristic *c;
struct element_id match_id;
- struct connection *conn;
+ struct app_connection *conn;
int32_t conn_id = 0;
struct service *service;
uint8_t status;
{
const struct hal_cmd_gatt_client_deregister_for_notification *cmd = buf;
struct notification_data *notification, notif;
- struct connection *conn;
+ struct app_connection *conn;
int32_t conn_id = 0;
uint8_t status;
int32_t gatt_status;