From e3d4221d6b4374918867f3c49f00b1b54ed78ca3 Mon Sep 17 00:00:00 2001 From: Sameer Kumar Date: Fri, 24 May 2024 15:51:54 +0530 Subject: [PATCH] Get local IRK value This patch adds support to get local IRK value. Change-Id: Iae9293c6d93688d8b9a6672bdaf2261c41668a9f Signed-off-by: Sameer Kumar --- src/adapter.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index 10c57b2..85b5468 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -5798,6 +5798,34 @@ static DBusMessage *adapter_get_rssi(DBusConnection *conn, return btd_error_failed(msg, "Get Raw RSSI Failed"); } +static DBusMessage *get_irk(DBusMessage *msg, uint8_t *irk_info, + uint16_t irk_size) +{ + DBusMessage *reply; + DBusMessageIter iter, array; + reply = g_dbus_create_reply(msg, DBUS_TYPE_INVALID); + + dbus_message_iter_init_append(reply, &iter); + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "y", &array); + dbus_message_iter_append_fixed_array(&array, DBUS_TYPE_BYTE, + &irk_info, irk_size); + dbus_message_iter_close_container(&iter, &array); + + return reply; +} + + +static DBusMessage *adapter_get_local_irk(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + struct btd_adapter *adapter = data; + if (!adapter->local_irk) { + if (!load_local_irk(adapter)) + return g_dbus_create_error(msg, DBUS_ERROR_NO_MEMORY, "No Memory"); + } + return get_irk(msg, adapter->local_irk, MGMT_IRK_SIZE); +} + #if !defined(__SPRD_PATCH__) static void get_adv_tx_power_complete(uint8_t status, uint16_t length, const void *param, void *user_data) @@ -8497,6 +8525,10 @@ static const GDBusMethodTable adapter_methods[] = { { "interval", "u" }, { "window", "u" }), NULL, adapter_le_set_scan_params) }, + { GDBUS_METHOD("GetLocalIrk", + NULL, + GDBUS_ARGS({ "value", "ay" }), + adapter_get_local_irk) }, { GDBUS_ASYNC_METHOD("scan_filter_param_setup", GDBUS_ARGS({ "client_if", "i" }, { "action", "i" }, { "filt_index", "i" }, { "feat_seln", "i"}, -- 2.7.4