summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-12-01 12:08:51 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-12-01 12:08:51 +0200
commit2071a8a2f8e6d238ff0d0f44cb075c902b8ec0e4 (patch)
treedf0ca5bf4a8cfdc83284a72a9cace7bb22b2193d /src
parent722b85aa0cda44f276d7b41f7658a6fe9cc01fae (diff)
Get rid of OffMode and always behave like DevDown
Diffstat (limited to 'src')
-rw-r--r--src/adapter.c45
-rw-r--r--src/hcid.h4
-rw-r--r--src/main.c13
-rw-r--r--src/main.conf4
4 files changed, 15 insertions, 51 deletions
diff --git a/src/adapter.c b/src/adapter.c
index 0f427ef4..607f2415 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -614,10 +614,7 @@ static int set_mode(struct btd_adapter *adapter, uint8_t new_mode)
if (dd < 0)
return -EIO;
- if (!adapter->up &&
- (main_opts.offmode == HCID_OFFMODE_NOSCAN ||
- (main_opts.offmode == HCID_OFFMODE_DEVDOWN &&
- scan_enable != SCAN_DISABLED))) {
+ if (!adapter->up && scan_enable != SCAN_DISABLED) {
/* Start HCI device */
if (ioctl(dd, HCIDEVUP, adapter->dev_id) == 0)
goto done; /* on success */
@@ -632,8 +629,7 @@ static int set_mode(struct btd_adapter *adapter, uint8_t new_mode)
}
}
- if (adapter->up && scan_enable == SCAN_DISABLED &&
- main_opts.offmode == HCID_OFFMODE_DEVDOWN) {
+ if (adapter->up && scan_enable == SCAN_DISABLED) {
if (ioctl(dd, HCIDEVDOWN, adapter->dev_id) < 0) {
err = -errno;
hci_close_dev(dd);
@@ -1777,10 +1773,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &property);
/* Powered */
- if (main_opts.offmode == HCID_OFFMODE_DEVDOWN)
- value = adapter->up ? TRUE : FALSE;
- else
- value = adapter->scan_mode == SCAN_DISABLED ? FALSE : TRUE;
+ value = adapter->up ? TRUE : FALSE;
dict_append_entry(&dict, "Powered", DBUS_TYPE_BOOLEAN, &value);
/* Discoverable */
@@ -2540,23 +2533,17 @@ static int adapter_up(struct btd_adapter *adapter, int dd)
if (g_str_equal(mode, "off")) {
powered = FALSE;
- if (main_opts.offmode == HCID_OFFMODE_NOSCAN) {
- adapter->mode = MODE_OFF;
- scan_mode = SCAN_DISABLED;
- } else if (main_opts.offmode == HCID_OFFMODE_DEVDOWN) {
- if (!adapter->initialized) {
- dev_down = TRUE;
- goto proceed;
- }
-
- if (read_on_mode(srcaddr, mode, sizeof(mode)) < 0)
- write_device_mode(&adapter->bdaddr,
- "connectable");
- else
- write_device_mode(&adapter->bdaddr, mode);
-
- return adapter_up(adapter, dd);
+ if (!adapter->initialized) {
+ dev_down = TRUE;
+ goto proceed;
}
+
+ if (read_on_mode(srcaddr, mode, sizeof(mode)) < 0)
+ write_device_mode(&adapter->bdaddr, "connectable");
+ else
+ write_device_mode(&adapter->bdaddr, mode);
+
+ return adapter_up(adapter, dd);
} else if (!g_str_equal(mode, "connectable") &&
adapter->discov_timeout == 0) {
/* Set discoverable only if timeout is 0 */
@@ -2591,7 +2578,7 @@ proceed:
g_free(cl);
}
- if (dev_down == FALSE && main_opts.offmode == HCID_OFFMODE_DEVDOWN)
+ if (dev_down == FALSE)
emit_property_changed(connection, adapter->path,
ADAPTER_INTERFACE, "Powered",
DBUS_TYPE_BOOLEAN, &powered);
@@ -3196,9 +3183,7 @@ void adapter_mode_changed(struct btd_adapter *adapter, uint8_t scan_mode)
return;
}
- if (powered == FALSE ||
- (main_opts.offmode == HCID_OFFMODE_NOSCAN &&
- adapter->scan_mode == SCAN_DISABLED))
+ if (powered == FALSE)
emit_property_changed(connection, path,
ADAPTER_INTERFACE, "Powered",
DBUS_TYPE_BOOLEAN, &powered);
diff --git a/src/hcid.h b/src/hcid.h
index 614ec7f8..90e31f0d 100644
--- a/src/hcid.h
+++ b/src/hcid.h
@@ -42,9 +42,6 @@
#define MODE_LIMITED 0x03
#define MODE_UNKNOWN 0xff
-#define HCID_OFFMODE_DEVDOWN 0
-#define HCID_OFFMODE_NOSCAN 1
-
/* Timeout for hci_send_req (milliseconds) */
#define HCI_REQ_TIMEOUT 5000
@@ -59,7 +56,6 @@ struct main_opts {
uint16_t link_mode;
uint16_t link_policy;
- int offmode;
uint8_t scan;
uint8_t mode;
uint8_t inqmode;
diff --git a/src/main.c b/src/main.c
index e9454603..af3368e9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -102,18 +102,6 @@ static void parse_config(GKeyFile *config)
debug("parsing main.conf");
- str = g_key_file_get_string(config, "General",
- "OffMode", &err);
- if (err) {
- debug("%s", err->message);
- g_clear_error(&err);
- } else {
- debug("offmode=%s", str);
- if (g_str_equal(str, "DevDown"))
- main_opts.offmode = HCID_OFFMODE_DEVDOWN;
- g_free(str);
- }
-
val = g_key_file_get_integer(config, "General",
"DiscoverableTimeout",
&err);
@@ -528,7 +516,6 @@ static void init_defaults(void)
{
/* Default HCId settings */
memset(&main_opts, 0, sizeof(main_opts));
- main_opts.offmode = HCID_OFFMODE_NOSCAN;
main_opts.scan = SCAN_PAGE;
main_opts.mode = MODE_CONNECTABLE;
main_opts.name = g_strdup("BlueZ");
diff --git a/src/main.conf b/src/main.conf
index 20bac707..0ddd9498 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -26,10 +26,6 @@ PairableTimeout = 0
# (16384 = 10 seconds)
PageTimeout = 8192
-# Behaviour for Adapter.SetProperty("mode", "off")
-# Possible values: "DevDown", "NoScan" (default)
-OffMode = NoScan
-
# Discover scheduler interval used in Adapter.DiscoverDevices
# The value is in seconds. Defaults is 0 to use controller scheduler
DiscoverSchedulerInterval = 0