summaryrefslogtreecommitdiff
path: root/monitor
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-05-26 13:47:13 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-05-26 13:57:48 -0700
commit53c28e3d868396fe5676751a44171dd67a7255a0 (patch)
tree59365db378271ea5e7bd09e2c46857effe698664 /monitor
parent1ffd74a6d4212a165763dc53e58a1b49b6fc5a98 (diff)
downloadbluez-53c28e3d868396fe5676751a44171dd67a7255a0.tar.gz
monitor/att: Simplify CCC decoders
This simplify callbacks moving the decoding of the value to print_ccc_value.
Diffstat (limited to 'monitor')
-rw-r--r--monitor/att.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/monitor/att.c b/monitor/att.c
index df3e65057..0223af210 100644
--- a/monitor/att.c
+++ b/monitor/att.c
@@ -221,38 +221,30 @@ static const struct bitfield_data ccc_value_table[] = {
{ }
};
-static void print_ccc_value(uint8_t value)
-{
- uint8_t mask = value;
-
- mask = print_bitfield(4, value, ccc_value_table);
- if (mask)
- print_text(COLOR_WHITE_BG, " Unknown fields (0x%2.2x)",
- mask);
-}
-
-static void gatt_ccc_read(const struct l2cap_frame *frame)
+static void print_ccc_value(const struct l2cap_frame *frame)
{
uint8_t value;
+ uint8_t mask;
if (!l2cap_frame_get_u8((void *)frame, &value)) {
print_text(COLOR_ERROR, "invalid size");
return;
}
- print_ccc_value(value);
+ mask = print_bitfield(4, value, ccc_value_table);
+ if (mask)
+ print_text(COLOR_WHITE_BG, " Unknown fields (0x%2.2x)",
+ mask);
}
-static void gatt_ccc_write(const struct l2cap_frame *frame)
+static void ccc_read(const struct l2cap_frame *frame)
{
- uint8_t value;
-
- if (!l2cap_frame_get_u8((void *)frame, &value)) {
- print_text(COLOR_ERROR, "invalid size");
- return;
- }
+ print_ccc_value(frame);
+}
- print_ccc_value(value);
+static void ccc_write(const struct l2cap_frame *frame)
+{
+ print_ccc_value(frame);
}
#define GATT_HANDLER(_uuid, _read, _write, _notify) \
@@ -272,8 +264,7 @@ struct gatt_handler {
void (*write)(const struct l2cap_frame *frame);
void (*notify)(const struct l2cap_frame *frame);
} gatt_handlers[] = {
- GATT_HANDLER(GATT_CLIENT_CHARAC_CFG_UUID, gatt_ccc_read,
- gatt_ccc_write, NULL)
+ GATT_HANDLER(0x2902, ccc_read, ccc_write, NULL),
};
static struct gatt_handler *get_handler(struct gatt_db_attribute *attr)