summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruna Moreira <bruna.moreira@gmail.com>2013-12-18 16:07:01 -0400
committerJefferson Delfes <jefferson.delfes@gmail.com>2013-12-23 11:08:03 -0400
commitd827a34ef97691eb15197640823b544eb6539cd1 (patch)
tree6802c9578fdddc855e9d452ba70d01327ef9be39
parent39232306910e88a6d545d64b1443dda867c686b4 (diff)
Update read-desc command for multiple connections
The connection ID was added in read-desc command to add support for multiple connections.
-rw-r--r--btctl.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/btctl.c b/btctl.c
index e2c64df..d01bb63 100644
--- a/btctl.c
+++ b/btctl.c
@@ -1764,38 +1764,40 @@ static void cmd_read_desc(char *args) {
service_info_t *svc_info;
char_info_t *char_info;
bt_uuid_t *descr_uuid;
- int svc_id, char_id, desc_id, auth;
+ connection_t *conn;
+ int svc_id, char_id, desc_id, auth, conn_id;
- if (u.conn_id <= 0) {
- rl_printf("Not connected\n");
+ if (u.gattiface == NULL) {
+ rl_printf("Unable to BLE read-desc: GATT interface not avaiable\n");
return;
}
- if (u.gattiface == NULL) {
- rl_printf("Unable to BLE read-desc: GATT interface not avaiable\n");
+ if (sscanf(args, " %i %i %i %i %i ", &conn_id, &svc_id, &char_id, &desc_id,
+ &auth) != 5) {
+ rl_printf("Usage: read-desc <connection ID> <serviceID> "
+ "<characteristicID> <descriptorID> <auth>\n");
+ rl_printf(" auth - enable authentication (1) or not (0)\n");
return;
}
- if (u.svcs_size <= 0) {
- rl_printf("Run search-svc first to get all services list\n");
+ conn = get_connection(conn_id);
+ if (conn == NULL) {
+ rl_printf("Invalid connection ID\n");
return;
}
- if (sscanf(args, " %i %i %i %i ", &svc_id, &char_id, &desc_id,
- &auth) != 4) {
- rl_printf("Usage: read-desc serviceID characteristicID descriptorID "
- "auth\n");
- rl_printf(" auth - enable authentication (1) or not (0)\n");
+ if (conn->svcs_size <= 0) {
+ rl_printf("Run search-svc first to get all services list\n");
return;
}
- if (svc_id < 0 || svc_id >= u.svcs_size) {
+ if (svc_id < 0 || svc_id >= conn->svcs_size) {
rl_printf("Invalid serviceID: %i need to be between 0 and %i\n", svc_id,
- u.svcs_size - 1);
+ conn->svcs_size - 1);
return;
}
- svc_info = &u.svcs[svc_id];
+ svc_info = &conn->svcs[svc_id];
if (char_id < 0 || char_id >= svc_info->char_count) {
rl_printf("Invalid characteristicID, try to run characteristics "
"command.\n");
@@ -1809,7 +1811,8 @@ static void cmd_read_desc(char *args) {
}
descr_uuid = &char_info->descrs[desc_id];
- status = u.gattiface->client->read_descriptor(u.conn_id, &svc_info->svc_id,
+ status = u.gattiface->client->read_descriptor(conn->conn_id,
+ &svc_info->svc_id,
&char_info->char_id,
descr_uuid, auth);
if (status != BT_STATUS_SUCCESS) {