diff options
author | Bruna Moreira <bruna.moreira@gmail.com> | 2013-12-18 16:35:40 -0400 |
---|---|---|
committer | Jefferson Delfes <jefferson.delfes@gmail.com> | 2013-12-23 11:08:03 -0400 |
commit | 2717d728c4f8b0999bbb89210dd004a6959c9592 (patch) | |
tree | 46dbe9372589ad39f487404d16fb8e0880e37fa8 | |
parent | d827a34ef97691eb15197640823b544eb6539cd1 (diff) |
Update rssi command for multiple connections
The connection ID was added in rssi command to add support for multiple
connections.
-rw-r--r-- | btctl.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -1972,18 +1972,30 @@ void read_remote_rssi_cb(int client_if, bt_bdaddr_t *bda, int rssi, static void cmd_rssi(char *args) { bt_status_t status; + connection_t *conn; + int conn_id; - if (u.conn_id <= 0) { - rl_printf("Not connected\n"); + if (u.gattiface == NULL) { + rl_printf("Unable to BLE RSSI: GATT interface not avaiable\n"); return; } - if (u.gattiface == NULL) { - rl_printf("Unable to BLE RSSI: GATT interface not avaiable\n"); + if (sscanf(args, " %i ", &conn_id) != 1) { + rl_printf("Usage: rssi <connection ID>\n"); + return; + } + + conn = get_connection(conn_id); + if (conn == NULL) { + rl_printf("Invalid connection ID\n"); + return; + } else if (conn_id == PENDING_CONN_ID) { + rl_printf("Connection is not active\n"); return; } - status = u.gattiface->client->read_remote_rssi(u.client_if, &u.remote_addr); + status = u.gattiface->client->read_remote_rssi(u.client_if, + &conn->remote_addr); if (status != BT_STATUS_SUCCESS) { rl_printf("Failed to request RSSI, status: %d\n", status); return; |