diff --git a/android/gatt.c b/android/gatt.c
index e87237a..75c555c 100644
--- a/android/gatt.c
+++ b/android/gatt.c
HAL_OP_GATT_CLIENT_EXECUTE_WRITE, HAL_STATUS_FAILED);
}
+static void handle_notification(const uint8_t *pdu, uint16_t len,
+ gpointer user_data)
+{
+ uint8_t buf[IPC_MTU];
+ struct hal_ev_gatt_client_notify *ev = (void *) buf;
+ struct notification_data *notification = user_data;
+ uint8_t data_offset = sizeof(uint8_t) + sizeof(uint16_t);
+
+ if (len < data_offset)
+ return;
+
+ memcpy(&ev->char_id, ¬ification->ch, sizeof(ev->char_id));
+ memcpy(&ev->srvc_id, ¬ification->service, sizeof(ev->srvc_id));
+ bdaddr2android(¬ification->dev->bdaddr, &ev->bda);
+ ev->conn_id = notification->dev->conn_id;
+ ev->is_notify = pdu[0] == ATT_OP_HANDLE_NOTIFY;
+
+ /* We have to cut opcode and handle from data */
+ ev->len = len - data_offset;
+ memcpy(ev->value, pdu + data_offset, len - data_offset);
+
+ ipc_send_notif(hal_ipc, HAL_SERVICE_ID_GATT, HAL_EV_GATT_CLIENT_NOTIFY,
+ sizeof(*ev) + ev->len, ev);
+}
+
static void send_register_for_notification_ev(int32_t id, int32_t registered,
int32_t status,
const struct hal_gatt_srvc_id *srvc,
notification->notif_id = g_attrib_register(dev->attrib,
ATT_OP_HANDLE_NOTIFY,
c->ch.value_handle,
- NULL, notification,
+ handle_notification,
+ notification,
destroy_notification);
if (!notification->notif_id) {
free(notification);
notification->ind_id = g_attrib_register(dev->attrib, ATT_OP_HANDLE_IND,
c->ch.value_handle,
- NULL, notification,
+ handle_notification,
+ notification,
destroy_notification);
if (!notification->ind_id) {
g_attrib_unregister(dev->attrib, notification->notif_id);