diff --git a/android/bluetooth.c b/android/bluetooth.c
index acd2dd2..8f66dd1 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
#define BASELEN_REMOTE_DEV_PROP (sizeof(struct hal_ev_remote_device_props) \
+ sizeof(struct hal_property))
+#define SCAN_TYPE_BREDR (1 << BDADDR_BREDR)
+#define SCAN_TYPE_LE ((1 << BDADDR_LE_PUBLIC) | (1 << BDADDR_LE_RANDOM))
+#define SCAN_TYPE_DUAL (SCAN_TYPE_BREDR | SCAN_TYPE_LE)
+
struct device {
bdaddr_t bdaddr;
uint8_t bdaddr_type;
get_adapter_discoverable_timeout();
}
-static bool start_discovery(void)
+static uint8_t get_adapter_discovering_type(void)
{
- struct mgmt_cp_start_discovery cp;
+ uint8_t type;
if (adapter.current_settings & MGMT_SETTING_BREDR)
- cp.type = 1 << BDADDR_BREDR;
+ type = SCAN_TYPE_BREDR;
else
- cp.type = 0;
+ type = 0;
if (adapter.current_settings & MGMT_SETTING_LE)
- cp.type |= (1 << BDADDR_LE_PUBLIC) | (1 << BDADDR_LE_RANDOM);
+ type |= SCAN_TYPE_LE;
+
+ return type;
+}
+
+static bool start_discovery(uint8_t type)
+{
+ struct mgmt_cp_start_discovery cp;
+
+ cp.type = get_adapter_discovering_type() & type;
DBG("type=0x%x", cp.type);
dev->confirm_id = 0;
}
-static bool stop_discovery(void)
+static bool stop_discovery(uint8_t type)
{
struct mgmt_cp_stop_discovery cp;
- if (adapter.current_settings & MGMT_SETTING_BREDR)
- cp.type = 1 << BDADDR_BREDR;
- else
- cp.type = 0;
-
- if (adapter.current_settings & MGMT_SETTING_LE)
- cp.type |= (1 << BDADDR_LE_PUBLIC) | (1 << BDADDR_LE_RANDOM);
+ cp.type = get_adapter_discovering_type() & type;
DBG("type=0x%x", cp.type);
goto reply;
}
- if (!start_discovery()) {
+ if (!start_discovery(SCAN_TYPE_DUAL)) {
status = HAL_STATUS_FAILED;
goto reply;
}
goto reply;
}
- if (!stop_discovery()) {
+ if (!stop_discovery(SCAN_TYPE_DUAL)) {
status = HAL_STATUS_FAILED;
goto reply;
}