*/
+/**
+ * @addtogroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
+ * @{
+ */
+
+/**
+ * @ingroup CAPI_NETWORK_BLUETOOTH_ADAPTER_MODULE
+ * @brief Gets the address from hci when adapter is disabled
+ * @since_tizen 7.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/bluetooth.admin
+ * @remarks The @a address must be released with free() by you.
+ *
+ * @param[out] address The device address of local Bluetooth adapter
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #BT_ERROR_NONE Successful
+ * @retval #BT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #BT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #BT_ERROR_OPERATION_FAILED Operation failed
+ * @retval #BT_ERROR_NOT_SUPPORTED Not supported
+ */
+int bt_adapter_get_hci_address(char **address);
+
+/**
+ * @}
+ */
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_LE_5_0); \
}
+#define BT_MAC_ADD_LENGTH 17
+#define BT_MAC_ADD_PATH "/sys/class/bluetooth/hci0/address"
+
static bt_scan_filter_h pxp_linkloss_alert_filter;
static bt_scan_filter_h pxp_immediate_alert_filter;
return BT_ERROR_NONE;
}
+int bt_adapter_get_hci_address(char **address)
+{
+ BT_CHECK_SUPPORTED_FEATURE(BT_FEATURE_COMMON);
+ BT_CHECK_INPUT_PARAMETER(address);
+
+ if (!TIZEN_FEATURE_FHUB_REFERENCE) {
+ BT_INFO("Not a FHUB device");
+ return BT_ERROR_NOT_SUPPORTED;
+ }
+
+ FILE *fp = NULL;
+ char buf[BT_MAC_ADD_LENGTH +1];
+ if (0 == access(BT_MAC_ADD_PATH, F_OK))
+ fp = fopen(BT_MAC_ADD_PATH, "r");
+
+ if (fp == NULL) {
+ BT_ERR("Failed to open file %s\n", BT_MAC_ADD_PATH);
+ return BT_ERROR_OPERATION_FAILED;
+ }
+
+ if (fgets(buf, sizeof(buf), fp) == NULL) {
+ BT_ERR("Failed to get MAC info from %s\n", BT_MAC_ADD_PATH);
+ fclose(fp);
+ return BT_ERROR_OPERATION_FAILED;
+ }
+
+ BT_DBG("%s : %s", BT_MAC_ADD_PATH, buf);
+ *address = (char *)g_try_malloc0(BT_MAC_ADD_LENGTH + 1);
+ if (*address == NULL) {
+ BT_ERR("malloc() failed");
+ fclose(fp);
+ return BT_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_strlcpy(*address, buf, BT_MAC_ADD_LENGTH + 1);
+ BT_DBG("%s", *address);
+ fclose(fp);
+ return BT_ERROR_NONE;
+}
+
/* LCOV_EXCL_START */
int bt_adapter_get_version(char **version)
{
char *firmware = NULL;
char *stack_version = NULL;
char *profiles = NULL;
+ char *local_bt_mac = NULL;
ret = bt_adapter_get_local_info(&chipset, &firmware,
&stack_version, &profiles);
g_free(stack_version);
g_free(profiles);
}
+
+ if (TIZEN_FEATURE_FHUB_REFERENCE) {
+ ret = bt_adapter_get_hci_address(&local_bt_mac);
+ if (ret < BT_ERROR_NONE)
+ TC_PRT("get_hci_address : returns %s\n", __bt_get_error_message(ret));
+ else {
+ TC_PRT("Local BT mac: [%s]", local_bt_mac);
+ g_free(local_bt_mac);
+ }
+ }
break;
}