summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-11-29 21:45:14 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-11-29 21:45:14 +0200
commitfaeb00ab84d97bf5e59f36f5a962af50f22919f4 (patch)
tree844c0575b4b222b4932c19f29d1e3269f2699575
parent7719613581c592d41c96be7f2334c7923d59f3c2 (diff)
Clean up scan mode related code
-rw-r--r--src/adapter.c36
-rw-r--r--src/adapter.h3
-rw-r--r--src/dbus-hci.c3
3 files changed, 7 insertions, 35 deletions
diff --git a/src/adapter.c b/src/adapter.c
index 8794a240..a44561de 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3030,24 +3030,6 @@ void adapter_remove_discov_timeout(struct btd_adapter *adapter)
adapter->discov_timeout_id = 0;
}
-void adapter_set_scan_mode(struct btd_adapter *adapter, uint8_t scan_mode)
-{
- if (!adapter)
- return;
-
- adapter->scan_mode = scan_mode;
-}
-
-uint8_t adapter_get_scan_mode(struct btd_adapter *adapter)
-{
- return adapter->scan_mode;
-}
-
-uint8_t adapter_get_mode(struct btd_adapter *adapter)
-{
- return adapter->mode;
-}
-
void adapter_set_state(struct btd_adapter *adapter, int state)
{
gboolean discov_active = FALSE;
@@ -3217,31 +3199,26 @@ void adapter_remove_oor_device(struct btd_adapter *adapter, char *peer_addr)
void adapter_mode_changed(struct btd_adapter *adapter, uint8_t scan_mode)
{
const gchar *path = adapter_get_path(adapter);
- const char *mode;
gboolean powered, discoverable;
+ if (adapter->scan_mode == scan_mode)
+ return;
+
switch (scan_mode) {
case SCAN_DISABLED:
- mode = "off";
adapter->mode = MODE_OFF;
powered = FALSE;
discoverable = FALSE;
break;
case SCAN_PAGE:
- mode = "connectable";
adapter->mode = MODE_CONNECTABLE;
powered = TRUE;
discoverable = FALSE;
break;
case (SCAN_PAGE | SCAN_INQUIRY):
+ adapter->mode = MODE_DISCOVERABLE;
powered = TRUE;
discoverable = TRUE;
- if (adapter_get_mode(adapter) == MODE_LIMITED) {
- mode = "limited";
- } else {
- adapter->mode = MODE_DISCOVERABLE;
- mode = "discoverable";
- }
if (adapter->discov_timeout != 0)
adapter_set_discov_timeout(adapter,
adapter->discov_timeout);
@@ -3259,17 +3236,16 @@ void adapter_mode_changed(struct btd_adapter *adapter, uint8_t scan_mode)
return;
}
- if (powered == FALSE || adapter->scan_mode == SCAN_DISABLED) {
+ if (powered == FALSE || adapter->scan_mode == SCAN_DISABLED)
emit_property_changed(connection, path,
ADAPTER_INTERFACE, "Powered",
DBUS_TYPE_BOOLEAN, &powered);
- }
emit_property_changed(connection, path,
ADAPTER_INTERFACE, "Discoverable",
DBUS_TYPE_BOOLEAN, &discoverable);
- adapter_set_scan_mode(adapter, scan_mode);
+ adapter->scan_mode = scan_mode;
}
struct agent *adapter_get_agent(struct btd_adapter *adapter)
diff --git a/src/adapter.h b/src/adapter.h
index 165b3325..28faf897 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -136,9 +136,6 @@ const gchar *adapter_get_path(struct btd_adapter *adapter);
void adapter_get_address(struct btd_adapter *adapter, bdaddr_t *bdaddr);
void adapter_remove(struct btd_adapter *adapter);
void adapter_remove_discov_timeout(struct btd_adapter *adapter);
-void adapter_set_scan_mode(struct btd_adapter *adapter, uint8_t scan_mode);
-uint8_t adapter_get_scan_mode(struct btd_adapter *adapter);
-uint8_t adapter_get_mode(struct btd_adapter *adapter);
void adapter_set_state(struct btd_adapter *adapter, int state);
int adapter_get_state(struct btd_adapter *adapter);
struct remote_dev_info *adapter_search_found_devices(struct btd_adapter *adapter,
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index f2b6f2e5..ee9f9cab 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -1375,8 +1375,7 @@ void hcid_dbus_setscan_enable_complete(bdaddr_t *local)
adapter_remove_discov_timeout(adapter);
- if (adapter_get_scan_mode(adapter) != rp.enable)
- adapter_mode_changed(adapter, rp.enable);
+ adapter_mode_changed(adapter, rp.enable);
failed:
if (dd >= 0)