On 04/08/2019 06:56, Ingo Feinerer wrote:
This adds support to query the home provider, mainly for debugging and
information purposes.

Signed-off-by: Ingo Feinerer <feine...@logic.at>
---
  cli.c | 36 +++++++++++++++++++++++++++++++++++-
  1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/cli.c b/cli.c
index 19f36f4..ea7e0b0 100644
--- a/cli.c
+++ b/cli.c
@@ -95,6 +95,31 @@ mbim_pin_state_response(void *buffer, size_t len)
        return 0;
  }
+static int
+mbim_home_provider_response(void *buffer, size_t len)
+{
+       struct mbim_basic_connect_home_provider_r *state = (struct 
mbim_basic_connect_home_provider_r *) buffer;
+       char *provider_id, *provider_name;
+
+       if (len < sizeof(struct mbim_basic_connect_home_provider_r)) {
+               fprintf(stderr, "message not long enough\n");
+               return -1;
+       }
+       struct mbimprovider *provider = &state->provider;

please move this to the start of the function

    John


+
+       provider_id = mbim_get_string(&provider->providerid, buffer);
+       provider_name = mbim_get_string(&provider->providername, buffer);
+
+       printf("  provider_id: %s\n", provider_id);
+       printf("  provider_name: %s\n", provider_name);
+       printf("  cellularclass: %04X - %s\n", le32toh(provider->cellularclass),
+               mbim_enum_string(mbim_cellular_class_values, 
le32toh(provider->cellularclass)));
+       printf("  rssi: %04X\n", le32toh(provider->rssi));
+       printf("  errorrate: %04X\n", le32toh(provider->errorrate));
+
+       return 0;
+}
+
  static int
  mbim_registration_response(void *buffer, size_t len)
  {
@@ -294,6 +319,14 @@ mbim_pin_state_request(void)
        return mbim_send_command_msg();
  }
+static int
+mbim_home_provider_request(void)
+{
+       mbim_setup_command_msg(basic_connect, MBIM_MESSAGE_COMMAND_TYPE_QUERY, 
MBIM_CID_BASIC_CONNECT_HOME_PROVIDER, 0);
+
+       return mbim_send_command_msg();
+}
+
  static int
  mbim_registration_request(void)
  {
@@ -478,6 +511,7 @@ static struct mbim_handler handlers[] = {
        { "caps", 0, mbim_device_caps_request, mbim_device_caps_response },
        { "pinstate", 0, mbim_pin_state_request, mbim_pin_state_response },
        { "unlock", 1, mbim_pin_unlock_request, mbim_pin_state_response },
+       { "home", 0, mbim_home_provider_request, mbim_home_provider_response },
        { "registration", 0, mbim_registration_request, 
mbim_registration_response },
        { "subscriber", 0, mbim_subscriber_request, mbim_subscriber_response },
        { "attach", 0, mbim_attach_request, mbim_attach_response },
@@ -491,7 +525,7 @@ static struct mbim_handler handlers[] = {
  static int
  usage(void)
  {
-       fprintf(stderr, "Usage: umbim 
<caps|pinstate|unlock|registration|subscriber|attach|detach|connect|disconnect|config|radio>
 [options]\n"
+       fprintf(stderr, "Usage: umbim 
<caps|pinstate|unlock|home|registration|subscriber|attach|detach|connect|disconnect|config|radio>
 [options]\n"
                "Options:\n"
  #ifdef LIBQMI_MBIM_PROXY
                "    -p                    use mbim-proxy\n"

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to