static DBusMessage *characteristic_read_value(DBusConnection *conn, DBusMessage *msg, void *user_data) { struct characteristic *chrc = user_data; struct bt_gatt_client *gatt = chrc->service->client->gatt; struct async_dbus_op *op; if (chrc->read_id) return btd_error_in_progress(msg); op = new0(struct async_dbus_op, 1); if (!op) return btd_error_failed(msg, "Failed to initialize request"); op->msg = dbus_message_ref(msg); op->data = chrc; chrc->read_id = bt_gatt_client_read_value(gatt, chrc->value_handle, chrc_read_cb, async_dbus_op_ref(op), async_dbus_op_unref); if (chrc->read_id) return NULL; async_dbus_op_free(op); return btd_error_failed(msg, "Failed to send read request"); }
static DBusMessage *descriptor_read_value(DBusConnection *conn, DBusMessage *msg, void *user_data) { struct descriptor *desc = user_data; struct bt_gatt_client *gatt = desc->chrc->service->client->gatt; struct async_dbus_op *op; if (!gatt) return btd_error_failed(msg, "Not connected"); if (desc->read_id) return btd_error_in_progress(msg); op = new0(struct async_dbus_op, 1); op->msg = dbus_message_ref(msg); op->data = desc; desc->read_id = bt_gatt_client_read_value(gatt, desc->handle, desc_read_cb, async_dbus_op_ref(op), async_dbus_op_unref); if (desc->read_id) return NULL; async_dbus_op_free(op); return btd_error_failed(msg, "Failed to send read request"); }
static void cmd_read_value(struct client *cli, char *cmd_str) { char *argv[2]; int argc = 0; uint16_t handle; 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) { read_value_usage(); return; } handle = strtol(argv[0], &endptr, 16); if (!endptr || *endptr != '\0' || !handle) { printf("Invalid value handle: %s\n", argv[0]); return; } if (!bt_gatt_client_read_value(cli->gatt, handle, read_cb, NULL, NULL)) printf("Failed to initiate read value procedure\n"); }
static void handle_pnpid(struct btd_device *device, uint16_t value_handle) { struct bt_gatt_client *client = btd_device_get_gatt_client(device); if (!bt_gatt_client_read_value(client, value_handle, read_pnpid_cb, device, NULL)) DBG("Failed to send request to read pnpid"); }
static void read_ext_props(void *data, void *user_data) { struct characteristic *chrc = data; bt_gatt_client_read_value(chrc->service->client->gatt, chrc->ext_props_handle, read_ext_props_cb, chrc, NULL); }
static void handle_appearance(struct gas *gas, uint16_t value_handle) { if (!bt_gatt_client_read_value(gas->client, value_handle, read_appearance_cb, gas, NULL)) DBG("Failed to send request to read appearance"); }