summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>2014-10-24 17:59:36 +0200
committerCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>2014-10-28 11:45:43 +0100
commitea4787499cb21d2bfc744aad7b8ba103efe67845 (patch)
tree4963826f9ce9c5aeaa4199b583523191223f0b3d
parentc135cd5be417b55b9a25c32d4cc584a6662fb109 (diff)
downloadbluetooth-ea4787499cb21d2bfc744aad7b8ba103efe67845.tar.gz
bluetooth-ea4787499cb21d2bfc744aad7b8ba103efe67845.tar.bz2
bluetooth-ea4787499cb21d2bfc744aad7b8ba103efe67845.zip
It allows to use BT_ADAPTER_DEVICE_DISCOVERY_REMOVED discovery state in discovery state change callback. In that way, when a remote device is no more visible, it can be handled by C API. Change-Id: I2a25bc59147f224cc74cd38e963aaf945ed16b31 Signed-off-by: Corentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
-rw-r--r--include/bluetooth.h1
-rw-r--r--src/bluetooth-common.c12
2 files changed, 13 insertions, 0 deletions
diff --git a/include/bluetooth.h b/include/bluetooth.h
index d8b4dda..9a759c7 100644
--- a/include/bluetooth.h
+++ b/include/bluetooth.h
@@ -109,6 +109,7 @@ typedef enum
BT_ADAPTER_DEVICE_DISCOVERY_STARTED, /**< Device discovery is started */
BT_ADAPTER_DEVICE_DISCOVERY_FINISHED, /**< Device discovery is finished */
BT_ADAPTER_DEVICE_DISCOVERY_FOUND, /**< The remote Bluetooth device is found */
+ BT_ADAPTER_DEVICE_DISCOVERY_REMOVED, /**< A known remote Bluetooth device is disappeard */
} bt_adapter_device_discovery_state_e;
/**
diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c
index b17f8c2..6474b76 100644
--- a/src/bluetooth-common.c
+++ b/src/bluetooth-common.c
@@ -536,6 +536,17 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
(_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FOUND, NULL, bt_event_slot_container[event_index].user_data);
}
break;
+ case BLUETOOTH_EVENT_REMOTE_DEVICE_DISAPPEARED:
+ BT_INFO("bt_adapter_device_discovery_state_changed_cb() will be called with BT_ADAPTER_DEVICE_DISCOVERY_REMOVED");
+ if (__bt_get_bt_adapter_device_discovery_info_s(&discovery_info, (bluetooth_device_info_t *)(param->param_data)) == BT_ERROR_NONE) {
+ ((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback)
+ (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_REMOVED, discovery_info, bt_event_slot_container[event_index].user_data);
+ __bt_free_bt_adapter_device_discovery_info_s(discovery_info);
+ } else {
+ ((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback)
+ (_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_REMOVED, NULL, bt_event_slot_container[event_index].user_data);
+ }
+ break;
case BLUETOOTH_EVENT_BONDING_FINISHED:
BT_INFO("bt_device_bond_created_cb() will be called");
_bt_get_bt_device_info_s(&bonded_device, (bluetooth_device_info_t *)(param->param_data));
@@ -1150,6 +1161,7 @@ static int __bt_get_cb_index(int event)
case BLUETOOTH_EVENT_DISCOVERY_STARTED:
case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+ case BLUETOOTH_EVENT_REMOTE_DEVICE_DISAPPEARED:
return BT_EVENT_DEVICE_DISCOVERY_STATE_CHANGED;
case BLUETOOTH_EVENT_BONDING_FINISHED:
return BT_EVENT_BOND_CREATED;