diff --git a/android/gatt.c b/android/gatt.c
index fb29339..f16d365 100644
--- a/android/gatt.c
+++ b/android/gatt.c
HAL_OP_GATT_CLIENT_GET_INCLUDED_SERVICE, status);
}
-static void send_client_char_notify(const struct characteristic *ch,
- int32_t conn_id,
- const struct service *service)
+static void send_client_char_notify(const struct hal_gatt_srvc_id *service,
+ const struct hal_gatt_gatt_id *charac,
+ int32_t char_prop, int32_t conn_id)
{
struct hal_ev_gatt_client_get_characteristic ev;
- memset(&ev, 0, sizeof(ev));
- ev.status = ch ? GATT_SUCCESS : GATT_FAILURE;
+ ev.conn_id = conn_id;
- if (ch) {
- ev.char_prop = ch->ch.properties;
- element_id_to_hal_gatt_id(&ch->id, &ev.char_id);
+ if (charac) {
+ memcpy(&ev.char_id, charac, sizeof(struct hal_gatt_gatt_id));
+ ev.char_prop = char_prop;
+ ev.status = GATT_SUCCESS;
+ } else {
+ memset(&ev.char_id, 0, sizeof(struct hal_gatt_gatt_id));
+ ev.char_prop = 0;
+ ev.status = GATT_FAILURE;
}
- ev.conn_id = conn_id;
- element_id_to_hal_srvc_id(&service->id, service->primary, &ev.srvc_id);
+ memcpy(&ev.srvc_id, service, sizeof(struct hal_gatt_srvc_id));
ipc_send_notif(hal_ipc, HAL_SERVICE_ID_GATT,
HAL_EV_GATT_CLIENT_GET_CHARACTERISTIC,
sizeof(ev), &ev);
}
+static void convert_send_client_char_notify(const struct characteristic *ch,
+ int32_t conn_id,
+ const struct service *service)
+{
+ struct hal_gatt_srvc_id srvc;
+ struct hal_gatt_gatt_id charac;
+
+ element_id_to_hal_srvc_id(&service->id, service->primary, &srvc);
+
+ if (ch) {
+ element_id_to_hal_gatt_id(&ch->id, &charac);
+ send_client_char_notify(&srvc, &charac, ch->ch.properties,
+ conn_id);
+ } else {
+ send_client_char_notify(&srvc, NULL, 0, conn_id);
+ }
+}
+
static void cache_all_srvc_chars(struct service *srvc, GSList *characteristics)
{
uint16_t inst_id = 0;
if (queue_isempty(srvc->chars))
cache_all_srvc_chars(srvc, characteristics);
- send_client_char_notify(queue_peek_head(srvc->chars), data->conn_id,
- srvc);
+ convert_send_client_char_notify(queue_peek_head(srvc->chars),
+ data->conn_id, srvc);
free(data);
}
else
ch = queue_peek_head(srvc->chars);
- send_client_char_notify(ch, conn->id, srvc);
+ convert_send_client_char_notify(ch, conn->id, srvc);
status = HAL_STATUS_SUCCESS;
done:
+ if (status != HAL_STATUS_SUCCESS)
+ send_client_char_notify(&cmd->srvc_id, NULL, 0, cmd->conn_id);
+
ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
HAL_OP_GATT_CLIENT_GET_CHARACTERISTIC, status);
}