diff options
author | som <somashekhar.puttagangaiah@intel.com> | 2022-09-14 21:08:34 +0530 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2022-10-03 10:23:27 +0000 |
commit | 15fad122f4158db7e7ec7037687a2251cf50b172 (patch) | |
tree | 143ba5d8603e7d0edbfad35f6ab4bc5ee21fde64 | |
parent | 6317a8cbb3a8a825afe7654c6dc1c52a045be708 (diff) | |
download | libmbim-15fad122f4158db7e7ec7037687a2251cf50b172.tar.gz |
mbimcli: Add uicc atr option in cli
This commit provides option to test uicc atr
using mbimcli option.
Co-author: Bestha, Lakshminarayana
-rw-r--r-- | src/mbimcli/mbimcli-ms-uicc-low-level-access.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/mbimcli/mbimcli-ms-uicc-low-level-access.c b/src/mbimcli/mbimcli-ms-uicc-low-level-access.c index 96806ba..493a717 100644 --- a/src/mbimcli/mbimcli-ms-uicc-low-level-access.c +++ b/src/mbimcli/mbimcli-ms-uicc-low-level-access.c @@ -37,6 +37,7 @@ static gchar *query_uicc_read_binary_str; static gchar *query_uicc_read_record_str; static gchar *set_uicc_open_channel_str; static gchar *set_uicc_close_channel_str; +static gboolean query_uicc_atr_flag; static GOptionEntry entries[] = { { "ms-query-uicc-application-list", 0, 0, G_OPTION_ARG_NONE, &query_uicc_application_list_flag, @@ -63,6 +64,10 @@ static GOptionEntry entries[] = { "Set UICC close channel (allowed keys: channel, channel-group)", "[\"key=value,...\"]" }, + { "ms-query-uicc-atr", 0, 0, G_OPTION_ARG_NONE, &query_uicc_atr_flag, + "Query UICC atr", + NULL + }, { NULL } }; @@ -95,7 +100,8 @@ mbimcli_ms_uicc_low_level_access_options_enabled (void) !!query_uicc_read_binary_str + !!query_uicc_read_record_str + !!set_uicc_open_channel_str + - !!set_uicc_close_channel_str; + !!set_uicc_close_channel_str + + query_uicc_atr_flag; if (n_actions > 1) { g_printerr ("error: too many Microsoft UICC Low Level Access Service actions requested\n"); @@ -792,6 +798,40 @@ close_channel_properties_handle (const gchar *key, return TRUE; } +static void +query_atr_ready (MbimDevice *device, + GAsyncResult *res) +{ + g_autoptr(MbimMessage) response = NULL; + g_autoptr(GError) error = NULL; + const guint8 *atr = NULL; + g_autofree gchar *atr_buffer = NULL; + guint32 atr_size = 0; + + response = mbim_device_command_finish (device, res, &error); + if (!response || !mbim_message_response_get_result (response, MBIM_MESSAGE_TYPE_COMMAND_DONE, &error)) { + g_printerr ("error: operation failed: %s\n", error->message); + shutdown (FALSE); + return; + } + + if (!mbim_message_ms_uicc_low_level_access_atr_response_parse ( + response, + &atr_size, + &atr, + &error)) { + g_printerr ("error: couldn't parse response message: %s\n", error->message); + shutdown (FALSE); + return; + } + + atr_buffer = mbim_common_str_hex (atr, atr_size, ':'); + g_print ("Succesfully retrieved ATR info:\n" + "\tresponse: %s\n", atr_buffer); + + shutdown (TRUE); +} + void mbimcli_ms_uicc_low_level_access_run (MbimDevice *device, GCancellable *cancellable) @@ -1002,5 +1042,18 @@ mbimcli_ms_uicc_low_level_access_run (MbimDevice *device, return; } + /* Request to UICC atr? */ + if (query_uicc_atr_flag) { + g_debug ("Asynchronously querying UICC atr Info..."); + request = mbim_message_ms_uicc_low_level_access_atr_query_new (NULL); + mbim_device_command (ctx->device, + request, + 10, + ctx->cancellable, + (GAsyncReadyCallback)query_atr_ready, + NULL); + return; + } + g_warn_if_reached (); } |