return NULL;
}
+static char *__bt_get_server_app_path_from_server(int instance)
+{
+ GSList *l;
+ INFO("Number of GATT Server apps [%d]", g_slist_length(gatt_server_apps));
+ INFO("Find App with slot [%d]", instance);
+
+ for (l = gatt_server_apps; l; l = g_slist_next(l)) {
+ struct gatt_server_app *app = (struct gatt_server_app *)l->data;
+
+ if (app->slot == instance) {
+ INFO("App slot [%d] Found, App path [%s]",
+ app->slot, app->app_path);
+ return app->app_path;
+ }
+ }
+ return NULL;
+}
+
static void _bt_remote_service_from_gatt_server(int instance, int service_handle)
{
GSList *l;
g_dbus_method_invocation_return_value(invocation, NULL);
}
-static gboolean __bt_hal_gatt_emit_interface_removed(gchar *object_path, gchar *interface)
+static gboolean __bt_hal_gatt_emit_interface_removed(const char *app_path, gchar *object_path, gchar *interface)
{
gboolean ret;
GError *error = NULL;
g_variant_builder_init(array_builder, G_VARIANT_TYPE("as"));
g_variant_builder_add(array_builder, "s", interface);
- ret = g_dbus_connection_emit_signal(g_conn, NULL, "/",
- "org.freedesktop.Dbus.Objectmanager",
+ ret = g_dbus_connection_emit_signal(g_conn, NULL, app_path,
+ "org.freedesktop.DBus.ObjectManager",
"InterfacesRemoved",
g_variant_new("(oas)",
object_path, array_builder),
GATT_SERV_INTERFACE, inner_builder);
ret = g_dbus_connection_emit_signal(g_conn, NULL, "/",
- "org.freedesktop.Dbus.ObjectManager",
+ "org.freedesktop.Dbus.ObjectManager", // TODO: need to check Dbus is working or not
"InterfacesAdded",
g_variant_new("(oa{sa{sv}})",
path, builder),
app->slot = slot;
gatt_server_apps = g_slist_append(gatt_server_apps, app);
INFO("GATT Server: Path [%s] Slot [%d]-> Updated", app_path, slot);
-
}
-
static bt_status_t gatt_server_add_service(int server_if, btgatt_srvc_id_t *srvc_id,
int num_handles)
{
GSList *l1 = NULL;
int err = BT_STATUS_SUCCESS;
int ret = BT_STATUS_SUCCESS;
+ char *app_path = NULL;
INFO("Slot [%d] service handle [%d]", server_if, service_handle);
/* Fetch service data for the GATT server */
return BT_STATUS_FAIL;
}
+ app_path = __bt_get_server_app_path_from_server(server_if);
+ if (app_path == NULL) {
+ ERR("Could not find service info svc handle [%d] server slot [%d]",
+ service_handle, server_if);
+ return BT_STATUS_FAIL;
+ }
+
if (serv_info->is_svc_registered == FALSE) {
ERR("service Not registered path [%s] handle [%d]",
serv_info->serv_path, service_handle);
desc_info->desc_id);
if (ret) {
__bt_hal_gatt_emit_interface_removed(
+ app_path,
desc_info->desc_path,
GATT_DESC_INTERFACE);
} else {
ret = g_dbus_connection_unregister_object(g_conn,
char_info->char_id);
if (ret) {
- __bt_hal_gatt_emit_interface_removed(char_info->char_path,
+ __bt_hal_gatt_emit_interface_removed(app_path, char_info->char_path,
GATT_CHAR_INTERFACE);
} else {
INFO("Err");
ret = g_dbus_connection_unregister_object(g_conn, serv_info->serv_id);
if (ret) {
- __bt_hal_gatt_emit_interface_removed(serv_info->serv_path,
+ __bt_hal_gatt_emit_interface_removed(app_path, serv_info->serv_path,
GATT_SERV_INTERFACE);
} else {
INFO("Failed!!");