diff options
author | Bjørn Mork <bjorn@mork.no> | 2013-04-06 20:36:00 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-04-07 20:19:05 +0200 |
commit | 187f5f3bc0708f6a4c8e0bd4a7b2b40322626e9d (patch) | |
tree | 16259feb943b5b9638dfbfd54a76961a2a20bdd7 /cli/mbimcli-basic-connect.c | |
parent | 184a962a8e50231d8d070649a065c355fca371f9 (diff) | |
download | libmbim-187f5f3bc0708f6a4c8e0bd4a7b2b40322626e9d.tar.gz |
cli: new '--basic-connect-query-pin' command
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Diffstat (limited to 'cli/mbimcli-basic-connect.c')
-rw-r--r-- | cli/mbimcli-basic-connect.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/cli/mbimcli-basic-connect.c b/cli/mbimcli-basic-connect.c index b33497b..6e1624c 100644 --- a/cli/mbimcli-basic-connect.c +++ b/cli/mbimcli-basic-connect.c @@ -44,6 +44,7 @@ static gboolean query_device_caps_flag; static gboolean query_subscriber_ready_status_flag; static gboolean query_radio_state_flag; static gboolean query_device_services_flag; +static gboolean query_pin_flag; static GOptionEntry entries[] = { { "basic-connect-query-device-caps", 0, 0, G_OPTION_ARG_NONE, &query_device_caps_flag, @@ -62,6 +63,10 @@ static GOptionEntry entries[] = { "Query device services", NULL }, + { "basic-connect-query-pin", 0, 0, G_OPTION_ARG_NONE, &query_pin_flag, + "Query PIN state", + NULL + }, { NULL } }; @@ -92,7 +97,8 @@ mbimcli_basic_connect_options_enabled (void) n_actions = (query_device_caps_flag + query_subscriber_ready_status_flag + query_radio_state_flag + - query_device_services_flag); + query_device_services_flag + + query_pin_flag); if (n_actions > 1) { g_printerr ("error: too many Basic Connect actions requested\n"); @@ -370,6 +376,35 @@ query_device_services_ready (MbimDevice *device, shutdown (TRUE); } +static void +pin_ready (MbimDevice *device, + GAsyncResult *res) +{ + MbimMessage *response; + GError *error = NULL; + + response = mbim_device_command_finish (device, res, &error); + if (!response) { + g_printerr ("error: operation failed: %s\n", error->message); + g_error_free (error); + shutdown (FALSE); + return; + } + + g_print ("[%s] Pin Info:\n" + "\t PinType: '%s'\n" + "\t PinState: '%s'\n" + "\t RemainingAttempts: '%u'\n", + mbim_device_get_path_display (device), + mbim_pin_type_get_string ( + mbim_message_basic_connect_pin_set_response_get_pintype (response)), + mbim_pin_state_get_string ( + mbim_message_basic_connect_pin_set_response_get_pinstate (response)), + mbim_message_basic_connect_pin_set_response_get_remainingattempts (response)); + mbim_message_unref (response); + shutdown (TRUE); +} + void mbimcli_basic_connect_run (MbimDevice *device, GCancellable *cancellable) @@ -448,5 +483,21 @@ mbimcli_basic_connect_run (MbimDevice *device, return; } + if (query_pin_flag) { + MbimMessage *request; + + g_debug ("Asynchronously querying PIN state..."); + request = (mbim_message_basic_connect_pin_query_request_new ( + mbim_device_get_next_transaction_id (ctx->device))); + mbim_device_command (ctx->device, + request, + 10, + ctx->cancellable, + (GAsyncReadyCallback)pin_ready, + NULL); + mbim_message_unref (request); + return; + } + g_warn_if_reached (); } |