Added feature : notification of GATT char Changed Value
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-gatt.c
index e6004d5..dbeed8c 100644 (file)
@@ -84,6 +84,7 @@ static void __bt_handle_gatt_client_read_desc(void *buf, uint16_t len);
 static void __bt_handle_gatt_client_write_char(void *buf, uint16_t len);
 static void __bt_handle_gatt_client_write_desc(void *buf, uint16_t len);
 static void __bt_handle_gatt_client_watch_notification(void *buf, uint16_t len);
+static void __bt_handle_gatt_client_changed_value(void *buf, uint16_t len);
 /*****************************************************************************************************/
 
 static bool interface_ready(void)
@@ -245,11 +246,30 @@ static void __bt_hal_handle_gatt_server_write_requested(void *buf, uint16_t len)
                                ev->is_prep, ev->value);
 }
 
+static void __bt_hal_handle_gatt_server_acquire_write_requested(void *buf, uint16_t len)
+{
+       struct hal_ev_gatt_server_acquire_write_res *ev = buf;
+
+       DBG("acquire write requested event recived");
+
+       if (bt_gatt_callbacks->server->request_acquire_write_cb)
+               bt_gatt_callbacks->server->request_acquire_write_cb(ev->mtu, ev->conn_id, ev->trans_id, ev->char_handl, (bt_bdaddr_t *)ev->bdaddr);
+}
+
+static void __bt_hal_handle_gatt_server_acquire_notify_requested(void *buf, uint16_t len)
+{
+       struct hal_ev_gatt_server_acquire_notify *ev = buf;
+
+       DBG("acquire notify  requested event recived");
+
+       if (bt_gatt_callbacks->server->request_acquire_notify_cb)
+               bt_gatt_callbacks->server->request_acquire_notify_cb(ev->mtu, ev->conn_id, ev->trans_id, ev->char_handl);
+}
+
 static void __bt_hal_handle_gatt_server_indicate_confirmed(void *buf, uint16_t len)
 {
        struct hal_ev_gatt_server_indicate_cfm *ev = buf;
 
-
        if (bt_gatt_callbacks->server->indication_confirmation_cb)
                bt_gatt_callbacks->server->indication_confirmation_cb(ev->conn_id, ev->trans_id,
                                ev->att_handle, (bt_bdaddr_t *) ev->bdaddr);
@@ -380,6 +400,19 @@ static void __bt_hal_gatt_events(int message, void *buf, uint16_t len)
                __bt_handle_gatt_client_watch_notification(buf, len);
                break;
        }
+       case HAL_EV_GATT_CLIENT_NOTIFY_CHANGED_VALUE: {
+               __bt_handle_gatt_client_changed_value(buf, len);
+               break;
+       }
+       case HAL_EV_GATT_SERVER_ACQUIRE_WRITE_RES:{
+               __bt_hal_handle_gatt_server_acquire_write_requested(buf, len);
+               break;
+       }
+       case HAL_EV_GATT_SERVER_ACQUIRE_NOTIFY_RES:{
+               __bt_hal_handle_gatt_server_acquire_notify_requested(buf, len);
+               break;
+       }
+
        default:
                DBG("Event Currently not handled!!");
                break;
@@ -603,6 +636,29 @@ static void __bt_handle_gatt_client_watch_notification(void *buf, uint16_t len)
                                ev->registered, ev->status, &gatt_srvc_id, &gatt_char_id);
 }
 
+static void __bt_handle_gatt_client_changed_value(void *buf, uint16_t len)
+{
+       struct hal_ev_gatt_client_notify_changed_value *ev = buf;
+       btgatt_notify_params_t changd_value_parm;
+
+       changd_value_parm.srvc_id.is_primary = ev->is_primary;
+       changd_value_parm.srvc_id.id.inst_id = ev->inst_id;
+       memcpy(changd_value_parm.srvc_id.id.uuid.uu, ev->svc_uuid, 16);
+
+       changd_value_parm.char_id.inst_id = ev->inst_id;
+       memcpy(changd_value_parm.char_id.uuid.uu, ev->char_uuid, 16);
+       changd_value_parm.is_notify = ev->is_notify;
+
+       memcpy(changd_value_parm.bda.address, ev->bdaddr, 6);
+
+       changd_value_parm.len = ev->len;
+       if (ev->len > 0)
+               memcpy(changd_value_parm.value, ev->value, ev->len);
+
+       if (bt_gatt_callbacks->client->notify_cb)
+               bt_gatt_callbacks->client->notify_cb(ev->conn_id, &changd_value_parm);
+}
+
 static bt_hal_le_adv_info_t *__bt_hal_get_adv_ind_info(char *addr)
 {
        GSList *l;