Fix the issue that previously set scan resp data was not removed 26/292926/1
authorWootak Jung <wootak.jung@samsung.com>
Wed, 17 May 2023 05:42:00 +0000 (14:42 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Wed, 17 May 2023 06:04:41 +0000 (15:04 +0900)
reproduction steps:
1. create 1st advertiser and fill scan resp data
2. start advertising by 1st advertiser
3. stop 1st advertiser
4. create 2nd advertiser and don't fill scan resp data
5. start advertising by 2nd advertiser
6. 1st scan resp data was not removed

Change-Id: Icb144e25fd67f3aa5bd488ee3a1f05c99d152501
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
bt-oal/bluez_hal/src/bt-hal-adapter-le.c

index fedc21b..d192d33 100644 (file)
@@ -916,6 +916,17 @@ int _bt_hal_set_advertising_data(btgatt_adv_param_setup_t adv_param_setup)
                                g_variant_new("(@ayi)", temp, slot_id),
                                G_DBUS_CALL_FLAGS_NONE,
                                -1, NULL, &error);
+
+               builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
+               temp = g_variant_new("ay", builder);
+               g_variant_builder_unref(builder);
+
+               /* If there is no scan response data, explicitly set the empty value.
+                * Oherwise, previously set (stopped) scan resp may be used */
+               ret = g_dbus_proxy_call_sync(proxy, "SetScanRespData",
+                               g_variant_new("(@ayi)", temp, slot_id),
+                               G_DBUS_CALL_FLAGS_NONE,
+                               -1, NULL, &error);
        } else {
                /* Set Scan response data to stack */
                ret = g_dbus_proxy_call_sync(proxy, "SetScanRespData",
@@ -930,7 +941,7 @@ int _bt_hal_set_advertising_data(btgatt_adv_param_setup_t adv_param_setup)
                return BT_STATUS_FAIL;
        }
 
-       INFO("Request of SetAdvertisingData or SetScanRespData is success");
+       INFO("Request of %s is success", adv_param_setup.set_scan_rsp ? "SetScanRespData" : "SetAdvertisingData");
 
        if (ret)
                g_variant_unref(ret);