From add3e20aceeffc19819a455a7c1af2d7e41138f4 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 29 Dec 2013 18:34:36 -0800 Subject: [PATCH] monitor: Decode detailed AFH channel list --- monitor/packet.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/monitor/packet.c b/monitor/packet.c index d9681fe29..473ab8d66 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -1943,13 +1943,34 @@ static void print_name(const uint8_t *name) static void print_channel_map(const uint8_t *map) { + unsigned int count = 0, start = 0; char str[21]; - int i; + int i, n; for (i = 0; i < 10; i++) sprintf(str + (i * 2), "%2.2x", map[i]); print_field("Channel map: 0x%s", str); + + for (i = 0; i < 10; i++) { + for (n = 0; n < 8; n++) { + if (map[i] & (1 << n)) { + if (count == 0) + start = (i * 8) + n; + count++; + continue; + } + + if (count > 1) { + print_field(" Channel %u-%u", + start, start + count - 1 ); + count = 0; + } else if (count > 0) { + print_field(" Channel %u", start); + count = 0; + } + } + } } static void print_flush_timeout(uint16_t timeout) -- 2.47.3