handle device disappear event 75/29475/2 devel accepted/tizen/common/20141103.140847 accepted/tizen/common/20141103.140856 accepted/tizen/common/20141103.140935 accepted/tizen/ivi/20141107.010904 submit/tizen/20141030.031637 submit/tizen/20141030.072151 submit/tizen/20141031.051326 submit/tizen_mobile/20141120.000000
authorCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Fri, 24 Oct 2014 15:59:36 +0000 (17:59 +0200)
committerCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Tue, 28 Oct 2014 10:45:43 +0000 (11:45 +0100)
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>
include/bluetooth.h
src/bluetooth-common.c

index d8b4dda..9a759c7 100644 (file)
@@ -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;
 
 /**
index b17f8c2..6474b76 100644 (file)
@@ -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;