Set callback for Bluetooth discovery
Set callback for Bluetooth discovery to react on every change. Possible options: discovery started, finished and new device found.
// PRIVILEGE needed to be set in tizen-manifest.xml:
// http://tizen.org/privilege/bluetooth
#include <bluetooth.h>
#include <dlog.h> // for logging purposes
void
adapter_device_discovery_state_changed_cb(int result,
bt_adapter_device_discovery_state_e discovery_state,
bt_adapter_device_discovery_info_s *discovery_info,
void* user_data) {
if(result == BT_ERROR_NONE) {
switch (discovery_state) {
case BT_ADAPTER_DEVICE_DISCOVERY_STARTED:
LOGI("Device discovery started");
break;
case BT_ADAPTER_DEVICE_DISCOVERY_FINISHED:
LOGI("Device discovery finished");
break;
case BT_ADAPTER_DEVICE_DISCOVERY_FOUND:
LOGI("Device discovery found");
}
}
}
void
discovery_state_changed() {
int ret;
ret = bt_adapter_set_device_discovery_state_changed_cb(
adapter_device_discovery_state_changed_cb, NULL);
if(ret != BT_ERROR_NONE)
LOGE("Error occurred");
}
void test() {
bt_initialize();
discovery_state_changed();
bt_adapter_start_device_discovery();
}