diff options
author | Jefferson Delfes <jefferson.delfes@gmail.com> | 2013-12-19 10:24:30 -0400 |
---|---|---|
committer | Jefferson Delfes <jefferson.delfes@gmail.com> | 2013-12-23 10:27:28 -0400 |
commit | eb16a10fca58f0518bd0f6552a3db1ee4f277ea2 (patch) | |
tree | 4c43a2eac6c52081a48ada1683b44e98d6ad5a3a | |
parent | 93a89fe7099ed4ceb811b810e18f8318a8466eeb (diff) |
Add connections command
In order to support multiple connections, we need to pass connection ID
to every command that issues some procedure over GATT.
So connections command will list every active connection with connection
ID and remote address.
-rw-r--r-- | btctl.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -1885,6 +1885,26 @@ static void cmd_rssi(char *args) { } } +static void cmd_conns(char *args) { + int i, c = 0; + + for (i = 0; i < MAX_CONNECTIONS; i++) { + connection_t *conn = &u.conns[i]; + char addr_str[BT_ADDRESS_STR_LEN]; + + if (conn->conn_id <= INVALID_CONN_ID) + continue; + + rl_printf("Connection ID: %i Address: %s%s\n", conn->conn_id, + ba2str(conn->remote_addr.address, addr_str), + conn->conn_id == PENDING_CONN_ID ? " (pending)" : ""); + c++; + } + + if (c == 0) + rl_printf("No connections active\n"); +} + /* List of available user commands */ static const cmd_t cmd_list[] = { { "quit", " Exits", cmd_quit }, @@ -1911,6 +1931,7 @@ static const cmd_t cmd_list[] = { { "unreg-notif", " Unregister a previous request to receive " "notification/indicaton", cmd_unreg_notification }, { "rssi", " Request RSSI for connected device", cmd_rssi }, + { "connections", " Display active connections", cmd_conns }, { NULL, NULL, NULL } }; |