static void cmd_unregister_notify(struct client *cli, char *cmd_str) { char *argv[2]; int argc = 0; unsigned int id; char *endptr = NULL; if (!bt_gatt_client_is_ready(cli->gatt)) { printf("GATT client not initialized\n"); return; } if (!parse_args(cmd_str, 1, argv, &argc) || argc != 1) { unregister_notify_usage(); return; } id = strtol(argv[0], &endptr, 10); if (!endptr || *endptr != '\0' || !id) { printf("Invalid notify id: %s\n", argv[0]); return; } if (!bt_gatt_client_unregister_notify(cli->gatt, id)) { printf("Failed to unregister notify handler with id: %u\n", id); return; } printf("Unregistered notify handler with id: %u\n", id); }
static void notify_client_free(struct notify_client *client) { DBG("owner %s", client->owner); g_dbus_remove_watch(btd_get_dbus_connection(), client->watch); bt_gatt_client_unregister_notify(client->chrc->service->client->gatt, client->notify_id); free(client->owner); free(client); }
static DBusMessage *characteristic_stop_notify(DBusConnection *conn, DBusMessage *msg, void *user_data) { struct characteristic *chrc = user_data; struct bt_gatt_client *gatt = chrc->service->client->gatt; const char *sender = dbus_message_get_sender(msg); struct notify_client *client; if (!chrc->notifying) return btd_error_failed(msg, "Not notifying"); client = queue_remove_if(chrc->notify_clients, match_notify_sender, (void *) sender); if (!client) return btd_error_failed(msg, "No notify session started"); queue_remove(chrc->service->client->all_notify_clients, client); bt_gatt_client_unregister_notify(gatt, client->notify_id); update_notifying(chrc); notify_client_unref(client); return dbus_message_new_method_return(msg); }