+
+static void _bt_hal_send_value_changed_event(hal_gattc_server_info_t *conn_info,
+ hal_gattc_service_t *svc_info, hal_gattc_char_t *char_info,
+ char *char_value, int len)
+{
+ struct hal_ev_gatt_client_notify_changed_value ev;
+ hal_gattc_client_info_t *gattc_client = NULL;
+
+ if (!event_cb) {
+ ERR("gatt client callback not registered");
+ return;
+ }
+
+ gattc_client = __bt_find_gatt_client_info(&conn_info->bd_addr);
+ if (NULL == gattc_client) {
+ ERR("failed to get the gatt client info");
+ return ;
+ }
+
+ //send event
+ DBG("sending gatt client connected status event");
+ memset(&ev, 0, sizeof(ev));
+
+ ev.conn_id = gattc_client->conn_id;
+ ev.inst_id = conn_info->inst_id;
+ ev.is_primary = svc_info->is_primary;
+ memcpy(ev.svc_uuid, svc_info->svc_uuid.uu, sizeof(ev.svc_uuid));
+ memcpy(ev.char_uuid, char_info->chr_uuid.uu, sizeof(ev.char_uuid));
+
+ memcpy(ev.bdaddr, conn_info->bd_addr.address, BT_HAL_ADDRESS_LENGTH_MAX);
+
+ if (len > 0 && (char_value != NULL)) {
+ memcpy(ev.value, char_value, len);
+ ev.len = len;
+ }
+
+ event_cb(HAL_EV_GATT_CLIENT_NOTIFY_CHANGED_VALUE, (void *)&ev, sizeof(ev));
+}
+
+void _bt_hal_handle_gattc_value_changed_event(int result, const char *char_handle,
+ char *char_value, int len)
+{
+ char device_address[BT_HAL_ADDRESS_STRING_SIZE] = { 0 };
+ hal_gattc_server_info_t *conn_info = NULL;
+ bt_bdaddr_t bd_addr;
+ GSList *l;
+ GSList *k;
+ hal_gattc_service_t *svc_info = NULL;
+ hal_gattc_char_t *char_info = NULL;
+
+ DBG("+");
+
+ _bt_hal_convert_device_path_to_address(char_handle, device_address);
+ device_address[BT_HAL_ADDRESS_STRING_SIZE - 1] = '\0';
+ DBG("device address:[%s]", device_address);
+ DBG("char handle:[%s]", char_handle);
+
+ _bt_hal_convert_addr_string_to_type(bd_addr.address, device_address);
+ conn_info = __bt_find_gatt_conn_info(&bd_addr);
+
+ //find service for notified char path
+ for (l = conn_info->gatt_list_services; l != NULL; l = g_slist_next(l)) {
+ svc_info = (hal_gattc_service_t*)l->data;
+ if (svc_info == NULL)
+ continue;
+
+ /* find characteristic object path */
+ for (k = svc_info->gatt_list_chars; k != NULL; k = g_slist_next(k)) {
+ char_info = (hal_gattc_char_t *)k->data;
+ if (char_info == NULL)
+ continue;
+
+ if (g_strcmp0(char_info->chr_path, char_handle) == 0) {
+ DBG("Found char handle[%s]", char_info->chr_path);
+
+ //send event
+ _bt_hal_send_value_changed_event(conn_info, svc_info,
+ char_info, char_value, len);
+ return;
+ }
+ }
+ }
+}