diff --git a/src/adapter.c b/src/adapter.c
index 88b720a..db8a737 100644
--- a/src/adapter.c
+++ b/src/adapter.c
if (current == enable)
return;
- set_mode(adapter, MGMT_OP_SET_PAIRABLE, 0x01);
+ set_mode(adapter, MGMT_OP_SET_PAIRABLE, enable ? 0x01 : 0x00);
}
bool btd_adapter_get_powered(struct btd_adapter *adapter)
!(adapter->current_settings & MGMT_SETTING_LE))
set_mode(adapter, MGMT_OP_SET_LE, 0x01);
- set_mode(adapter, MGMT_OP_SET_PAIRABLE, 0x01);
+ if (main_opts.always_pairable) {
+ if (!(adapter->current_settings & MGMT_SETTING_PAIRABLE))
+ set_mode(adapter, MGMT_OP_SET_PAIRABLE, 0x01);
+ } else {
+ struct agent *agent = agent_get(NULL);
+
+ if (adapter->current_settings & MGMT_SETTING_PAIRABLE) {
+ if (!agent)
+ set_mode(adapter, MGMT_OP_SET_PAIRABLE, 0x00);
+ } else {
+ if (agent)
+ set_mode(adapter, MGMT_OP_SET_PAIRABLE, 0x01);
+ }
+
+ if (agent) {
+ agent_unref(agent);
+ agent = NULL;
+ }
+ }
+
if (!kernel_conn_control)
set_mode(adapter, MGMT_OP_SET_CONNECTABLE, 0x01);
diff --git a/src/agent.c b/src/agent.c
index 8c1211c..70786c3 100644
--- a/src/agent.c
+++ b/src/agent.c
#include "log.h"
#include "error.h"
+#include "hcid.h"
#include "dbus-common.h"
#include "adapter.h"
#include "device.h"
io_cap = IO_CAPABILITY_NOINPUTNOOUTPUT;
adapter_set_io_capability(adapter, io_cap);
+
+ if (!main_opts.always_pairable)
+ adapter_set_pairable(adapter, agent ? true : false);
}
static bool add_default_agent(struct agent *agent)
diff --git a/src/hcid.h b/src/hcid.h
index 6040c71..5956124 100644
--- a/src/hcid.h
+++ b/src/hcid.h
uint16_t autoto;
uint32_t pairto;
uint32_t discovto;
+ gboolean always_pairable;
gboolean reverse_sdp;
gboolean name_resolv;
gboolean debug_keys;
diff --git a/src/main.c b/src/main.c
index 15f98cf..5ec1ab3 100644
--- a/src/main.c
+++ b/src/main.c
"Name",
"Class",
"DiscoverableTimeout",
+ "AlwaysPairable",
"PairableTimeout",
"AutoConnectTimeout",
"DeviceID",
DBG("parsing main.conf");
+ boolean = g_key_file_get_boolean(config, "General",
+ "AlwaysPairable", &err);
+ if (err) {
+ DBG("%s", err->message);
+ g_clear_error(&err);
+ } else
+ main_opts.always_pairable = boolean;
+
val = g_key_file_get_integer(config, "General",
"DiscoverableTimeout", &err);
if (err) {
memset(&main_opts, 0, sizeof(main_opts));
main_opts.name = g_strdup_printf("BlueZ %s", VERSION);
main_opts.class = 0x000000;
+ main_opts.always_pairable = FALSE;
main_opts.pairto = DEFAULT_PAIRABLE_TIMEOUT;
main_opts.discovto = DEFAULT_DISCOVERABLE_TIMEOUT;
main_opts.reverse_sdp = TRUE;
diff --git a/src/main.conf b/src/main.conf
index 3ebadde..1d62f24 100644
--- a/src/main.conf
+++ b/src/main.conf
# considered. Defaults to '0x000000'.
#Class = 0x000100
+# Whether adapters should always be set as pairable, regardless of
+# whether there is any agents registered. Setting to false (the default)
+# will make adapters only pairable once the first agent registers.
+#AlwaysPairable = false
+
# 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