summaryrefslogtreecommitdiff
path: root/monitor
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2013-02-02 11:19:09 +0100
committerMarcel Holtmann <marcel@holtmann.org>2013-02-02 11:21:50 +0100
commitf5c43df669bc978a982d54f1cddcfbc484432173 (patch)
tree89f1313e18b78b3fef77622b17a52472659a36df /monitor
parent37b90a9581a9a388d6c952549644eaf49fe91408 (diff)
monitor: Decode supported commands result
Diffstat (limited to 'monitor')
-rw-r--r--monitor/packet.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/monitor/packet.c b/monitor/packet.c
index 503da75ab..8de496513 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -1382,15 +1382,33 @@ static void print_manufacturer(uint16_t manufacturer)
bt_compidtostr(manufacturer), manufacturer);
}
+static const char *get_supported_command(int bit);
+
static void print_commands(const uint8_t *commands)
{
- char str[129];
- int i;
+ unsigned int count = 0;
+ int i, n;
+
+ for (i = 0; i < 64; i++) {
+ for (n = 0; n < 8; n++) {
+ if (commands[i] & (1 << n))
+ count++;
+ }
+ }
- for (i = 0; i < 64; i++)
- sprintf(str + (i * 2), "%2.2x", commands[i]);
+ print_field("Commands: %u entr%s", count, count == 1 ? "y" : "ies");
- print_field("Commands: 0x%s", str);
+ for (i = 0; i < 64; i++) {
+ for (n = 0; n < 8; n++) {
+ const char *cmd;
+
+ if (!(commands[i] & (1 << n)))
+ continue;
+
+ cmd = get_supported_command((i * 8) + n);
+ print_field(" %s (Octet %d - Bit %d)", cmd, i, n);
+ }
+ }
}
struct features_data {
@@ -4116,6 +4134,18 @@ static const struct opcode_data opcode_table[] = {
{ }
};
+static const char *get_supported_command(int bit)
+{
+ int i;
+
+ for (i = 0; opcode_table[i].str; i++) {
+ if (opcode_table[i].bit == bit)
+ return opcode_table[i].str;
+ }
+
+ return NULL;
+}
+
static void status_evt(const void *data, uint8_t size)
{
uint8_t status = *((uint8_t *) data);