Add support for custom advertising flags. 74/295574/1 accepted/tizen/7.0/unified/20230719.021526
authorJakub Latusek <j.latusek@samsung.com>
Wed, 1 Feb 2023 06:00:13 +0000 (15:00 +0900)
committerAnuj Kumar Singh <anujk.singh@samsung.com>
Mon, 10 Jul 2023 10:01:55 +0000 (15:31 +0530)
It is required to set proper advertising flags when establishing a
connection using
Bluetooth low energy to properly recognize device type.
Without this, the Linux device cannot recognize the Tizen device
properly and establish a connection.

Change-Id: I2dcbcd053a8de4c4954653ae8a5f55fbed775f66
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
Signed-off-by: Jakub Latusek <j.latusek@samsung.com>
src/adapter.c

index 77cbd9d5518fb2518a7f67564ad092df7bf8c09a..ae7d15d33857b71ed20c5fd4044248f77aab8e66 100644 (file)
@@ -4287,10 +4287,26 @@ gboolean adapter_le_set_platform_scan_filter_data(struct btd_adapter *adapter,
 }
 #endif
 
+static bool is_set_adv_data_flag(uint8_t *data, int data_len)
+{
+       int adv_type;
+       for (int i = 0; i < data_len; i++) {
+               adv_type = data[i + 1];
+               if (adv_type == EIR_FLAGS)
+                       return true;
+               else
+                       i = i + data[i];
+       }
+       return false;
+}
+
 static int set_adv_data_flag(uint8_t *adv_data, uint8_t *data, int data_len, void *user_data)
 {
        struct btd_adapter *adapter = user_data;
 
+       if (is_set_adv_data_flag(data, data_len))
+               return data_len;
+
        adv_data[0] = 2;
        adv_data[1] = EIR_FLAGS;
 
@@ -4298,12 +4314,10 @@ static int set_adv_data_flag(uint8_t *adv_data, uint8_t *data, int data_len, voi
                adv_data[2] = EIR_GEN_DISC | EIR_CONTROLLER |
                                EIR_SIM_HOST | EIR_BREDR_UNSUP;
        else {
-#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
                if (TIZEN_FEATURE_BLUEZ_DA) {
                        DBG("Disable LE General Discoverable Mode");
                        adv_data[2] = EIR_CONTROLLER | EIR_SIM_HOST;
                } else
-#endif
                        adv_data[2] = EIR_GEN_DISC | EIR_CONTROLLER | EIR_SIM_HOST;
        }
 
@@ -4778,8 +4792,13 @@ static DBusMessage *adapter_set_advertising_data(DBusConnection *conn,
                        DBUS_TYPE_INVALID))
                return btd_error_invalid_args(msg);
 
-       if (len > ADV_DATA_MAX_LENGTH - 3)
-               return btd_error_invalid_args(msg);
+       if (is_set_adv_data_flag(value, len)) {
+               if (len > ADV_DATA_MAX_LENGTH)
+                       return btd_error_invalid_args(msg);
+       } else {
+               if (len > ADV_DATA_MAX_LENGTH - 3)
+                       return btd_error_invalid_args(msg);
+       }
 
        if (adapter->le_static_addr.b[5] != 0) {
                char *ptr = NULL;