summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWootak Jung <wootak.jung@samsung.com>2018-05-31 17:12:42 +0900
committerWootak Jung <wootak.jung@samsung.com>2018-05-31 17:17:34 +0900
commit8b2dbfb5bac3f9a897e846330c37f79ada3e8945 (patch)
tree0b3627184de208202bb82b81cefba43083597f1b
parentf8bb52dcd073736b6350edc3a08fa890b3afe2a9 (diff)
downloadbluez-8b2dbfb5bac3f9a897e846330c37f79ada3e8945.tar.gz
bluez-8b2dbfb5bac3f9a897e846330c37f79ada3e8945.tar.bz2
bluez-8b2dbfb5bac3f9a897e846330c37f79ada3e8945.zip
Add headless device handling logicsubmit/tizen/20180531.061844
Change-Id: I0b7fa8f982e4b455b245e5c66b1fdc7ecb6289ca
-rwxr-xr-xpackaging/bluez.spec14
-rw-r--r--src/adapter.c10
-rwxr-xr-xsrc/hcid.h1
-rwxr-xr-xsrc/main.c15
-rw-r--r--src/main_headless.conf114
5 files changed, 154 insertions, 0 deletions
diff --git a/packaging/bluez.spec b/packaging/bluez.spec
index 7def6bac..20243369 100755
--- a/packaging/bluez.spec
+++ b/packaging/bluez.spec
@@ -138,6 +138,12 @@ Conflicts: %{name}-profile_wearable
%description profile_tv
Bluez modified service script for Tizen TV
+%package plugin-headless
+Summary: Bluez headless plugin
+Requires: %{name}-compat = %{version}-%{release}
+%description plugin-headless
+This package is Bluez plugin to manager headless device
+
%prep
%setup -q
cp %{SOURCE1001} .
@@ -359,6 +365,7 @@ 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/main_headless.conf %{buildroot}%{_sysconfdir}/bluetooth/main.conf.headless
#install -D -m 0644 src/org.bluez.service %{buildroot}%{_datadir}/dbus-1/system-services/org.bluez.service
@@ -530,5 +537,12 @@ rm %{_sysconfdir}/bluetooth/main.conf
%manifest %{name}.manifest
%{_sysconfdir}/bluetooth/main.conf
+%post plugin-headless
+ln -sf main.conf.headless %{_sysconfdir}/bluetooth/main.conf
+%preun plugin-headless
+rm %{_sysconfdir}/bluetooth/main.conf
+%files plugin-headless
+%manifest %{name}.manifest
+%{_sysconfdir}/bluetooth/main.conf.headless
%changelog
diff --git a/src/adapter.c b/src/adapter.c
index 656f91d0..d0df3a29 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -11703,6 +11703,16 @@ static void pin_code_request_callback(uint16_t index, uint16_t length,
return;
}
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ if (main_opts.pin_code) {
+ /* Because we can't receive user input on headless device,
+ no need to request pincode. Use the 'PinCode' in headless conf file */
+ btd_adapter_pincode_reply(adapter, &ev->addr.bdaddr,
+ main_opts.pin_code, strlen(main_opts.pin_code));
+ return;
+ }
+#endif
+
err = device_request_pincode(device, ev->secure);
if (err < 0) {
btd_error(adapter->dev_id, "device_request_pin: %s",
diff --git a/src/hcid.h b/src/hcid.h
index 6c6ffab5..cbd11c14 100755
--- a/src/hcid.h
+++ b/src/hcid.h
@@ -48,6 +48,7 @@ struct main_opts {
gboolean fast_conn;
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
gboolean le_privacy;
+ char *pin_code;
#endif
uint16_t did_source;
diff --git a/src/main.c b/src/main.c
index 5f64d52f..17ddac18 100755
--- a/src/main.c
+++ b/src/main.c
@@ -92,6 +92,7 @@ static const char *supported_options[] = {
"Privacy",
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
"EnableLEPrivacy",
+ "PinCode",
#endif
NULL
};
@@ -407,6 +408,16 @@ static void parse_config(GKeyFile *config)
g_clear_error(&err);
else
main_opts.le_privacy = boolean;
+
+ str = g_key_file_get_string(config, "General", "PinCode", &err);
+ if (err) {
+ DBG("%s", err->message);
+ g_clear_error(&err);
+ } else {
+ DBG("PinCode=%s", str);
+ main_opts.pin_code = g_strdup(str);
+ g_free(str);
+ }
#endif
str = g_key_file_get_string(config, "GATT", "Cache", &err);
if (err) {
@@ -435,6 +446,7 @@ static void init_defaults(void)
main_opts.debug_keys = FALSE;
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
main_opts.le_privacy = FALSE;
+ main_opts.pin_code = NULL;
#endif
if (sscanf(VERSION, "%hhu.%hhu", &major, &minor) != 2)
@@ -799,6 +811,9 @@ int main(int argc, char *argv[])
if (main_opts.mode != BT_MODE_LE)
stop_sdp_server();
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ g_free(main_opts.pin_code);
+#endif
g_main_loop_unref(event_loop);
diff --git a/src/main_headless.conf b/src/main_headless.conf
new file mode 100644
index 00000000..15b5fd1e
--- /dev/null
+++ b/src/main_headless.conf
@@ -0,0 +1,114 @@
+[General]
+
+# Default adapter name
+# Defaults to 'BlueZ X.YZ'
+#Name = BlueZ
+
+# Default device class. Only the major and minor device class bits are
+# considered. Defaults to '0x000000'.
+#Class = 0x000100
+
+# How long to stay in discoverable mode before going back to non-discoverable
+# The value is in seconds. Default is 180, i.e. 3 minutes.
+# 0 = disable timer, i.e. stay discoverable forever
+#DiscoverableTimeout = 0
+
+# How long to stay in pairable mode before going back to non-discoverable
+# The value is in seconds. Default is 0.
+# 0 = disable timer, i.e. stay pairable forever
+#PairableTimeout = 0
+
+# Automatic connection for bonded devices driven by platform/user events.
+# If a platform plugin uses this mechanism, automatic connections will be
+# enabled during the interval defined below. Initially, this feature
+# intends to be used to establish connections to ATT channels. Default is 60.
+#AutoConnectTimeout = 60
+
+# Use vendor id source (assigner), vendor, product and version information for
+# DID profile support. The values are separated by ":" and assigner, VID, PID
+# and version.
+# Possible vendor id source values: bluetooth, usb (defaults to usb)
+#DeviceID = bluetooth:1234:5678:abcd
+
+# Do reverse service discovery for previously unknown devices that connect to
+# us. This option is really only needed for qualification since the BITE tester
+# doesn't like us doing reverse SDP for some test cases (though there could in
+# theory be other useful purposes for this too). Defaults to 'true'.
+#ReverseServiceDiscovery = true
+
+# Enable name resolving after inquiry. Set it to 'false' if you don't need
+# remote devices name and want shorter discovery cycle. Defaults to 'true'.
+#NameResolving = true
+
+# Enable runtime persistency of debug link keys. Default is false which
+# makes debug link keys valid only for the duration of the connection
+# that they were created for.
+#DebugKeys = false
+
+# Restricts all controllers to the specified transport. Default value
+# is "dual", i.e. both BR/EDR and LE enabled (when supported by the HW).
+# Possible values: "dual", "bredr", "le"
+#ControllerMode = dual
+
+# Enables Multi Profile Specification support. This allows to specify if
+# system supports only Multiple Profiles Single Device (MPSD) configuration
+# or both Multiple Profiles Single Device (MPSD) and Multiple Profiles Multiple
+# Devices (MPMD) configurations.
+# Possible values: "off", "single", "multiple"
+#MultiProfile = off
+
+# Permanently enables the Fast Connectable setting for adapters that
+# support it. When enabled other devices can connect faster to us,
+# however the tradeoff is increased power consumptions. This feature
+# will fully work only on kernel version 4.1 and newer. Defaults to
+# 'false'.
+#FastConnectable = false
+
+# Default privacy setting.
+# Enables use of private address.
+# Possible values: "off", "device", "network"
+# "network" option not supported currently
+# Defaults to "off"
+# Privacy = off
+
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+# Defines PinCode in headless device. If PinCode request is invoked,
+# response this PinCode directly instead of delivery to agent.
+PinCode = 0000
+#endif
+
+[GATT]
+# GATT attribute cache.
+# Possible values:
+# always: Always cache attributes even for devices not paired, this is
+# recommended as it is best for interoperability, with more consistent
+# reconnection times and enables proper tracking of notifications for all
+# devices.
+# yes: Only cache attributes of paired devices.
+# no: Never cache attributes
+# Default: always
+#Cache = always
+
+[Policy]
+#
+# The ReconnectUUIDs defines the set of remote services that should try
+# to be reconnected to in case of a link loss (link supervision
+# timeout). The policy plugin should contain a sane set of values by
+# default, but this list can be overridden here. By setting the list to
+# empty the reconnection feature gets disabled.
+#ReconnectUUIDs=00001112-0000-1000-8000-00805f9b34fb,0000111f-0000-1000-8000-00805f9b34fb,0000110a-0000-1000-8000-00805f9b34fb
+
+# ReconnectAttempts define the number of attempts to reconnect after a link
+# lost. Setting the value to 0 disables reconnecting feature.
+#ReconnectAttempts=7
+
+# ReconnectIntervals define the set of intervals in seconds to use in between
+# attempts.
+# If the number of attempts defined in ReconnectAttempts is bigger than the
+# set of intervals the last interval is repeated until the last attempt.
+#ReconnectIntervals=1,2,4,8,16,32,64
+
+# AutoEnable defines option to enable all controllers when they are found.
+# This includes adapters present on start as well as adapters that are plugged
+# in later on. Defaults to 'false'.
+#AutoEnable=false