4 * Copyright (c) 2015 -2016 Samsung Electronics Co., Ltd All Rights Reserved.
6 * Contact: Anupam Roy <anupam.r@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
33 #include "bt-hal-log.h"
34 #include "bt-hal-msg.h"
35 #include "bt-hal-utils.h"
36 #include "bt-hal-adapter-le.h"
37 #include "bt-hal-adapter-dbus-handler.h"
38 #include "bt-hal-dbus-common-utils.h"
40 #include "bt-internal-types.h"
42 #define BT_ENABLE_TIMEOUT 20000 /* 20 seconds */
43 #define BT_CORE_NAME "org.projectx.bt_core"
44 #define BT_CORE_PATH "/org/projectx/bt_core"
45 #define BT_CORE_INTERFACE "org.projectx.btcore"
47 static GDBusProxy *core_proxy = NULL;
48 static GDBusConnection *system_conn = NULL;
49 static handle_stack_msg event_cb = NULL;
51 handle_stack_msg _bt_get_adapter_event_cb(void)
59 GDBusConnection *__bt_hal_get_system_gconn(void)
61 if (system_conn == NULL)
62 system_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
67 GDBusProxy *_bt_init_core_proxy(void)
69 GDBusConnection *conn;
71 conn = __bt_hal_get_system_gconn();
75 proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
90 static GDBusProxy *__bt_get_core_proxy(void)
92 return (core_proxy) ? core_proxy : _bt_init_core_proxy();
95 /* To send stack event to hal-bluetooth handler */
96 void _bt_hal_dbus_store_stack_msg_cb(handle_stack_msg cb)
101 int _bt_hal_enable_core(void)
106 GError *error = NULL;
108 proxy = __bt_get_core_proxy();
110 return BT_HAL_ERROR_INTERNAL;
112 /* Clean up the process */
113 result = g_dbus_proxy_call_sync(proxy,
116 G_DBUS_CALL_FLAGS_NONE,
123 ERR("Bt core call failed(Error: %s)", error->message);
124 g_clear_error(&error);
126 ERR("Bt core call failed");
127 return BT_HAL_ERROR_INTERNAL;
130 g_variant_unref(result);
131 return BT_HAL_ERROR_NONE;
134 static gboolean __bt_hal_send_adapter_event(gpointer user_data)
136 struct hal_ev_adapter_state_changed ev;
137 gboolean *enable = (gboolean *)user_data;
140 ev.state = HAL_POWER_ON;
142 ev.state = HAL_POWER_OFF;
145 event_cb = _bt_get_adapter_event_cb();
148 event_cb(HAL_EV_ADAPTER_STATE_CHANGED, &ev, sizeof(ev));
154 static gboolean __bt_hal_send_le_event(gpointer user_data)
156 struct hal_ev_le_state_changed ev;
157 gboolean *enable = (gboolean *)user_data;
160 ev.state = HAL_POWER_ON;
162 ev.state = HAL_POWER_OFF;
165 event_cb = _bt_get_adapter_event_cb();
168 event_cb(HAL_EV_LE_STATE_CHANGED, &ev, sizeof(ev));
175 int _bt_hal_dbus_enable_adapter(void)
178 GError *error = NULL;
179 GVariant *result = NULL;
180 unsigned char powered = 0;
184 int le_value = VCONFKEY_BT_LE_STATUS_OFF;
185 if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &le_value))
186 ERR("fail to get vconf key!");
188 if (_bt_hal_get_adapter_powered_state(&powered) == BT_STATUS_FAIL)
189 ERR("_bt_hal_get_adapter_powered_state failed");
191 /*if LE is enabled and bluez is UP , send event from here and return.*/
192 if ((le_value == VCONFKEY_BT_LE_STATUS_ON) && (powered == 1)) {
193 gboolean *user_data = g_new0(int, 1);
195 g_idle_add(__bt_hal_send_adapter_event, (gpointer)user_data);
196 return BT_STATUS_SUCCESS;
199 if (TIZEN_FEATURE_BT_USB_DONGLE && powered == 1) {
200 gboolean *user_data = g_new0(int, 1);
202 g_idle_add(__bt_hal_send_adapter_event, (gpointer)user_data);
203 return BT_STATUS_SUCCESS;
206 proxy = __bt_get_core_proxy();
209 ERR("_bt_hal_dbus_enable_adapter: Core proxy get failed!!!");
210 return BT_STATUS_FAIL;
213 _bt_hal_set_adapter_request_state(TRUE);
214 _bt_hal_set_le_request_state(TRUE);
215 result = g_dbus_proxy_call_sync(proxy, "EnableAdapter",
217 G_DBUS_CALL_FLAGS_NONE, BT_ENABLE_TIMEOUT,
220 ERR("EnableAdapter failed: %s", error->message);
221 g_clear_error(&error);
223 _bt_hal_set_adapter_request_state(FALSE);
224 _bt_hal_set_le_request_state(FALSE);
225 result = g_dbus_proxy_call_sync(proxy,
228 G_DBUS_CALL_FLAGS_NONE,
234 ERR("Bt core call failed(Error: %s)", error->message);
235 g_clear_error(&error);
237 g_variant_unref(result);
239 /* TODO: Terminate bluetooth service or not, need to check */
240 /*g_idle_add((GSourceFunc)_bt_terminate_service, NULL);*/
241 return BT_STATUS_FAIL;
244 g_variant_unref(result);
245 return BT_STATUS_SUCCESS;
248 int _bt_hal_dbus_disable_adapter(void)
251 GError *error = NULL;
252 GVariant *result = NULL;
255 proxy = __bt_get_core_proxy();
257 ERR("_bt_hal_dbus_enable_adapter: Core proxy get failed!!!");
258 return BT_STATUS_FAIL;
261 result = g_dbus_proxy_call_sync(proxy, "DisableAdapter",
263 G_DBUS_CALL_FLAGS_NONE, -1,
266 ERR("DisableAdapter failed: %s", error->message);
267 g_clear_error(&error);
269 g_variant_unref(result);
271 /* TODO: Terminate bluetooth service or not, need to check */
272 /*g_idle_add((GSourceFunc)_bt_terminate_service, NULL);*/
273 return BT_STATUS_FAIL;
276 g_variant_unref(result);
277 return BT_STATUS_SUCCESS;
280 int _bt_hal_dbus_recover_adapter(void)
283 GVariant *result = NULL;
284 GError *error = NULL;
287 proxy = __bt_get_core_proxy();
289 ERR("_bt_hal_dbus_recover_adapter: Core proxy get failed!!!");
290 return BT_STATUS_FAIL;
293 result = g_dbus_proxy_call_sync(proxy, "RecoverAdapter",
295 G_DBUS_CALL_FLAGS_NONE, -1,
298 ERR("RecoverAdapter failed: %s", error->message);
299 g_clear_error(&error);
301 return BT_STATUS_FAIL;
304 g_variant_unref(result);
305 return BT_STATUS_SUCCESS;
309 int _bt_hal_dbus_enable_le(void)
312 GError *error = NULL;
313 GVariant *result = NULL;
314 int adapter_value = VCONFKEY_BT_STATUS_OFF;
315 unsigned char powered = 0;
319 if (vconf_get_int(VCONFKEY_BT_STATUS, &adapter_value) != 0)
320 ERR("fail to get vconf key!");
322 if (_bt_hal_get_adapter_powered_state(&powered) == BT_STATUS_FAIL)
323 ERR("_bt_hal_get_adapter_powered_state failed");
325 if ((adapter_value == VCONFKEY_BT_STATUS_ON) && (powered == 1)) {
326 gboolean *user_data = g_new0(int, 1);
328 g_idle_add(__bt_hal_send_le_event, (gpointer)user_data);
329 return BT_STATUS_SUCCESS;
332 proxy = __bt_get_core_proxy();
335 DBG("_bt_hal_dbus_enable_le: Core proxy get failed!!!");
336 return BT_STATUS_FAIL;
338 _bt_hal_set_le_request_state(TRUE);
340 result = g_dbus_proxy_call_sync(proxy, "EnableAdapterLe",
342 G_DBUS_CALL_FLAGS_NONE, BT_ENABLE_TIMEOUT,
345 DBG("EnableAdapterLe failed: %s", error->message);
346 g_clear_error(&error);
348 result = g_dbus_proxy_call_sync(proxy,
351 G_DBUS_CALL_FLAGS_NONE,
356 _bt_hal_set_le_request_state(FALSE);
358 DBG("Bt core call failed(Error: %s)", error->message);
359 g_clear_error(&error);
361 g_variant_unref(result);
363 return BT_STATUS_FAIL;
367 g_variant_unref(result);
368 return BT_STATUS_SUCCESS;
371 int _bt_hal_dbus_disable_le(void)
374 GError *error = NULL;
375 GVariant *result = NULL;
376 int adapter_value = VCONFKEY_BT_STATUS_OFF;
379 if (vconf_get_int(VCONFKEY_BT_STATUS, &adapter_value) != 0)
380 ERR("fail to get vconf key!");
382 if (adapter_value == VCONFKEY_BT_STATUS_ON) {
383 gboolean *user_data = g_new0(int, 1);
385 g_idle_add(__bt_hal_send_le_event, (gpointer)user_data);
386 return BT_STATUS_SUCCESS;
389 proxy = __bt_get_core_proxy();
392 DBG("_bt_hal_dbus_disable_le: Core proxy get failed!!!");
393 return BT_STATUS_FAIL;
396 result = g_dbus_proxy_call_sync(proxy, "DisableAdapterLe",
398 G_DBUS_CALL_FLAGS_NONE, -1,
401 DBG("DisableAdapter failed: %s", error->message);
402 g_clear_error(&error);
404 g_variant_unref(result);
405 return BT_STATUS_FAIL;
411 g_variant_unref(result);
412 return BT_STATUS_SUCCESS;
417 int _bt_hal_dbus_reset_adapter(void)
421 GError *error = NULL;
424 proxy = __bt_get_core_proxy();
426 return BT_STATUS_FAIL;
428 result = g_dbus_proxy_call_sync(proxy,
431 G_DBUS_CALL_FLAGS_NONE,
438 ERR("Failed to ResetAdapter (Error: %s)", error->message);
439 g_clear_error(&error);
441 ERR("Failed to ResetAdapter");
442 return BT_STATUS_FAIL;
445 g_variant_unref(result);
446 return BT_STATUS_SUCCESS;
450 int _bt_hal_dbus_start_discovery(gboolean is_custom,
451 bt_disc_role_type_t role)
454 GError *error = NULL;
456 const gchar *disc_type;
457 DBG("Discovery Type: Is Custom : [%s]", is_custom ? "TRUE" : "FALSE");
459 proxy = _bt_hal_get_adapter_proxy();
461 DBG("Adapter proxy get failed!!!");
462 return BT_STATUS_FAIL;
466 if (role == BT_DISC_ROLE_BREDR)
468 else if (role == BT_DISC_ROLE_LE)
470 else if (role == BT_DISC_ROLE_DUAL)
471 disc_type = "LE_BREDR";
473 return BT_STATUS_PARM_INVALID;
475 result = g_dbus_proxy_call_sync(proxy,
476 "StartCustomDiscovery",
477 g_variant_new("s", disc_type),
478 G_DBUS_CALL_FLAGS_NONE,
483 result = g_dbus_proxy_call_sync(proxy,
486 G_DBUS_CALL_FLAGS_NONE,
493 ERR("StartDiscovery failed (Error: %s)", error->message);
494 g_clear_error(&error);
496 ERR("StartDiscovery failed");
497 return BT_STATUS_FAIL;
500 /* discovery status will be change in event */
502 g_variant_unref(result);
503 return BT_STATUS_SUCCESS;
506 int _bt_hal_dbus_stop_discovery(void)
509 GError *error = NULL;
513 proxy = _bt_hal_get_adapter_proxy();
515 DBG("_bt_hal_dbus_stop_discovery: Adapter proxy get failed!!!");
516 return BT_STATUS_FAIL;
519 result = g_dbus_proxy_call_sync(proxy,
522 G_DBUS_CALL_FLAGS_NONE,
529 ERR("StopDiscovery failed (Error: %s)", error->message);
530 g_clear_error(&error);
532 ERR("StopDiscovery failed");
533 return BT_STATUS_FAIL;
536 /* discovery status will be change in event */
538 g_variant_unref(result);
539 return BT_STATUS_SUCCESS;
542 static gboolean __bt_adapter_all_properties_cb(gpointer user_data)
544 GVariant *result = user_data;
545 GVariantIter *property_iter;
549 /* Buffer and propety count management */
550 uint8_t buf[BT_HAL_MAX_PROPERTY_BUF_SIZE];
551 struct hal_ev_adapter_props_changed *ev = (void*) buf;
553 gchar *address = NULL;
555 unsigned int cod = 0;
556 gboolean discoverable;
557 gboolean connectable;
558 unsigned int scan_mode = BT_SCAN_MODE_NONE;
559 unsigned int disc_timeout;
561 gboolean is_discovering;
562 gboolean is_le_discovering;
563 uint8_t ipsp_initialized;
566 unsigned int pairable_timeout;
567 gboolean scan_mode_property_update = FALSE;
571 memset(buf, 0, sizeof(buf));
574 ev->status = BT_STATUS_SUCCESS;
576 DBG("@@Start parsing properties");
577 g_variant_get(result, "(a{sv})", &property_iter);
578 while (g_variant_iter_loop(property_iter, "{sv}", &key, &value)) {
579 if (!g_strcmp0(key, "Address")) {
582 address = (gchar *) g_variant_get_string(value, NULL);
583 DBG("Address [%s]", address);
584 _bt_hal_convert_addr_string_to_type(bdaddr, address);
585 size += __bt_insert_hal_properties(buf + size,
586 HAL_PROP_ADAPTER_ADDR, sizeof(bdaddr), bdaddr);
588 } else if (!g_strcmp0(key, "Alias")) {
589 name = (gchar *) g_variant_get_string(value, NULL);
590 DBG("Alias [%s]", name);
591 size += __bt_insert_hal_properties(buf + size,
592 HAL_PROP_ADAPTER_NAME, strlen(name) + 1, name);
594 } else if (!g_strcmp0(key, "Class")) {
595 cod = g_variant_get_uint32(value);
596 DBG("Class [%d]", cod);
597 size += __bt_insert_hal_properties(buf + size,
598 HAL_PROP_ADAPTER_CLASS, sizeof(unsigned int), &cod);
600 } else if (!g_strcmp0(key, "Discoverable")) {
601 discoverable = g_variant_get_boolean(value);
602 DBG("Discoverable [%d]", discoverable);
604 scan_mode = BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
605 scan_mode_property_update = TRUE;
606 } else if (!g_strcmp0(key, "DiscoverableTimeout")) {
607 disc_timeout = g_variant_get_uint32(value);
608 DBG("Discoverable Timeout [%d]", disc_timeout);
609 size += __bt_insert_hal_properties(buf + size,
610 HAL_PROP_ADAPTER_DISC_TIMEOUT, sizeof(unsigned int), &disc_timeout);
612 } else if (!g_strcmp0(key, "Connectable")) {
613 connectable = g_variant_get_boolean(value);
614 DBG("Connectable [%d]", connectable);
615 if (scan_mode == BT_SCAN_MODE_NONE)
616 scan_mode = BT_SCAN_MODE_CONNECTABLE;
617 scan_mode_property_update = TRUE;
618 } else if (!g_strcmp0(key, "Version")) {
619 version = (gchar *) g_variant_get_string(value, NULL);
620 DBG("Version [%s]", version);
621 size += __bt_insert_hal_properties(buf + size,
622 HAL_PROP_ADAPTER_VERSION, strlen(version) + 1, version);
624 } else if (!g_strcmp0(key, "Name")) {
625 name = (gchar *) g_variant_get_string(value, NULL);
626 DBG("Name [%s]", name);
627 size += __bt_insert_hal_properties(buf + size,
628 HAL_PROP_ADAPTER_NAME, strlen(name) + 1, name);
630 } else if (!g_strcmp0(key, "Powered")) {
631 powered = g_variant_get_boolean(value);
632 DBG("Powered = [%d]", powered);
633 } else if (!g_strcmp0(key, "Pairable")) {
634 pairable = (g_variant_get_boolean(value) ? 1 : 0);
635 DBG("Pairable [%d]", pairable);
636 size += __bt_insert_hal_properties(buf + size,
637 HAL_PROP_ADAPTER_PAIRABLE, sizeof(uint8_t), &pairable);
639 } else if (!g_strcmp0(key, "PairableTimeout")) {
640 pairable_timeout = g_variant_get_uint32(value);
641 DBG("Pairable Timeout = [%d]", pairable_timeout);
642 size += __bt_insert_hal_properties(buf + size,
643 HAL_PROP_ADAPTER_PAIRABLE_TIMEOUT, sizeof(unsigned int), &pairable_timeout);
645 } else if (!g_strcmp0(key, "UUIDs")) {
650 size1 = g_variant_get_size(value);
651 int num_props_tmp = ev->num_props;
653 uuid_value = (char **)g_variant_get_strv(value, &size1);
654 for (i = 0; uuid_value[i] != NULL; i++)
656 /* UUID collection */
657 uint8_t uuids[HAL_UUID_LEN * uuid_count];
658 for (i = 0; uuid_value[i] != NULL; i++) {
659 char *uuid_str = NULL;
660 uint8_t uuid[HAL_UUID_LEN];
661 uuid_str = g_strdup(uuid_value[i]);
662 DBG("UUID string [%s]\n", uuid_str);
663 _bt_hal_convert_uuid_string_to_type(uuid, uuid_str);
664 memcpy(uuids + i * HAL_UUID_LEN, uuid, HAL_UUID_LEN);
667 size += __bt_insert_hal_properties(buf + size, HAL_PROP_ADAPTER_UUIDS,
668 (HAL_UUID_LEN * uuid_count),
670 ev->num_props = num_props_tmp + 1;
673 } else if (!g_strcmp0(key, "Discovering")) {
674 is_discovering = g_variant_get_boolean(value);
675 DBG("Discovering = [%d]", is_discovering);
676 } else if (!g_strcmp0(key, "LEDiscovering")) {
677 is_le_discovering = g_variant_get_boolean(value);
678 DBG("LE Discovering = [%d]", is_le_discovering);
679 } else if (!g_strcmp0(key, "Modalias")) {
680 char *modalias = NULL;
681 g_variant_get(value, "s", &modalias);
682 DBG("Adapter ModAlias [%s]", modalias);
683 size += __bt_insert_hal_properties(buf + size,
684 HAL_PROP_ADAPTER_MODALIAS, strlen(modalias) + 1, modalias);
687 } else if (!g_strcmp0(key, "SupportedLEFeatures")) {
688 DBG("LE Supported features");
691 GVariantIter *iter = NULL;
692 bt_local_le_features_t le_features;
693 gboolean le_features_present = FALSE;
695 memset(&le_features, 0x00, sizeof(le_features));
697 g_variant_get(value, "as", &iter);
699 while (g_variant_iter_loop(iter, "s", &name)) {
700 DBG("name = %s", name);
701 g_variant_iter_loop(iter, "s", &val);
702 DBG("Value = %s", val);
703 _bt_hal_update_le_feature_support(name, val, &le_features);
704 le_features_present = TRUE;
706 g_variant_iter_free(iter);
708 if (le_features_present) {
709 size += __bt_insert_hal_properties(buf + size,
710 HAL_PROP_ADAPTER_LOCAL_LE_FEAT, sizeof(le_features), &le_features);
713 DBG("le supported features values are NOT provided by Stack");
716 } else if (!g_strcmp0(key, "IpspInitStateChanged")) {
717 ipsp_initialized = (g_variant_get_boolean(value) ? 1 : 0);
718 DBG("IPSP Initialized = %d", ipsp_initialized);
719 size += __bt_insert_hal_properties(buf + size,
720 HAL_PROP_ADAPTER_IPSP_INITIALIZED, sizeof(uint8_t), &ipsp_initialized);
723 ERR("Unhandled Property:[%s]", key);
727 if (scan_mode_property_update) {
728 size += __bt_insert_hal_properties(buf + size,
729 HAL_PROP_ADAPTER_SCAN_MODE, sizeof(int), &scan_mode);
734 event_cb = _bt_get_adapter_event_cb();
736 ERR("event_cb is NULL");
741 DBG("Send Adapter properties changed event to HAL user,"
742 " Num Prop [%d] total size [%zd]", ev->num_props, size);
743 event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size);
746 g_variant_unref(result);
747 g_variant_iter_free(property_iter);
751 static int __bt_hal_dbus_get_all_adapter_properties(void)
755 GError *error = NULL;
759 proxy = _bt_hal_get_adapter_properties_proxy();
761 DBG("Adapter Properties proxy get failed!!!");
762 return BT_STATUS_FAIL;
765 result = g_dbus_proxy_call_sync(proxy,
767 g_variant_new("(s)", BT_HAL_ADAPTER_INTERFACE),
768 G_DBUS_CALL_FLAGS_NONE,
775 ERR("Failed to get all adapter properties (Error: %s)", error->message);
776 g_clear_error(&error);
778 ERR("Failed to get all adapter properties");
779 return BT_STATUS_FAIL;
782 DBG("Got All properties from Bluez Stack!!, time to start parsing");
784 * As we need to provide async callback to user from HAL, simply schedule a
785 * callback method which will carry actual result
787 g_idle_add(__bt_adapter_all_properties_cb, (gpointer)result);
790 return BT_STATUS_SUCCESS;
793 int _bt_hal_dbus_get_adapter_properties(void)
797 return __bt_hal_dbus_get_all_adapter_properties();
800 int _bt_hal_get_adapter_powered_state(uint8_t *state)
802 char *adapter_path = NULL;
803 gboolean powered = FALSE;
804 int ret = BT_STATUS_FAIL;
806 /* Check Valid Adapter Path, followed by Adapter Powered state.
807 If any of these fails, adapter will be considered Disabled */
808 adapter_path = _bt_hal_get_adapter_path();
810 if (adapter_path == NULL) {
811 INFO("adapter_path is NULL");
812 g_free(adapter_path);
817 /* Check Adapter Powered Status */
818 ret = _bt_hal_is_adapter_powered(&powered);
819 if (BT_STATUS_FAIL == ret) {
820 INFO("Adapter is not powered");
821 g_free(adapter_path);
826 g_free(adapter_path);
836 /* Get Discoverable timeout API and callback */
837 static gboolean __bt_adapter_discovery_timeout_cb(gpointer user_data)
839 /* Buffer and propety count management */
840 uint8_t buf[BT_HAL_MAX_PROPERTY_BUF_SIZE];
841 struct hal_ev_adapter_props_changed *ev = (void*) buf;;
843 unsigned int *timeout = user_data;
845 memset(buf, 0, sizeof(buf));
848 ev->status = BT_STATUS_SUCCESS;
850 DBG("Discovery timeout in callback: [%d]", *timeout);
852 size += __bt_insert_hal_properties(buf + size, HAL_PROP_ADAPTER_DISC_TIMEOUT,
853 sizeof(unsigned int), timeout);
856 DBG("Timeout value [%d] property Num [%d]", *timeout, ev->num_props);
859 event_cb = _bt_get_adapter_event_cb();
861 ERR("event_cb is NULL");
866 DBG("Send Adapter Properties changed event to HAL user,"
867 " Num Prop [%d] total size [%zd]", ev->num_props, size);
868 event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size);
875 int _bt_hal_dbus_get_discovery_timeout(void)
880 GError *error = NULL;
881 unsigned int *timeout;
884 proxy = _bt_hal_get_adapter_properties_proxy();
886 DBG("Adapter Properties proxy get failed!!!");
887 return BT_STATUS_FAIL;
890 result = g_dbus_proxy_call_sync(proxy,
892 g_variant_new("(ss)", BT_HAL_ADAPTER_INTERFACE,
893 "DiscoverableTimeout"),
894 G_DBUS_CALL_FLAGS_NONE,
901 ERR("Failed to get local version (Error: %s)", error->message);
902 g_clear_error(&error);
904 ERR("Failed to get local version");
905 return BT_STATUS_FAIL;
908 timeout = g_malloc0(sizeof(int));
910 ERR("Memory allocation failed");
911 g_variant_unref(result);
912 return BT_STATUS_FAIL;
915 g_variant_get(result, "(v)", &temp);
916 *timeout = g_variant_get_uint32(temp);
917 DBG("Timeout value: [%d]", *timeout);
919 g_variant_unref(result);
920 g_variant_unref(temp);
923 * As we need to provide async callback to user from HAL, simply schedule a
924 * callback method which will carry actual result
926 g_idle_add(__bt_adapter_discovery_timeout_cb, (gpointer) timeout);
929 return BT_STATUS_SUCCESS;
932 int _bt_hal_dbus_get_adapter_class(unsigned int *adapter_class)
937 GError *error = NULL;
940 proxy = _bt_hal_get_adapter_properties_proxy();
942 DBG("Adapter Properties proxy get failed!!!");
943 return BT_STATUS_FAIL;
946 result = g_dbus_proxy_call_sync(proxy,
948 g_variant_new("(ss)", BT_HAL_ADAPTER_INTERFACE,
950 G_DBUS_CALL_FLAGS_NONE,
957 ERR("Failed to get class (Error: %s)", error->message);
958 g_clear_error(&error);
960 ERR("Failed to get class");
961 return BT_STATUS_FAIL;
965 g_variant_get(result, "(v)", &temp);
966 *adapter_class = g_variant_get_uint32(temp);
967 DBG("Class value: [0x%06x]", *adapter_class);
969 g_variant_unref(result);
970 g_variant_unref(temp);
973 return BT_STATUS_SUCCESS;
976 /* Get Discoverable Mode API and callback */
977 static gboolean __bt_adapter_scan_mode_cb(gpointer user_data)
979 /* Buffer and propety count management */
980 uint8_t buf[BT_HAL_MAX_PROPERTY_BUF_SIZE];
981 struct hal_ev_adapter_props_changed *ev = (void*) buf;;
983 int *mode = user_data;
985 memset(buf, 0, sizeof(buf));
988 ev->status = BT_STATUS_SUCCESS;
990 DBG("Scan mode callback: [%d]", *mode);
992 size += __bt_insert_hal_properties(buf + size, HAL_PROP_ADAPTER_SCAN_MODE,
996 DBG("Scan mode [%d] property Num [%d]", *mode, ev->num_props);
999 event_cb = _bt_get_adapter_event_cb();
1001 ERR("event_cb is NULL");
1006 DBG("Send Adapter Properties changed event to HAL user,"
1007 " Num Prop [%d] total size [%zd]", ev->num_props, size);
1008 event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size);
1015 int _bt_hal_dbus_get_scan_mode(void)
1018 gboolean discoverable;
1019 gboolean connectable;
1022 GError *error = NULL;
1027 proxy = _bt_hal_get_adapter_properties_proxy();
1029 DBG("Adapter Properties proxy get failed!!!");
1030 return BT_STATUS_FAIL;
1033 result = g_dbus_proxy_call_sync(proxy,
1035 g_variant_new("(ss)", BT_HAL_ADAPTER_INTERFACE,
1037 G_DBUS_CALL_FLAGS_NONE,
1043 if (error != NULL) {
1044 ERR("Failed to get discoverable mode (Error: %s)", error->message);
1045 g_clear_error(&error);
1047 ERR("Failed to get discoverable mode");
1048 return BT_STATUS_FAIL;
1051 g_variant_get(result, "(v)", &temp);
1052 discoverable = g_variant_get_boolean(temp);
1053 DBG("discoverable:%d", discoverable);
1055 g_variant_unref(result);
1056 g_variant_unref(temp);
1058 if (!discoverable) {
1059 result = g_dbus_proxy_call_sync(proxy,
1061 g_variant_new("(ss)", BT_HAL_ADAPTER_INTERFACE,
1063 G_DBUS_CALL_FLAGS_NONE,
1068 if (error != NULL) {
1069 ERR("Failed to get connectable mode (Error: %s)", error->message);
1070 g_clear_error(&error);
1072 ERR("Failed to get connectable mode");
1073 return BT_STATUS_FAIL;
1076 g_variant_get(result, "(v)", &temp);
1077 connectable = g_variant_get_boolean(temp);
1078 DBG("connectable:%d", connectable);
1080 g_variant_unref(result);
1081 g_variant_unref(temp);
1084 scan_mode = g_malloc0(sizeof(int));
1086 ERR("Memory allocation failed");
1087 return BT_STATUS_FAIL;
1091 *scan_mode = BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
1092 else if (connectable)
1093 *scan_mode = BT_SCAN_MODE_CONNECTABLE;
1095 *scan_mode = BT_SCAN_MODE_NONE;
1098 * As we need to provide async callback to user from HAL, simply schedule a
1099 * callback method which will carry actual result
1101 g_idle_add(__bt_adapter_scan_mode_cb, (gpointer) scan_mode);
1104 return BT_STATUS_SUCCESS;
1107 /* Get Local Version API and callback */
1108 static gboolean __bt_adapter_local_version_cb(gpointer user_data)
1110 /* Buffer and propety count management */
1111 uint8_t buf[BT_HAL_MAX_PROPERTY_BUF_SIZE];
1112 struct hal_ev_adapter_props_changed *ev = (void*) buf;;
1114 char *version = NULL;
1116 memset(buf, 0, sizeof(buf));
1119 ev->status = BT_STATUS_SUCCESS;
1121 version = (char*) user_data;
1122 DBG("Local Version in callback: [%s]", version);
1124 size += __bt_insert_hal_properties(buf + size, HAL_PROP_ADAPTER_VERSION,
1125 (strlen(version) + 1), version);
1128 DBG("Device version [%s] property Num [%d]", version, ev->num_props);
1131 event_cb = _bt_get_adapter_event_cb();
1133 ERR("event_cb is NULL");
1138 DBG("Send Adapter Properties changed event to HAL user,"
1139 " Num Prop [%d] total size [%zd]", ev->num_props, size);
1140 event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size);
1147 int _bt_hal_dbus_get_local_version(void)
1150 const char *version = NULL;
1153 GError *error = NULL;
1156 proxy = _bt_hal_get_adapter_properties_proxy();
1158 DBG("Adapter Properties proxy get failed!!!");
1159 return BT_STATUS_FAIL;
1162 result = g_dbus_proxy_call_sync(proxy,
1164 g_variant_new("(ss)", BT_HAL_ADAPTER_INTERFACE,
1166 G_DBUS_CALL_FLAGS_NONE,
1172 if (error != NULL) {
1173 ERR("Failed to get local version (Error: %s)", error->message);
1174 g_clear_error(&error);
1176 ERR("Failed to get local version");
1177 return BT_STATUS_FAIL;
1180 g_variant_get(result, "(v)", &temp);
1181 version = g_variant_dup_string(temp, NULL);
1182 DBG("Local Version: [%s]", version);
1184 g_variant_unref(result);
1185 g_variant_unref(temp);
1188 * As we need to provide async callback to user from HAL, simply schedule a
1189 * callback method which will carry actual result
1191 g_idle_add(__bt_adapter_local_version_cb, (gpointer) version);
1194 return BT_STATUS_SUCCESS;
1197 /* Get Local Name API and callback */
1198 static gboolean __bt_adapter_local_name_cb(gpointer user_data)
1200 /* Buffer and propety count management */
1201 uint8_t buf[BT_HAL_MAX_PROPERTY_BUF_SIZE];
1202 struct hal_ev_adapter_props_changed *ev = (void*) buf;;
1206 memset(buf, 0, sizeof(buf));
1209 ev->status = BT_STATUS_SUCCESS;
1211 name = (char*) user_data;
1212 DBG("Local Name in callback: [%s]", name);
1214 size += __bt_insert_hal_properties(buf + size, HAL_PROP_ADAPTER_NAME,
1215 strlen(name) + 1, name);
1218 DBG("Device name [%s] property Num [%d]", name, ev->num_props);
1221 event_cb = _bt_get_adapter_event_cb();
1223 ERR("event_cb is NULL");
1228 DBG("Send Adapter Properties changed event to HAL user,"
1229 " Num Prop [%d] total size [%zd]", ev->num_props, size);
1230 event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size);
1237 int _bt_hal_dbus_get_local_name(void)
1240 const char *name = NULL;
1243 GError *error = NULL;
1245 proxy = _bt_hal_get_adapter_properties_proxy();
1247 DBG("Adapter Properties proxy get failed!!!");
1248 return BT_STATUS_FAIL;
1251 result = g_dbus_proxy_call_sync(proxy,
1253 g_variant_new("(ss)", BT_HAL_ADAPTER_INTERFACE,
1255 G_DBUS_CALL_FLAGS_NONE,
1261 if (error != NULL) {
1262 ERR("Failed to get local name (Error: %s)", error->message);
1263 g_clear_error(&error);
1265 ERR("Failed to get local name");
1266 return BT_STATUS_FAIL;
1269 g_variant_get(result, "(v)", &temp);
1270 name = g_variant_dup_string(temp, NULL);
1271 DBG("Local Name: [%s]", name);
1273 g_variant_unref(result);
1274 g_variant_unref(temp);
1277 * As we need to provide async callback to user from HAL, simply schedule a
1278 * callback method which will carry actual result
1280 g_idle_add(__bt_adapter_local_name_cb, (gpointer) name);
1282 return BT_STATUS_SUCCESS;
1285 /* Get Local Address API and callback */
1286 static gboolean __bt_adapter_local_address_cb(gpointer user_data)
1288 /* Buffer and propety count management */
1289 uint8_t buf[BT_HAL_MAX_PROPERTY_BUF_SIZE];
1290 struct hal_ev_adapter_props_changed *ev = (void*) buf;
1292 char * address = NULL;
1294 memset(buf, 0, sizeof(buf));
1297 ev->status = BT_STATUS_SUCCESS;
1299 address = (char*) user_data;
1302 _bt_hal_convert_addr_string_to_type(bdaddr, address);
1304 size += __bt_insert_hal_properties(buf + size, HAL_PROP_DEVICE_ADDR,
1305 sizeof(bdaddr), bdaddr);
1308 DBG("Device address [%s] property Num [%d]", address, ev->num_props);
1310 size += __bt_insert_hal_properties(buf + size, HAL_PROP_ADAPTER_ADDR,
1311 sizeof(bdaddr), bdaddr);
1314 event_cb = _bt_get_adapter_event_cb();
1316 ERR("event_cb is NULL");
1321 DBG("Send Device found event to HAL user,"
1322 " Num Prop [%d] total size [%zd]", ev->num_props, size);
1323 event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size);
1330 int _bt_hal_dbus_get_local_address(void)
1333 GError *error = NULL;
1334 const char *address;
1338 proxy = _bt_hal_get_adapter_properties_proxy();
1340 DBG("_bt_hal_dbus_get_local_address: Adapter Properties proxy get failed!!!");
1341 return BT_STATUS_FAIL;
1344 result = g_dbus_proxy_call_sync(proxy,
1346 g_variant_new("(ss)", BT_HAL_ADAPTER_INTERFACE,
1348 G_DBUS_CALL_FLAGS_NONE,
1354 ERR("Failed to get local address");
1355 if (error != NULL) {
1356 ERR("Failed to get local address (Error: %s)", error->message);
1357 g_clear_error(&error);
1359 return BT_STATUS_FAIL;
1362 g_variant_get(result, "(v)", &temp);
1363 address = g_variant_dup_string(temp, NULL);
1366 DBG("Address:%s", address);
1368 return BT_STATUS_FAIL;
1370 g_variant_unref(result);
1371 g_variant_unref(temp);
1374 * As we need to provide async callback to user from HAL, simply schedule a
1375 * callback method which will carry actual result
1377 g_idle_add(__bt_adapter_local_address_cb, (gpointer) address);
1379 return BT_STATUS_SUCCESS;
1382 /* Get Local services API and callback */
1383 static gboolean __bt_adapter_service_uuids_cb(gpointer user_data)
1385 GVariant *result = user_data;
1387 GVariantIter *iter = NULL;
1390 /* Buffer and propety count management */
1391 uint8_t buf[BT_HAL_MAX_PROPERTY_BUF_SIZE];
1392 struct hal_ev_adapter_props_changed *ev = (void*) buf;
1395 /* UUID collection */
1396 uint8_t uuids[HAL_UUID_LEN * MAX_UUID_COUNT];
1399 memset(buf, 0, sizeof(buf));
1402 ev->status = BT_STATUS_SUCCESS;
1404 g_variant_get(result, "(v)", &temp);
1405 g_variant_get(temp, "as", &iter);
1407 ERR("Failed to get UUIDs");
1411 while (g_variant_iter_loop(iter, "s", &uuid_str)) {
1412 uint8_t uuid[HAL_UUID_LEN];
1414 DBG("UUID string [%s]\n", uuid_str);
1415 _bt_hal_convert_uuid_string_to_type(uuid, uuid_str);
1416 memcpy(uuids + uuid_count * HAL_UUID_LEN, uuid, HAL_UUID_LEN);
1420 size += __bt_insert_hal_properties(buf + size,
1421 HAL_PROP_ADAPTER_UUIDS,
1422 (HAL_UUID_LEN * uuid_count),
1427 event_cb = _bt_get_adapter_event_cb();
1429 ERR("event_cb is NULL");
1434 DBG("Send Adapter properties changed event to HAL user,"
1435 " Num Prop [%d] total size [%zd]", ev->num_props, size);
1436 event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size);
1439 g_variant_iter_free(iter);
1440 g_variant_unref(result);
1441 g_variant_unref(temp);
1445 event_cb = _bt_get_adapter_event_cb();
1447 ev->status = BT_STATUS_FAIL;
1449 DBG("Send Adapter properties changed event to HAL user,"
1450 " Num Prop [%d] total size [%zd]", ev->num_props, size);
1451 event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size);
1454 g_variant_unref(result);
1458 int _bt_hal_dbus_get_adapter_supported_uuids(void)
1461 GError *error = NULL;
1464 proxy = _bt_hal_get_adapter_properties_proxy();
1466 DBG("Adapter Properties proxy get failed!!!");
1467 return BT_STATUS_FAIL;
1470 result = g_dbus_proxy_call_sync(proxy,
1472 g_variant_new("(ss)", BT_HAL_ADAPTER_INTERFACE,
1474 G_DBUS_CALL_FLAGS_NONE,
1480 if (error != NULL) {
1481 ERR("Failed to get UUIDs (Error: %s)", error->message);
1482 g_clear_error(&error);
1484 ERR("Failed to get UUIDs");
1485 return BT_STATUS_FAIL;
1489 DBG("Got All Adaptr service UUID's from Bluez Stack!!, time to start parsing");
1492 * As we need to provide async callback to user from HAL, simply schedule a
1493 * callback method which will carry actual result
1495 g_idle_add(__bt_adapter_service_uuids_cb, (gpointer)result);
1497 return BT_STATUS_SUCCESS;
1500 static gboolean __is_device_paired(GVariantIter *item_iter)
1502 gboolean paired = FALSE;
1506 while (g_variant_iter_loop(item_iter, "{sv}", &key, &value)) {
1507 if (NULL == key || g_strcmp0(key, "Paired"))
1510 paired = g_variant_get_boolean(value);
1511 g_variant_unref(value);
1519 static gboolean __bt_adapter_bonded_devices_cb(gpointer user_data)
1521 /* Buffer and propety count management */
1522 uint8_t buf[BT_HAL_MAX_PROPERTY_BUF_SIZE];
1523 uint8_t addresses[BT_HAL_MAX_PROPERTY_BUF_SIZE];
1524 struct hal_ev_adapter_props_changed *ev = (void*) buf;;
1528 GVariant *result = user_data;
1530 GVariantIter *interface_iter;
1531 GVariantIter *svc_iter;
1532 char *object_path = NULL;
1533 char *interface_str = NULL;
1535 char device_address[BT_HAL_ADDRESS_STRING_SIZE];
1536 uint8_t bdaddr[BT_HAL_ADDRESS_LENGTH_MAX];
1538 memset(buf, 0, sizeof(buf));
1541 ev->status = BT_STATUS_SUCCESS;
1543 INFO("Size [%zd]", size);
1545 /* signature of GetManagedObjects: a{oa{sa{sv}}} */
1546 g_variant_get(result, "(a{oa{sa{sv}}})", &iter);
1548 /* Parse the signature: {oa{sa{sv}}} */
1549 while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path, &interface_iter)) {
1550 if (object_path == NULL)
1553 while (g_variant_iter_loop(interface_iter, "{sa{sv}}",
1554 &interface_str, &svc_iter)) {
1555 if (g_strcmp0(interface_str, "org.bluez.Device1") == 0) {
1556 DBG("Found a device: %s", object_path);
1557 if (__is_device_paired(svc_iter)) {
1558 _bt_hal_convert_device_path_to_address(object_path, device_address);
1559 DBG("Paired Device Address: [%s]", device_address);
1561 _bt_hal_convert_addr_string_to_type(bdaddr, device_address);
1562 memcpy((addresses + (count * BT_HAL_ADDRESS_LENGTH_MAX)),
1563 bdaddr, BT_HAL_ADDRESS_LENGTH_MAX);
1566 g_variant_iter_free(svc_iter);
1567 g_free(interface_str);
1568 interface_str = NULL;
1574 g_variant_iter_free(iter);
1575 g_variant_unref(result);
1577 size += __bt_insert_hal_properties((buf + size),
1578 HAL_PROP_ADAPTER_BONDED_DEVICES,
1579 (count * BT_HAL_ADDRESS_LENGTH_MAX), addresses);
1583 event_cb = _bt_get_adapter_event_cb();
1585 ERR("event_cb is NULL");
1590 DBG("Send Adapter properties changed event to HAL user,"
1591 " Num Prop [%d] total size [%zd]", ev->num_props, size);
1592 event_cb(HAL_EV_ADAPTER_PROPS_CHANGED, (void*) buf, size);
1598 int _bt_hal_dbus_get_bonded_devices(void)
1600 GDBusProxy *manager_proxy;
1601 GVariant *result = NULL;
1603 manager_proxy = _bt_hal_get_manager_proxy();
1604 if (manager_proxy == NULL)
1605 return BT_STATUS_FAIL;
1607 result = g_dbus_proxy_call_sync(manager_proxy, "GetManagedObjects",
1609 G_DBUS_CALL_FLAGS_NONE,
1614 ERR("Can't get managed objects");
1615 return BT_STATUS_FAIL;
1619 * As we need to provide async callback to user from HAL, simply schedule a
1620 * callback method which will carry actual result
1622 g_idle_add(__bt_adapter_bonded_devices_cb, (gpointer) result);
1624 return BT_STATUS_SUCCESS;
1627 int _bt_hal_dbus_get_adapter_property(bt_property_type_t property_type)
1629 DBG("property_type: %d", property_type);
1631 switch (property_type) {
1632 case BT_PROPERTY_BDADDR:
1633 return _bt_hal_dbus_get_local_address();
1634 case BT_PROPERTY_BDNAME:
1635 return _bt_hal_dbus_get_local_name();
1636 case BT_PROPERTY_VERSION:
1637 return _bt_hal_dbus_get_local_version();
1638 case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
1639 return _bt_hal_dbus_get_discovery_timeout();
1640 case BT_PROPERTY_ADAPTER_SCAN_MODE:
1641 return _bt_hal_dbus_get_scan_mode();
1642 case BT_PROPERTY_CLASS_OF_DEVICE:
1643 return BT_STATUS_UNSUPPORTED;
1644 case BT_PROPERTY_UUIDS:
1645 return _bt_hal_dbus_get_adapter_supported_uuids();
1646 case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
1647 return _bt_hal_dbus_get_bonded_devices();
1649 return BT_STATUS_UNSUPPORTED;
1653 static int __bt_hal_dbus_set_local_name(void *data)
1656 const char *name = data;
1658 GError *error = NULL;
1660 DBG("Local Name: [%s]", name);
1661 proxy = _bt_hal_get_adapter_properties_proxy();
1663 DBG("_bt_hal_dbus_get_local_name: Adapter Properties proxy get failed!!!");
1664 return BT_STATUS_FAIL;
1667 result = g_dbus_proxy_call_sync(proxy,
1669 g_variant_new("(ssv)", BT_HAL_ADAPTER_INTERFACE,
1670 "Alias", g_variant_new("s", name)),
1671 G_DBUS_CALL_FLAGS_NONE,
1676 if (error != NULL) {
1677 ERR("Failed to set local name (Error: %s)", error->message);
1678 g_clear_error(&error);
1680 ERR("Failed to set local name");
1681 return BT_STATUS_FAIL;
1683 g_variant_unref(result);
1685 return BT_STATUS_SUCCESS;
1688 static int __bt_hal_dbus_set_scan_mode(void *data)
1693 GError *error = NULL;
1697 DBG("Scan mode: [%d]", *mode);
1698 proxy = _bt_hal_get_adapter_properties_proxy();
1700 DBG("Adapter Properties proxy get failed!!!");
1701 return BT_STATUS_FAIL;
1705 case BT_SCAN_MODE_NONE:
1709 case BT_SCAN_MODE_CONNECTABLE:
1713 case BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE:
1718 ERR("Invalid scan mode");
1719 return BT_STATUS_FAIL;
1722 result = g_dbus_proxy_call_sync(proxy,
1724 g_variant_new("(ssv)", BT_HAL_ADAPTER_INTERFACE,
1725 "Connectable", g_variant_new("b", pg_scan)),
1726 G_DBUS_CALL_FLAGS_NONE,
1731 if (error != NULL) {
1732 ERR("Failed to set connectable property (Error: %s)", error->message);
1733 g_clear_error(&error);
1735 ERR("Failed to set connectable property");
1736 return BT_STATUS_FAIL;
1738 g_variant_unref(result);
1740 result = g_dbus_proxy_call_sync(proxy,
1742 g_variant_new("(ssv)", BT_HAL_ADAPTER_INTERFACE, "Discoverable",
1743 g_variant_new("b", inq_scan)),
1744 G_DBUS_CALL_FLAGS_NONE,
1749 if (error != NULL) {
1750 ERR("Failed to set Discoverable property (Error: %s)", error->message);
1751 g_clear_error(&error);
1753 ERR("Failed to set Discoverable property");
1754 return BT_STATUS_FAIL;
1756 g_variant_unref(result);
1758 return BT_STATUS_SUCCESS;
1761 static int __bt_hal_dbus_set_discovery_timeout(void *data)
1764 unsigned int *timeout = data;
1766 GError *error = NULL;
1768 DBG("Discovery Timeout: [%d]", *timeout);
1769 proxy = _bt_hal_get_adapter_properties_proxy();
1771 DBG("Adapter Properties proxy get failed!!!");
1772 return BT_STATUS_FAIL;
1775 result = g_dbus_proxy_call_sync(proxy,
1777 g_variant_new("(ssv)", BT_HAL_ADAPTER_INTERFACE,
1778 "DiscoverableTimeout", g_variant_new("u", *timeout)),
1779 G_DBUS_CALL_FLAGS_NONE,
1784 if (error != NULL) {
1785 ERR("Failed to set DiscoverableTimeout property (Error: %s)", error->message);
1786 g_clear_error(&error);
1788 ERR("Failed to set DiscoverableTimeout property");
1789 return BT_STATUS_FAIL;
1791 g_variant_unref(result);
1793 return BT_STATUS_SUCCESS;
1796 /* Set Adapter Properties */
1797 int _bt_hal_dbus_set_adapter_property(const bt_property_t *property)
1801 if (property == NULL || property->val == NULL) {
1802 ERR("Invalid parameters received");
1803 return BT_STATUS_FAIL;
1806 switch (property->type) {
1807 case BT_PROPERTY_BDNAME:
1808 result = __bt_hal_dbus_set_local_name(property->val);
1810 case BT_PROPERTY_ADAPTER_SCAN_MODE:
1811 result = __bt_hal_dbus_set_scan_mode(property->val);
1813 case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
1814 result = __bt_hal_dbus_set_discovery_timeout(property->val);
1817 result = BT_STATUS_UNSUPPORTED;