Add the Auto Connection mode for headless device 25/120225/3
authorLee Hyuk <hyuk0512.lee@samsung.com>
Wed, 22 Mar 2017 06:37:38 +0000 (15:37 +0900)
committerLee Hyuk <hyuk0512.lee@samsung.com>
Thu, 23 Mar 2017 07:24:27 +0000 (16:24 +0900)
Change-Id: I08207bba60628d92d63a424cb3e1302d11182f67
Signed-off-by: Lee Hyuk <hyuk0512.lee@samsung.com>
packaging/bluez.spec
src/adapter.c
src/hcid.h
src/main.c
src/main_m.conf
src/main_w.conf

index 1786dc1..fdc16b5 100644 (file)
@@ -270,7 +270,6 @@ install --mode 0755 -d $RPM_BUILD_ROOT/var/lib/bluetooth
 install -D -m 0644 src/main_w.conf %{buildroot}%{_sysconfdir}/bluetooth/main.conf.wearable
 install -D -m 0644 src/main_m.conf %{buildroot}%{_sysconfdir}/bluetooth/main.conf
 
-
 #install -D -m 0644 src/bluetooth.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/bluetooth.conf
 #install -D -m 0644 profiles/audio/audio.conf %{buildroot}%{_sysconfdir}/bluetooth/audio.conf
 #install -D -m 0644 profiles/network/network.conf %{buildroot}%{_sysconfdir}/bluetooth/network.conf
index b2c88ca..b82d330 100644 (file)
@@ -323,6 +323,8 @@ struct btd_adapter {
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        uint8_t central_rpa_res_support;
        bluetooth_a2dp_role_t a2dp_role;
+       bool auto_pairing;
+       char *pin_code;
 #ifdef TIZEN_FEATURE_PLATFROM_SCAN_FILTER
        bool scan_filter_support;               /* platform's scan filtering support */
        uint8_t scan_type;              /* scan type */
@@ -538,6 +540,7 @@ static void store_adapter_info(struct btd_adapter *adapter)
        if (adapter->stored_alias)
                g_key_file_set_string(key_file, "General", "Alias",
                                                        adapter->stored_alias);
+
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        /* Store A2DP Role */
        if (adapter->a2dp_role == BLUETOOTH_A2DP_SINK_ROLE)
@@ -545,6 +548,7 @@ static void store_adapter_info(struct btd_adapter *adapter)
        else
                g_key_file_set_string(key_file, "General", "DefaultA2DPRole", "source");
 #endif
+
        ba2str(&adapter->bdaddr, address);
        snprintf(filename, PATH_MAX, STORAGEDIR "/%s/settings", address);
 
@@ -9481,6 +9485,8 @@ static struct btd_adapter *btd_adapter_new(uint16_t index)
        adapter->pairable_timeout = main_opts.pairto;
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        adapter->advertising = FALSE;
+       adapter->auto_pairing = main_opts.auto_pairing;
+       adapter->pin_code = main_opts.pin_code;
 #endif
 
        DBG("System name: %s", adapter->system_name);
@@ -11294,7 +11300,14 @@ static void pin_code_request_callback(uint16_t index, uint16_t length,
                }
                return;
        }
-
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       /* check auto pairing mode */
+       if (adapter->auto_pairing) {
+               btd_adapter_pincode_reply(adapter, &ev->addr.bdaddr,
+                                               adapter->pin_code, adapter->pin_code ? strlen(adapter->pin_code) : 0);
+               return;
+       }
+#endif
        err = device_request_pincode(device, ev->secure);
        if (err < 0) {
                btd_error(adapter->dev_id, "device_request_pin: %s",
index 3a52b65..e747590 100644 (file)
@@ -41,6 +41,8 @@ struct main_opts {
        gboolean        fast_conn;
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        gboolean        le_privacy;
+       gboolean        auto_pairing;
+       char            *pin_code;
 #endif
 
        uint16_t        did_source;
index 32facab..64bd72d 100644 (file)
@@ -91,6 +91,8 @@ static const char * const supported_options[] = {
        "MultiProfile",
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        "EnableLEPrivacy",
+       "AutoParing",
+       "PinCode",
 #endif
 };
 
@@ -346,6 +348,22 @@ static void parse_config(GKeyFile *config)
                g_clear_error(&err);
        else
                main_opts.le_privacy = boolean;
+
+       boolean = g_key_file_get_boolean(config, "General",
+                                               "AutoPairing", &err);
+       if (err)
+               g_clear_error(&err);
+       else
+               main_opts.auto_pairing = boolean;
+
+       str = g_key_file_get_string(config, "General", "PinCode", &err);
+       if (err) {
+               g_clear_error(&err);
+       } else {
+               DBG("PinCode=%s", str);
+               g_free(main_opts.pin_code);
+               main_opts.pin_code = str;
+       }
 #endif
 }
 
index bb431e4..eeeb7bd 100644 (file)
@@ -74,6 +74,14 @@ Class = 0x00020C        # Smart phone
 # Enable the LE Privacy feature. If value is true, i.e. LE Privacy is enabled
 # otherwise the feature is disabled by default for the local device.
 EnableLEPrivacy = false
+
+# Enable the Auto Pairing feature. If value is true, Auto Paring is enabled
+# otherwise the feature is disabled by defaut for the local device.
+AutoPairing = false
+
+# Set the Pin Code for device paring. If AutoPairing is enabled, local device
+# will use the specified pin code for device paring. Default value is "0000".
+PinCode = 0000
 #endif
 
 #[Policy]
index 822be5e..cd3e622 100644 (file)
@@ -67,6 +67,14 @@ Class = 0x000704        # Wearable, Wrist Watch
 # Enable the LE Privacy feature. If value is true, i.e. LE Privacy is enabled
 # otherwise the feature is disabled by default for the local device.
 EnableLEPrivacy = false
+
+# Enable the Auto Pairing feature. If value is true, Auto Paring is enabled
+# otherwise the feature is disabled by defaut for the local device.
+AutoPairing = false
+
+# Set the Pin Code for device paring. If AutoPairing is enabled, local device
+# will use the specified pin code for device paring. Default value is "0000".
+PinCode = 0000
 #endif
 
 [Policy]