From: Corentin Lecouvey Date: Fri, 24 Oct 2014 15:59:36 +0000 (+0200) Subject: handle device disappear event X-Git-Tag: submit/tizen/20141030.031637^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F29475%2F2;p=platform%2Fcore%2Fapi%2Fbluetooth.git handle device disappear event 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 --- 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;