Take BLE Advertising Interval min & max parameters in 0.625ms unit 15/247215/1 accepted/tizen/unified/20201111.124819 submit/tizen/20201109.212850
authorAyush Garg <ayush.garg@samsung.com>
Sat, 7 Nov 2020 06:44:42 +0000 (12:14 +0530)
committerAyush Garg <ayush.garg@samsung.com>
Sat, 7 Nov 2020 06:44:42 +0000 (12:14 +0530)
Till now, the Ble advertsing interval min and max values were taken in the ms unit.
According to specs, the actual time value can be in decimal (ex: 28.125ms) but such cases are not properly handled currently.
So these changes will allow to take input in 0.625ms units.

Change-Id: Ia052cdc456aae067a6a453eac0a3780b9c59e9fd
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
bt-oal/bluez_hal/src/bt-hal-adapter-le.c
bt-service/services/bt-request-handler.c
include/bluetooth-api.h
test/le-adv/bluetooth-advertising-test.c [changed mode: 0755->0644]

index b1b4b1a..0d39c95 100644 (file)
@@ -83,8 +83,8 @@ typedef struct {
 #define BT_HAL_ADV_NON_CONNECTABLE  0x03 /* ADV_NONCOND_IND */
 #define BT_HAL_ADV_CONNECTABLE_DIRECT_LOW  0x04 /* ADV_DIRECT_IND, low duty cycle */
 
-#define BT_HAL_ADV_INTERVAL_MIN 20 /* msec */
-#define BT_HAL_ADV_INTERVAL_MAX 10240
+#define BT_HAL_ADV_INTERVAL_MIN 32 /* in 0.625ms unit */
+#define BT_HAL_ADV_INTERVAL_MAX 16384
 #define BT_HAL_ADV_INTERVAL_SPLIT 0.625
 #define BT_HAL_DEFAULT_ADV_MIN_INTERVAL 500
 #define BT_HAL_DEFAULT_ADV_MAX_INTERVAL 500
@@ -668,8 +668,6 @@ int _bt_hal_set_advertising_params(int server_if, int min_interval,
        GDBusProxy *proxy;
        GVariant *ret;
        GError *error = NULL;
-       guint32 min = 0;
-       guint32 max = 0;
        bt_hal_adv_event_data_t *event;
        int slot_id = 0;
 
@@ -694,13 +692,10 @@ int _bt_hal_set_advertising_params(int server_if, int min_interval,
                adv_filter_policy = BT_HAL_ADV_FILTER_POLICY_DEFAULT;
        }
 
-       min = min_interval / BT_HAL_ADV_INTERVAL_SPLIT;
-       max = max_interval / BT_HAL_ADV_INTERVAL_SPLIT;
-
        slot_id = bt_hal_gatts_allocate_adv_slot_by_server_if(server_if);
 
        ret = g_dbus_proxy_call_sync(proxy, "SetAdvertisingParameters",
-                       g_variant_new("(uuuuii)", min, max,
+                       g_variant_new("(uuuuii)", min_interval, max_interval,
                        adv_filter_policy, adv_type,
                        tx_power, slot_id), G_DBUS_CALL_FLAGS_NONE,
                        -1, NULL, &error);
index ae7dee0..bf5a1f9 100644 (file)
@@ -2331,7 +2331,7 @@ int __bt_bluez_request(int function_name,
                __bt_service_get_parameters(in_param4, &use_reserved_slot,
                                sizeof(gboolean));
 
-               BT_DBG("bluetooth_advertising_params_t [%f %f %d %d %d]",
+               BT_DBG("bluetooth_advertising_params_t [%d %d %d %d %d]",
                                adv_params.interval_min, adv_params.interval_max,
                                adv_params.filter_policy, adv_params.type, adv_params.tx_power_level);
                result = _bt_set_custom_advertising(app, *adv_handle,
index 273835a..59d1c9a 100644 (file)
@@ -606,8 +606,8 @@ typedef struct {
 * Advertising parameters
 */
 typedef struct {
-       float interval_min;
-       float interval_max;
+       int interval_min;
+       int interval_max;
        guint8 filter_policy;
        guint8 type;
        int tx_power_level;
old mode 100755 (executable)
new mode 100644 (file)
index ffc9294..9b7488c
@@ -110,16 +110,16 @@ int test_input_callback(void *data)
                break;
        case 3:
                TC_PRT("SetCustomAdvertising ON, Filter 0x03");
-               params.interval_min = 1280;
-               params.interval_max = 1280;
+               params.interval_min = 2048; /* equals 1280ms */
+               params.interval_max = 2048;
                params.filter_policy = 0x03;
                params.type = 0x00;
                ret = bluetooth_set_custom_advertising(0, TRUE, &params);
                break;
        case 4:
                TC_PRT("SetCustomAdvertising ON, Filter 0x00");
-               params.interval_min = 1280;
-               params.interval_max = 1280;
+               params.interval_min = 2048; /* equals 1280ms */
+               params.interval_max = 2048;
                params.filter_policy = 0x00;
                params.type = 0x00;
                ret = bluetooth_set_custom_advertising(0, TRUE, &params);
@@ -300,7 +300,7 @@ void bt_event_callback(int event, bluetooth_event_param_t* param,
 
        case BLUETOOTH_EVENT_ADVERTISING_STARTED:
                TC_PRT("BLUETOOTH_EVENT_ADVERTISING_STARTED, result [0x%04x], "
-                               "interval_min [%f ms], interval_max [%f ms]",
+                               "interval_min [%d (0.625ms units)], interval_max [%d (0.625ms units)]",
                                param->result,
                                ((bluetooth_advertising_params_t *)param->param_data)->interval_min,
                                ((bluetooth_advertising_params_t *)param->param_data)->interval_max);