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)
ev->connected, &bd_addr);
}
+static void __bt_hal_handle_gatt_server_notification_changed(void *buf, uint16_t len)
+{
+ struct hal_ev_gatt_server_notifcation_change *ev = buf;
+ bt_bdaddr_t bd_addr;
+
+ memcpy(bd_addr.address, ev->bdaddr, 6);
+
+ if (bt_gatt_callbacks->server->notif_enabled_cb)
+ bt_gatt_callbacks->server->notif_enabled_cb(ev->conn_id, ev->trans_id,
+ ev->att_handle, ev->notify, &bd_addr);
+}
+
static void __bt_hal_handle_gatt_server_read_requested(void *buf, uint16_t len)
{
struct hal_ev_gatt_server_read_req *ev = buf;
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);
__bt_hal_handle_gatt_server_connected(buf, len);
break;
}
+ case HAL_EV_GATT_NOTIFICATION_CHANGE: {
+ __bt_hal_handle_gatt_server_notification_changed(buf, len);
+ break;
+ }
case HAL_EV_GATT_READ_REQUESTED: {
__bt_hal_handle_gatt_server_read_requested(buf, len);
break;
__bt_handle_gatt_client_write_desc(buf, len);
break;
}
+ case HAL_EV_GATT_CLIENT_WATCH_NOTIFICATION: {
+ __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;
ev->status, &desc_write_parm);
}
+static void __bt_handle_gatt_client_watch_notification(void *buf, uint16_t len)
+{
+ struct hal_ev_gatt_client_watch_notification *ev = buf;
+ btgatt_srvc_id_t gatt_srvc_id;
+ btgatt_gatt_id_t gatt_char_id;
+
+ gatt_srvc_id.is_primary = ev->is_primary;
+ gatt_srvc_id.id.inst_id = ev->inst_id;
+ memcpy(gatt_srvc_id.id.uuid.uu, ev->svc_uuid, 16);
+
+ memcpy(gatt_char_id.uuid.uu, ev->char_uuid, 16);
+ gatt_char_id.inst_id = ev->inst_id;
+
+ if (bt_gatt_callbacks->client->register_for_notification_cb)
+ bt_gatt_callbacks->client->register_for_notification_cb(ev->client_if,
+ 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;