This patch adds support to get local IRK value.
To avoid any conflicts this patch should be merged with bluez
patch: (Change-Id: Iae9293c6d93688d8b9a6672bdaf2261c41668a9f)
Change-Id: Iac2edded057054a98aa3855fe0eb2c97e9346a62
Signed-off-by: Sameer Kumar <sameer.kumar@samsung.com>
return result;
}
+BT_EXPORT_API int bluetooth_get_local_irk(bluetooth_irk_t *local_irk)
+{
+ int result;
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ result = _bt_send_request(BT_BLUEZ_SERVICE, BT_GET_LOCAL_IRK,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ *local_irk = g_array_index(out_param, bluetooth_irk_t, 0);
+ }
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+ return result;
+}
+
BT_EXPORT_API int bluetooth_start_custom_discovery(bt_discovery_role_type_t role,
unsigned short max_response,
unsigned short discovery_duration,
{BT_GET_DISCOVERABLE_MODE, "BT_GET_DISCOVERABLE_MODE"},
{BT_SET_DISCOVERABLE_MODE, "BT_SET_DISCOVERABLE_MODE"},
{BT_START_DISCOVERY, "BT_START_DISCOVERY"},
+ {BT_GET_LOCAL_IRK, "BT_GET_LOCAL_IRK"},
{BT_START_CUSTOM_DISCOVERY, "BT_START_CUSTOM_DISCOVERY"},
{BT_CANCEL_DISCOVERY, "BT_CANCEL_DISCOVERY"},
{BT_START_LE_DISCOVERY, "BT_START_LE_DISCOVERY"},
return BT_STATUS_SUCCESS;
}
+int _bt_hal_dbus_get_local_irk(uint8_t *local_irk)
+{
+ GDBusProxy *proxy;
+ GError *error = NULL;
+ GVariant *result;
+ GVariantIter *iter;
+
+ GByteArray *gp_byte_array = NULL;
+ guint8 g_byte;
+
+ DBG("+");
+
+ proxy = _bt_hal_get_adapter_proxy();
+ if (!proxy) {
+ DBG("_bt_hal_dbus_get_local_irk: Adapter proxy get failed!!!");
+ return BT_STATUS_FAIL;
+ }
+
+ result = g_dbus_proxy_call_sync(proxy,
+ "GetLocalIrk",
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+
+ if (!result) {
+ if (error != NULL) {
+ ERR("GetLocalIrk failed (Error: %s)", error->message);
+ g_clear_error(&error);
+ } else
+ ERR("GetLocalIrk failed");
+ return BT_STATUS_FAIL;
+ }
+
+ gp_byte_array = g_byte_array_new();
+ g_variant_get(result, "(ay)", &iter);
+
+ while (g_variant_iter_loop(iter, "y", &g_byte))
+ g_byte_array_append(gp_byte_array, &g_byte, 1);
+
+ memcpy(local_irk, gp_byte_array->data, gp_byte_array->len);
+
+ g_variant_iter_free(iter);
+ g_byte_array_free(gp_byte_array, TRUE);
+ return BT_STATUS_SUCCESS;
+}
+
int _bt_hal_dbus_stop_discovery(void)
{
GDBusProxy *proxy;
int _bt_hal_dbus_start_discovery(gboolean is_custom, bt_disc_role_type_t role);
+int _bt_hal_dbus_get_local_irk(uint8_t *irk);
+
int _bt_hal_dbus_stop_discovery(void);
int _bt_hal_get_adapter_powered_state(uint8_t *state);
return _bt_hal_dbus_start_discovery(false, 0x00);
}
+static int get_local_irk(uint8_t *local_irk)
+{
+ return _bt_hal_dbus_get_local_irk(local_irk);
+}
+
#ifdef TIZEN_BT_HAL
static int start_custom_discovery(bt_disc_role_type_t disc_type)
{
.get_remote_service_record = get_remote_service_record,
.get_remote_services = get_remote_services,
.start_discovery = start_discovery,
+ .get_local_irk = get_local_irk,
#ifdef TIZEN_BT_HAL
.start_custom_discovery = start_custom_discovery,
#endif
/** Start Discovery */
int (*start_discovery)(void);
+ /** Get Local Irk */
+ int (*get_local_irk)(uint8_t *irk);
+
#ifdef TIZEN_BT_HAL
int (*start_custom_discovery)(bt_disc_role_type_t disc_type);
#endif
oal_status_t adapter_start_inquiry(unsigned short duration);
/**
+* @brief Get the local Identity Resolving Key (IRK) value.
+*
+* @return OAL_STATUS_SUCCESS on success, otherwise a non-zero error value.
+* @retval #OAL_STATUS_SUCCESS Successful
+*
+* @pre Bluetooth controller must support this feature.
+*/
+oal_status_t adapter_get_local_irk(uint8_t *local_irk);
+
+/**
* @brief Stop device discovery
*
* @details OAL_EVENT_ADAPTER_INQUIRY_FINISHED will be generated by OAL
return OAL_STATUS_SUCCESS;
}
+oal_status_t adapter_get_local_irk(uint8_t *local_irk)
+{
+ int ret = OAL_STATUS_SUCCESS;
+ CHECK_OAL_INITIALIZED();
+
+ ret = blued_api->get_local_irk(local_irk);
+ if (ret != BT_STATUS_SUCCESS) {
+ BT_ERR("get property local irk failed, status: %s", status2string(ret));
+ return convert_to_oal_status(ret);
+ }
+
+ return OAL_STATUS_SUCCESS;
+}
+
oal_status_t adapter_stop_inquiry(void)
{
int ret;
cod_mask, FALSE, 0x00);
}
+int _bt_get_local_irk(uint8_t *local_irk)
+{
+ BT_CHECK_PARAMETER(local_irk, return);
+ int ret = OAL_STATUS_SUCCESS;
+ ret = adapter_get_local_irk(local_irk);
+ if (ret != OAL_STATUS_SUCCESS) {
+ BT_ERR("ret: %d", ret);
+ return _bt_convert_oal_status_to_bt_error(ret);
+ }
+
+ return BLUETOOTH_ERROR_NONE;
+}
+
int _bt_start_custom_discovery(bt_discovery_role_type_t role)
{
return __bt_adapter_state_discovery_request(TRUE, 0, 0, 0, TRUE, role);
break;
}
+ case BT_GET_LOCAL_IRK: {
+ uint8_t local_irk[BLUETOOTH_IRK_LENGTH] ;
+ result = _bt_get_local_irk(local_irk);
+
+ if (result == BLUETOOTH_ERROR_NONE) {
+ bluetooth_irk_t loc_irk;
+ memcpy(loc_irk.irk, local_irk, BLUETOOTH_IRK_LENGTH);
+ g_array_append_vals(*out_param1, &loc_irk,
+ sizeof(bluetooth_irk_t));
+ }
+
+ break;
+ }
case BT_START_CUSTOM_DISCOVERY: {
bt_discovery_role_type_t role;
case BT_GET_RSSI:
case BT_GET_LOCAL_NAME:
+ case BT_GET_LOCAL_IRK:
case BT_GET_LOCAL_ADDRESS:
case BT_GET_LOCAL_VERSION:
case BT_IS_SERVICE_USED:
int _bt_start_discovery(unsigned short max_response,
unsigned short duration, unsigned int cod_mask);
+int _bt_get_local_irk(uint8_t *local_irk);
+
int _bt_start_custom_discovery(bt_discovery_role_type_t role);
int _bt_cancel_discovery(void);
#define BLUETOOTH_SCAN_RESP_DATA_LENGTH_MAX 31 /**< This specifies maximum LE Scan response data length */
#define BLUETOOTH_MANUFACTURER_DATA_LENGTH_MAX 240 /**< This specifies maximum manufacturer data length */
#define BLUETOOTH_APPEARANCE_LENGTH 2 /**< This specifies bluetooth device appearance characteristic length */
+#define BLUETOOTH_IRK_LENGTH 16 /**< This specifies bluetooth device IRK length */
#define BLUETOOTH_MAX_SERVICES_FOR_DEVICE 40 /**< This specifies maximum number of services
a device can support */
char name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX + 1];
} bluetooth_device_name_t;
+
+typedef struct {
+ unsigned char irk[BLUETOOTH_IRK_LENGTH];
+} bluetooth_irk_t;
+
/**
* This is Bluetooth manufacturer specific data, maximum size of data is 240 bytes
*/
int bluetooth_le_get_maximum_advertising_data_length(gint *data_length);
/**
+ * @fn int bluetooth_get_local_irk(bluetooth_irk_t *irk)
+ * @brief Gets the local Identity Resolving Key (IRK).
+ *
+ * This function is a synchronous call.
+ *
+ * @return BLUETOOTH_ERROR_NONE - Success \n
+ * BLUETOOTH_ERROR_NOT_SUPPORT - Not supported \n
+ * BLUETOOTH_ERROR_INVALID_PARAM - Invalid parameter (NULL buffer) \n
+ * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Adapter is disabled \n
+ * BLUETOOTH_ERROR_INTERNAL - Internal error \n
+ * @param[out] irk. This structure variable contains the local IRK of the Bluetooth device.
+ *
+ * @remark None
+ */
+int bluetooth_get_local_irk(bluetooth_irk_t *irk);
+
+/**
* @fn int bluetooth_l2cap_le_create_socket(int psm)
* @brief Register l2cap_le socket with a specific PSM
*
BT_GET_DISCOVERABLE_MODE,
BT_SET_DISCOVERABLE_MODE,
BT_START_DISCOVERY,
+ BT_GET_LOCAL_IRK,
BT_START_CUSTOM_DISCOVERY,
BT_CANCEL_DISCOVERY,
BT_START_LE_DISCOVERY,