2 * Open Adaptation Layer (OAL)
4 * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
27 #include <bluetooth.h>
29 #include "oal-event.h"
30 #include "oal-internal.h"
31 #include "oal-manager.h"
32 #include "oal-hardware.h"
33 #include "oal-common.h"
34 #include "oal-utils.h"
37 #define CHECK_MAX(max, x) (((max) > (x)) ? (x) : (max))
39 static const bt_interface_t * blued_api;
41 static bt_address_t local_address;
42 static char local_name[BT_DEVICE_NAME_LENGTH_MAX + 1] = {'O', 'A', 'L', 0};
43 static char local_version[BT_VERSION_STR_LEN_MAX + 1];
44 static bt_scan_mode_t scan_mode = BT_SCAN_MODE_NONE;
45 static int discoverable_timeout = 0;
47 /* Forward declarations */
48 oal_status_t convert_to_oal_status(bt_status_t status);
49 static gboolean retry_enable_adapter(gpointer data);
51 static gboolean retry_enable_le(gpointer data);
53 oal_status_t oal_mgr_init_internal(void);
56 /* Callback registered with Stack */
57 static void cb_adapter_state_change(bt_state_t status);
58 static void cb_adapter_discovery_state_changed(bt_discovery_state_t state);
59 static void cb_adapter_device_found(int num_properties, bt_property_t *properties);
60 static void cb_adapter_properties(bt_status_t status,
61 int num_properties, bt_property_t *properties);
62 extern void cb_device_properties(bt_status_t status, bt_bdaddr_t *bd_addr,
63 int num_properties, bt_property_t *properties);
64 extern void cb_device_bond_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr,
65 bt_bond_state_t state);
66 extern void cb_device_acl_state_changed(bt_status_t status, bt_bdaddr_t *remote_bd_addr,
67 bt_acl_state_t state);
68 extern void cb_device_pin_request(bt_bdaddr_t *bd_addr, bt_bdname_t *bdname, uint32_t device_class);
69 extern void cb_device_ssp_request(bt_bdaddr_t *bd_addr, bt_bdname_t *bdname, uint32_t device_class,
70 bt_ssp_variant_t pairing_variant, uint32_t pass_key);
71 extern void cb_device_authorize_request(bt_bdaddr_t *remote_bd_addr, bt_service_id_t service_d);
72 extern void cb_device_trust_state_changed(bt_bdaddr_t *remote_bd_addr, bt_device_trust_state_t trusted);
74 extern void cb_socket_conn_authorize_request(bt_bdaddr_t *remote_bd_addr, bt_uuid_t *uuid);
75 static void cb_ble_state_change(bt_state_t status);
76 extern void cb_device_le_conn_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr,
77 bt_le_conn_state_t state);
78 extern void cb_device_trusted_profiles_changed(bt_bdaddr_t *bd_addr, uint32_t trust_val);
79 extern void cb_rssi_monitor_state_changed(bt_bdaddr_t *bd_addr, int32_t link_type, uint8_t state);
80 extern void cb_rssi_alert(bt_bdaddr_t *bd_addr, int32_t link_type, int32_t alert_type, int32_t rssi);
81 extern void cb_raw_rssi_received(bt_bdaddr_t *bd_addr, int32_t link_type, int32_t rssi);
84 static bt_callbacks_t callbacks = {
86 cb_adapter_state_change,
87 cb_adapter_properties,
89 cb_adapter_device_found,
90 cb_adapter_discovery_state_changed,
91 cb_device_pin_request,
92 cb_device_ssp_request,
93 cb_device_bond_state_changed,
94 cb_device_acl_state_changed,
95 NULL, /* callback_thread_event */
96 NULL, /* dut_mode_recv_callback */
97 NULL, /* le_test_mode_callback*/
98 NULL, /* energy_info_callback */
99 cb_device_authorize_request,
100 cb_device_trust_state_changed,
102 cb_socket_conn_authorize_request,
104 cb_device_le_conn_state_changed,
105 cb_device_trusted_profiles_changed,
106 cb_rssi_monitor_state_changed,
108 cb_raw_rssi_received,
112 oal_status_t adapter_mgr_init(const bt_interface_t * stack_if)
115 blued_api = stack_if;
117 ret = blued_api->init(&callbacks);
119 if (ret != BT_STATUS_SUCCESS) {
120 BT_ERR("Adapter callback registration failed: [%s]", status2string(ret));
121 blued_api->cleanup();
122 return convert_to_oal_status(ret);
125 return OAL_STATUS_SUCCESS;
128 const bt_interface_t* adapter_get_stack_interface(void)
133 void adapter_mgr_cleanup(void)
135 /* Nothing to clean yet , do not set blued_api NULL as it will be used to clean Bluedroid states */
139 oal_status_t adapter_enable(void)
141 int ret = BT_STATUS_SUCCESS;
144 CHECK_OAL_INITIALIZED();
145 if (OAL_STATUS_SUCCESS != hw_is_module_ready()) {
146 g_timeout_add(200, retry_enable_adapter, NULL);
147 return OAL_STATUS_PENDING;
150 ret = blued_api->enable();
152 if (ret != BT_STATUS_SUCCESS) {
153 BT_ERR("Enable failed: [%s]", status2string(ret));
154 return convert_to_oal_status(ret);
157 return OAL_STATUS_SUCCESS;
160 oal_status_t adapter_disable(void)
166 CHECK_OAL_INITIALIZED();
168 ret = blued_api->disable();
170 if (ret != BT_STATUS_SUCCESS) {
171 BT_ERR("Disable failed: [%s]", status2string(ret));
172 return convert_to_oal_status(ret);
174 return OAL_STATUS_SUCCESS;
177 oal_status_t le_enable(void)
179 int ret = BT_STATUS_SUCCESS;
182 CHECK_OAL_INITIALIZED();
185 if (OAL_STATUS_SUCCESS != hw_is_module_ready()) {
186 g_timeout_add(200, retry_enable_le, NULL);
187 return OAL_STATUS_PENDING;
190 ret = blued_api->le_enable();
192 if (ret != BT_STATUS_SUCCESS) {
193 BT_ERR("Enable failed: [%s]", status2string(ret));
194 return convert_to_oal_status(ret);
197 BT_INFO("Not Supported");
198 ret = OAL_STATUS_NOT_SUPPORT;
204 oal_status_t le_disable(void)
210 CHECK_OAL_INITIALIZED();
213 ret = blued_api->le_disable();
215 if (ret != BT_STATUS_SUCCESS) {
216 BT_ERR("Disable failed: [%s]", status2string(ret));
217 return convert_to_oal_status(ret);
220 BT_INFO("Not Supported");
221 ret = OAL_STATUS_NOT_SUPPORT;
226 oal_status_t le_init(void)
228 int ret = BT_STATUS_SUCCESS;
230 CHECK_OAL_INITIALIZED();
232 if (OAL_STATUS_SUCCESS != hw_is_module_ready()) {
233 g_timeout_add(200, retry_enable_le, NULL);
234 return OAL_STATUS_PENDING;
236 ret = blued_api->le_init();
237 if (ret != BT_STATUS_SUCCESS) {
238 BT_ERR("Enable failed: [%s]", status2string(ret));
239 return convert_to_oal_status(ret);
242 BT_INFO("Not Supported");
243 ret = OAL_STATUS_NOT_SUPPORT;
247 oal_status_t le_deinit(void)
249 int ret = BT_STATUS_SUCCESS;
251 CHECK_OAL_INITIALIZED();
253 if (OAL_STATUS_SUCCESS != hw_is_module_ready()) {
254 g_timeout_add(200, retry_enable_le, NULL);
255 return OAL_STATUS_PENDING;
257 blued_api->le_deinit();
259 BT_INFO("Not Supported");
260 ret = OAL_STATUS_NOT_SUPPORT;
264 oal_status_t adapter_start_custom_inquiry(discovery_type_t disc_type)
270 CHECK_OAL_INITIALIZED();
271 BT_INFO("Custom Discovery Type [0x%x]", disc_type);
274 ret = blued_api->start_custom_discovery(disc_type);
275 if (ret != BT_STATUS_SUCCESS) {
276 BT_ERR("start_custom_discovery failed: [%s]", status2string(ret));
277 return convert_to_oal_status(ret);
280 BT_INFO("Not Supported");
281 ret = OAL_STATUS_NOT_SUPPORT;
286 oal_status_t adapter_get_powered_status(gboolean *status)
289 unsigned char powered = 0;
293 CHECK_OAL_INITIALIZED();
295 OAL_CHECK_PARAMETER(status, return);
296 BT_INFO("Get Adapter Powered status");
299 ret = blued_api->get_adapter_powered_status(&powered);
300 if (ret != BT_STATUS_SUCCESS) {
301 BT_ERR("adapter_get_powered_status failed: [%s]", status2string(ret));
303 return convert_to_oal_status(ret);
310 BT_INFO("Not Supported");
311 ret = OAL_STATUS_NOT_SUPPORT;
316 oal_status_t adapter_reset(void)
322 CHECK_OAL_INITIALIZED();
323 BT_INFO("Adapter Reset");
326 ret = blued_api->reset();
327 if (ret != BT_STATUS_SUCCESS) {
328 BT_ERR("Adapter Reset failed: [%s]", status2string(ret));
329 return convert_to_oal_status(ret);
332 BT_INFO("Not Supported");
333 ret = OAL_STATUS_NOT_SUPPORT;
338 oal_status_t adapter_start_inquiry(unsigned short duration)
344 CHECK_OAL_INITIALIZED();
346 ret = blued_api->start_discovery();
347 if (ret != BT_STATUS_SUCCESS) {
348 BT_ERR("start_discovery failed: [%s]", status2string(ret));
349 return convert_to_oal_status(ret);
352 return OAL_STATUS_SUCCESS;
355 oal_status_t adapter_stop_inquiry(void)
361 CHECK_OAL_INITIALIZED();
363 ret = blued_api->cancel_discovery();
364 if (ret != BT_STATUS_SUCCESS) {
365 BT_ERR("cancel_discovery failed: [%s]", status2string(ret));
366 return convert_to_oal_status(ret);
369 return OAL_STATUS_SUCCESS;
372 /* Callbacks from Stack */
373 static void cb_adapter_state_change(bt_state_t status)
378 event = (BT_STATE_ON == status) ? OAL_EVENT_ADAPTER_ENABLED : OAL_EVENT_ADAPTER_DISABLED;
380 send_event(event, NULL, 0);
384 /* Callbacks from Stack */
385 static void cb_ble_state_change(bt_state_t status)
390 event = (BT_STATE_ON == status) ? OAL_EVENT_BLE_ENABLED : OAL_EVENT_BLE_DISABLED;
392 send_event(event, NULL, 0);
396 static gboolean retry_enable_adapter(gpointer data)
403 static gboolean retry_enable_le(gpointer data)
409 oal_status_t adapter_get_properties(void)
414 CHECK_OAL_INITIALIZED();
416 ret = blued_api->get_adapter_properties();
417 if (ret != BT_STATUS_SUCCESS) {
418 BT_ERR("get_adapter_properties failed: [%s]", status2string(ret));
419 return convert_to_oal_status(ret);
422 return OAL_STATUS_SUCCESS;
425 oal_status_t adapter_get_address(void)
430 CHECK_OAL_INITIALIZED();
432 ret = blued_api->get_adapter_property(BT_PROPERTY_BDADDR);
433 if (ret != BT_STATUS_SUCCESS) {
434 BT_ERR("get_adapter_property failed: [%s]", status2string(ret));
435 return convert_to_oal_status(ret);
438 return OAL_STATUS_SUCCESS;
441 oal_status_t adapter_get_version(void)
446 CHECK_OAL_INITIALIZED();
448 ret = blued_api->get_adapter_property(BT_PROPERTY_VERSION);
449 if (ret != BT_STATUS_SUCCESS) {
450 BT_ERR("get_adapter_property failed: [%s]", status2string(ret));
451 return convert_to_oal_status(ret);
454 return OAL_STATUS_SUCCESS;
457 oal_status_t adapter_get_name(void)
461 CHECK_OAL_INITIALIZED();
465 ret = blued_api->get_adapter_property(BT_PROPERTY_BDNAME);
466 if (ret != BT_STATUS_SUCCESS) {
467 BT_ERR("get_adapter_property failed: [%s]", status2string(ret));
468 return convert_to_oal_status(ret);
471 return OAL_STATUS_SUCCESS;
474 oal_status_t adapter_set_name(char * name)
479 CHECK_OAL_INITIALIZED();
481 OAL_CHECK_PARAMETER(name, return);
482 API_TRACE("Name: %s", name);
484 prop.type = BT_PROPERTY_BDNAME;
485 prop.len = strlen(name);
488 ret = blued_api->set_adapter_property(&prop);
489 if (ret != BT_STATUS_SUCCESS) {
490 BT_ERR("set_adapter_property: [%s]", status2string(ret));
491 ret = OAL_STATUS_INTERNAL_ERROR;
493 ret = OAL_STATUS_SUCCESS;
498 oal_status_t adapter_is_discoverable(int *p_discoverable)
500 OAL_CHECK_PARAMETER(p_discoverable, return);
502 *p_discoverable = (scan_mode == BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
504 API_TRACE("%d", *p_discoverable);
506 return OAL_STATUS_SUCCESS;
509 oal_status_t adapter_is_connectable(int *p_connectable)
511 OAL_CHECK_PARAMETER(p_connectable, return);
513 *p_connectable = (scan_mode == BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE)
514 || (scan_mode == BT_SCAN_MODE_CONNECTABLE);
516 API_TRACE("%d", *p_connectable);
518 return OAL_STATUS_SUCCESS;
521 oal_status_t adapter_get_discoverable_timeout(int *p_timeout)
523 API_TRACE("%d", discoverable_timeout);
525 *p_timeout = discoverable_timeout;
527 return OAL_STATUS_SUCCESS;
530 oal_status_t adapter_get_service_uuids(void)
534 CHECK_OAL_INITIALIZED();
538 ret = blued_api->get_adapter_property(BT_PROPERTY_UUIDS);
539 if (ret != BT_STATUS_SUCCESS) {
540 BT_ERR("get_adapter_property failed: [%s]", status2string(ret));
541 return convert_to_oal_status(ret);
544 return OAL_STATUS_SUCCESS;
547 oal_status_t adapter_get_bonded_devices(void)
551 CHECK_OAL_INITIALIZED();
555 ret = blued_api->get_adapter_property(BT_PROPERTY_ADAPTER_BONDED_DEVICES);
556 if (ret != BT_STATUS_SUCCESS) {
557 BT_ERR("get_adapter_property failed: [%s]", status2string(ret));
558 return convert_to_oal_status(ret);
561 return OAL_STATUS_SUCCESS;
564 static oal_status_t set_scan_mode(bt_scan_mode_t mode)
571 CHECK_OAL_INITIALIZED();
573 prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE;
574 prop.len = sizeof(bt_scan_mode_t);
576 res = blued_api->set_adapter_property(&prop);
577 if (res != BT_STATUS_SUCCESS) {
578 BT_ERR("set scan mode failed [%s]", status2string(res));
579 return convert_to_oal_status(res);
583 return OAL_STATUS_SUCCESS;
586 oal_status_t adapter_set_connectable(int connectable)
590 API_TRACE("%d", connectable);
592 CHECK_OAL_INITIALIZED();
594 mode = connectable ? BT_SCAN_MODE_CONNECTABLE : BT_SCAN_MODE_NONE;
596 return set_scan_mode(mode);
599 oal_status_t adapter_set_discoverable(void)
601 CHECK_OAL_INITIALIZED();
604 return set_scan_mode(BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
607 oal_status_t adapter_set_discoverable_timeout(int timeout)
611 uint32_t prop_val = timeout;
613 CHECK_OAL_INITIALIZED();
614 API_TRACE("%d", timeout);
616 prop.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT;
617 prop.len = sizeof(prop_val);
618 prop.val = &prop_val;
619 res = blued_api->set_adapter_property(&prop);
620 if (res != BT_STATUS_SUCCESS) {
621 BT_ERR("set_adapter_property failed [%s]", status2string(res));
622 return convert_to_oal_status(res);
624 return OAL_STATUS_SUCCESS;
627 oal_status_t adapter_ble_multi_adv_update(int Ins_id, int min_intv, int max_intv,
628 int adv_type, int chnl_map, int tx_power, int timeout_s)
631 CHECK_OAL_INITIALIZED();
634 res = gatts_multi_adv_update(Ins_id, min_intv, max_intv,
635 adv_type, chnl_map, tx_power, timeout_s);
636 if (res != OAL_STATUS_SUCCESS) {
637 BT_ERR("gatts_multi_adv_update: [%d]", res);
640 return OAL_STATUS_SUCCESS;
643 oal_status_t adapter_ble_multi_adv_set_inst_data(int instance_id,
644 oal_ble_multi_adv_param_setup_t * adv_param_setup)
647 CHECK_OAL_INITIALIZED();
648 OAL_CHECK_PARAMETER(adv_param_setup, return);
652 res = gatts_multi_adv_set_inst_data(instance_id, adv_param_setup);
653 if (res != OAL_STATUS_SUCCESS) {
654 BT_ERR("failed: [%d]", res);
657 return OAL_STATUS_SUCCESS;
660 oal_status_t adapter_ble_multi_adv_enable(int instance_id)
663 CHECK_OAL_INITIALIZED();
666 res = gatts_multi_adv_enable(instance_id);
667 if (res != OAL_STATUS_SUCCESS) {
668 BT_ERR("failed: [%d]", res);
672 return OAL_STATUS_SUCCESS;
675 oal_status_t adapter_ble_multi_adv_disable(int instance_id)
678 CHECK_OAL_INITIALIZED();
681 res = gatts_multi_adv_disable(instance_id);
682 if (res != OAL_STATUS_SUCCESS) {
683 BT_ERR("failed: [%d]", res);
687 return OAL_STATUS_SUCCESS;
690 static void cb_adapter_properties(bt_status_t status,
692 bt_property_t *properties)
696 BT_DBG("status: %d, count: %d", status, num_properties);
698 if (status != BT_STATUS_SUCCESS) {
699 if (num_properties == 1) {
700 BT_ERR("Adapter Prop failed: status: [%s], count: %d, prop: %d",
701 status2string(status), num_properties, properties[num_properties-1].type);
703 BT_ERR("Adapter Prop failed: status: [%s], count: %d", status2string(status), num_properties);
708 for (i = 0; i < num_properties; i++) {
709 BT_DBG("prop type %d, len %d", properties[i].type, properties[i].len);
710 switch (properties[i].type) {
711 case BT_PROPERTY_VERSION: {
712 g_strlcpy(local_version, properties[i].val, BT_VERSION_STR_LEN_MAX);
713 local_version[properties[i].len] = '\0';
715 BT_DBG("Version: %s", local_version);
716 /* Send event to application */
717 if (num_properties == 1) {
718 char *adapter_ver = g_strdup(local_version);
720 /* Application has requested this property SET/GET hence send EVENT */
721 send_event(OAL_EVENT_ADAPTER_PROPERTY_VERSION, adapter_ver, strlen(adapter_ver));
725 case BT_PROPERTY_BDNAME: {
726 g_strlcpy(local_name, properties[i].val, BT_DEVICE_NAME_LENGTH_MAX);
727 local_name[properties[i].len] = '\0';
729 BT_DBG("Name: %s", local_name);
730 /* Send event to application */
731 if (num_properties == 1) {
732 char * adap_name = g_strdup(local_name);
734 /* Application has requested this property SET/GET hence send EVENT */
735 send_event(OAL_EVENT_ADAPTER_PROPERTY_NAME, adap_name, strlen(adap_name));
739 case BT_PROPERTY_BDADDR: {
742 addr = properties[i].val;
743 memcpy(local_address.addr, addr->address, 6);
744 if (num_properties == 1) {
745 /* Application has requested this property SET/GET hence send EVENT */
746 send_event(OAL_EVENT_ADAPTER_PROPERTY_ADDRESS,
747 g_memdup(&local_address, sizeof(local_address)),
748 sizeof(local_address));
752 case BT_PROPERTY_UUIDS: {
755 num_uuid = properties[i].len/sizeof(bt_uuid_t);
757 BT_DBG("num_uuid: %d", num_uuid);
759 /* Send event to application */
760 if (num_properties == 1) {
761 event_adapter_services_t *uuids_event;
763 uuids_event = g_malloc(sizeof(event_adapter_services_t) + properties[i].len);
764 memcpy(uuids_event->service_list, properties[i].val, properties[i].len);
765 uuids_event->num = num_uuid;
767 /* Application has requested this property SET/GET hence send EVENT */
768 send_event(OAL_EVENT_ADAPTER_PROPERTY_SERVICES,
769 uuids_event, (sizeof(event_adapter_services_t) + num_uuid * sizeof(bt_uuid_t)));
773 case BT_PROPERTY_ADAPTER_SCAN_MODE: {
774 bt_scan_mode_t cur_mode = *((bt_scan_mode_t *)properties[i].val);
776 BT_INFO("Scan mode (%d)", cur_mode);
778 scan_mode = cur_mode;
780 /* Send event to application */
781 if (num_properties == 1) {
782 oal_event_t event = OAL_EVENT_ADAPTER_MODE_NON_CONNECTABLE;
784 if (BT_SCAN_MODE_CONNECTABLE == cur_mode)
785 event = OAL_EVENT_ADAPTER_MODE_CONNECTABLE;
786 else if (BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE == cur_mode)
787 event = OAL_EVENT_ADAPTER_MODE_DISCOVERABLE;
789 /* Application has requested this property SET/GET hence send EVENT */
790 send_event(event, NULL, 0);
794 case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT: {
797 timeout = *((uint32_t*)properties[i].val);
799 BT_INFO("Discoverability timeout: %d", timeout);
800 discoverable_timeout = timeout;
802 send_event(OAL_EVENT_ADAPTER_MODE_DISCOVERABLE_TIMEOUT,
803 g_memdup(properties[i].val, sizeof(uint32_t)),
807 case BT_PROPERTY_ADAPTER_BONDED_DEVICES: {
810 bt_bdaddr_t *bonded_addr_list;
811 event_device_list_t *event_data;
813 num_bonded = properties[i].len/sizeof(bt_bdaddr_t);
814 BT_DBG("num_bonded %d", num_bonded);
816 if (num_properties > 1) /* No explicit req for this prop, ignore */
819 bonded_addr_list = properties[i].val;
820 event_data = g_malloc(sizeof(event_device_list_t) + num_bonded*sizeof(bt_address_t));
821 event_data->num = num_bonded;
823 for (j = 0; j < num_bonded; j++)
824 memcpy(event_data->devices[j].addr, bonded_addr_list[j].address, 6);
826 send_event(OAL_EVENT_ADAPTER_BONDED_DEVICE_LIST,
827 event_data, (sizeof(event_device_list_t) + num_bonded * sizeof(bt_bdaddr_t)));
831 BT_WARN("Unhandled property: %d", properties[i].type);
837 static void cb_adapter_discovery_state_changed(bt_discovery_state_t state)
841 event = (BT_DISCOVERY_STARTED == state) ? OAL_EVENT_ADAPTER_INQUIRY_STARTED : OAL_EVENT_ADAPTER_INQUIRY_FINISHED;
844 send_event(event, NULL, 0);
847 static void cb_adapter_device_found(int num_properties, bt_property_t *properties)
849 remote_device_t dev_info;
850 ble_adv_data_t adv_info;
856 if (num_properties == 0) {
857 BT_ERR("Unexpected, properties count is zero!!");
861 memset(&dev_info, 0x00, sizeof(remote_device_t));
862 memset(&adv_info, 0x00, sizeof(ble_adv_data_t));
864 print_bt_properties(num_properties, properties);
865 parse_device_properties(num_properties, properties, &dev_info, &adv_info);
867 BT_INFO("number of properties= [%d] ", num_properties, size);
869 if (dev_info.type != DEV_TYPE_BREDR) {
870 /* BLE Single or DUAL mode found, so it should have Adv data */
871 event_ble_dev_found_t * ble_dev_event = g_new0(event_ble_dev_found_t, 1);
873 ble_dev_event->adv_len = adv_info.len;
875 if (adv_info.len > 0 && adv_info.adv_data) {
876 memcpy(ble_dev_event->adv_data, adv_info.adv_data, adv_info.len);
877 ble_dev_event->adv_len = adv_info.len;
879 ble_dev_event->adv_len = 0;
881 ble_dev_event->device_info = dev_info;
883 event_data = ble_dev_event;
884 size = sizeof(event_ble_dev_found_t);
885 event = OAL_EVENT_ADAPTER_INQUIRY_RESULT_BLE;
887 /* BREDR device, so No Adv data */
888 event_dev_found_t * dev_event = g_new0(event_dev_found_t, 1);
890 memcpy(dev_event, &dev_info, sizeof(remote_device_t));
891 event_data = dev_event;
892 size = sizeof(remote_device_t);
893 event = OAL_EVENT_ADAPTER_INQUIRY_RESULT_BREDR_ONLY;
896 send_event(event, event_data, size);