monitor: Stop spamming logs when GATT db cannot be loaded
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 2 Jun 2022 21:18:52 +0000 (14:18 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
This stops calling hci_devba everytime the GATT db needs to be loaded
since that causes a raw socket to be open to read back the address
pointed by the index, instead this is done only once at assign_handle
and store in packet_conn_data.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
monitor/att.c
monitor/packet.c
monitor/packet.h

index 98b70f6..a3baeff 100644 (file)
@@ -1227,7 +1227,6 @@ static void load_gatt_db(struct packet_conn_data *conn)
 {
        struct att_conn_data *data = conn->data;
        char filename[PATH_MAX];
-       bdaddr_t src;
        char local[18];
        char peer[18];
 
@@ -1242,10 +1241,7 @@ static void load_gatt_db(struct packet_conn_data *conn)
        if (!gatt_db_isempty(data->ldb) && !gatt_db_isempty(data->rdb))
                return;
 
-       if (hci_devba(conn->index, &src) < 0)
-               return;
-
-       ba2str(&src, local);
+       ba2str((bdaddr_t *)conn->src, local);
        ba2str((bdaddr_t *)conn->dst, peer);
 
        if (gatt_db_isempty(data->ldb)) {
index 98dda9e..9a2611a 100755 (executable)
@@ -177,6 +177,9 @@ static void assign_handle(uint16_t index, uint16_t handle, uint8_t type,
 
        for (i = 0; i < MAX_CONN; i++) {
                if (conn_list[i].handle == 0x0000) {
+                       if (hci_devba(index, (bdaddr_t *)conn_list[i].src) < 0)
+                               return;
+
                        conn_list[i].index = index;
                        conn_list[i].handle = handle;
                        conn_list[i].type = type;
index f942974..fbc878f 100755 (executable)
@@ -25,6 +25,7 @@
 
 struct packet_conn_data {
        uint16_t index;
+       uint8_t  src[6];
        uint16_t handle;
        uint8_t  type;
        uint8_t  dst[6];