gap: Don't attempt to read the appearance if already set
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 4 Apr 2022 20:15:18 +0000 (13:15 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
Devices are unlikely to change appearance over time which is the reason
why we cache then on the storage so this skips reading it on every
reconnection.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/gap/gas.c

index 2125b72..9c4e4a4 100755 (executable)
@@ -141,6 +141,11 @@ static void read_appearance_cb(bool success, uint8_t att_ecode,
 
 static void handle_appearance(struct gas *gas, uint16_t value_handle)
 {
+       uint16_t value;
+
+       if (!device_get_appearance(gas->device, &value))
+               return;
+
        if (!bt_gatt_client_read_value(gas->client, value_handle,
                                                read_appearance_cb, gas, NULL))
                DBG("Failed to send request to read appearance");