diff --git a/monitor/packet.c b/monitor/packet.c
index 503da75..8de4965 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
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 {
{ }
};
+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);