Commit c1aef5ca authored by Sun XinZhao's avatar Sun XinZhao
Browse files

ms-basic-connect-extensions: add 'device caps'

We query the device capabilities and we can see
the following information

mbimcli -d /dev/cdc-wdm0 -p --ms-query-device-caps
[/dev/cdc-wdm0] Device capabilities retrieved:
              Device type: 'x'
           Cellular class: 'x'
              voice class: 'x'
                SIM class: 'x'
               Data class: 'x, x, x, x'
                 SMS caps: 'x, x'
                CTRL caps: 'x'
             Max sessions: 'x'
        Custom data class: 'x'
                Device ID: 'x'
            Firmware info: 'x'
            Hardware info: 'x'
           Executor Index: 'x'
parent 95a5d2f5
Pipeline #335087 passed with stage
in 1 minute and 29 seconds
......@@ -189,6 +189,51 @@
{ "name" : "SlotMap",
"format" : "ref-struct-array",
"struct-type" : "MbimSlot",
"array-size-field" : "MapCount" } ] }
"array-size-field" : "MapCount" } ] },
//************************************************************************************
{ "name" : "Device Caps",
"service" : "Ms Basic Connect Extensions",
"type" : "Command",
"since" : "1.26",
"query" : [],
"response" : [ { "name" : "DeviceType",
"format" : "guint32",
"public-format" : "MbimDeviceType" },
{ "name" : "CellularClass",
"format" : "guint32",
"public-format" : "MbimCellularClass" },
{ "name" : "VoiceClass",
"format" : "guint32",
"public-format" : "MbimVoiceClass" },
{ "name" : "SmsClass",
"format" : "guint32",
"public-format" : "MbimSimClass" },
{ "name" : "DataClass",
"format" : "guint32",
"public-format" : "MbimDataClass" },
{ "name" : "SmsCaps",
"format" : "guint32",
"public-format" : "MbimSmsCaps" },
{ "name" : "ControlCaps",
"format" : "guint32",
"public-format" : "MbimCtrlCaps" },
{ "name" : "MaxSessions",
"format" : "guint32" },
{ "name" : "CustomDataClass",
"format" : "string",
"max-size" : "22" },
{ "name" : "DeviceId",
"format" : "string",
"max-size" : "36" },
{ "name" : "FirmwareInfo",
"format" : "string",
"max-size" : "60" },
{ "name" : "HardwareInfo",
"format" : "string",
"max-size" : "60" },
{ "name" : "ExecutorIndex",
"format" : "guint32" } ] }
]
......@@ -48,6 +48,7 @@ static gboolean query_lte_attach_configuration_flag;
static gboolean query_lte_attach_status_flag; /* support for the deprecated name */
static gboolean query_lte_attach_info_flag;
static gboolean query_sys_caps_flag;
static gboolean query_device_caps_flag;
static gchar *query_slot_info_status_str;
static gboolean query_device_slot_mappings_flag;
static gchar *set_device_slot_mappings_str;
......@@ -78,6 +79,10 @@ static GOptionEntry entries[] = {
"Query system capabilities",
NULL
},
{ "ms-query-device-caps", 0,0, G_OPTION_ARG_NONE, &query_device_caps_flag,
"Query device capabilities",
NULL
},
{ "ms-query-slot-info-status", 0, 0, G_OPTION_ARG_STRING, &query_slot_info_status_str,
"Query slot information status",
"[SlotIndex]"
......@@ -164,6 +169,7 @@ mbimcli_ms_basic_connect_extensions_options_enabled (void)
query_lte_attach_configuration_flag +
(query_lte_attach_status_flag || query_lte_attach_info_flag) +
query_sys_caps_flag +
query_device_caps_flag +
!!query_slot_info_status_str +
!!set_device_slot_mappings_str +
query_device_slot_mappings_flag);
......@@ -386,6 +392,101 @@ query_sys_caps_ready (MbimDevice *device,
shutdown (TRUE);
}
static void
query_device_caps_ready (MbimDevice *device,
GAsyncResult *res)
{
g_autoptr(MbimMessage) response = NULL;
g_autoptr(GError) error = NULL;
MbimDeviceType device_type;
const gchar *device_type_str;
MbimVoiceClass voice_class;
const gchar *voice_class_str;
MbimCellularClass cellular_class;
g_autofree gchar *cellular_class_str = NULL;
MbimSimClass sim_class;
g_autofree gchar *sim_class_str = NULL;
MbimDataClass data_class;
g_autofree gchar *data_class_str = NULL;
MbimSmsCaps sms_caps;
g_autofree gchar *sms_caps_str = NULL;
MbimCtrlCaps ctrl_caps;
g_autofree gchar *ctrl_caps_str = NULL;
guint32 max_sessions;
g_autofree gchar *custom_data_class = NULL;
g_autofree gchar *device_id = NULL;
g_autofree gchar *firmware_info = NULL;
g_autofree gchar *hardware_info = NULL;
guint32 executor_index;
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_basic_connect_extensions_device_caps_response_parse (
response,
&device_type,
&cellular_class,
&voice_class,
&sim_class,
&data_class,
&sms_caps,
&ctrl_caps,
&max_sessions,
&custom_data_class,
&device_id,
&firmware_info,
&hardware_info,
&executor_index,
&error)) {
g_printerr ("error: couldn't parse response message: %s\n", error->message);
shutdown (FALSE);
return;
}
device_type_str = mbim_device_type_get_string (device_type);
cellular_class_str = mbim_cellular_class_build_string_from_mask (cellular_class);
voice_class_str = mbim_voice_class_get_string (voice_class);
sim_class_str = mbim_sim_class_build_string_from_mask (sim_class);
data_class_str = mbim_data_class_build_string_from_mask (data_class);
sms_caps_str = mbim_sms_caps_build_string_from_mask (sms_caps);
ctrl_caps_str = mbim_ctrl_caps_build_string_from_mask (ctrl_caps);
g_print ("[%s] Device capabilities retrieved:\n"
"\t Device type: '%s'\n"
"\t Cellular class: '%s'\n"
"\t Voice class: '%s'\n"
"\t SIM class: '%s'\n"
"\t Data class: '%s'\n"
"\t SMS caps: '%s'\n"
"\t Ctrl caps: '%s'\n"
"\t Max sessions: '%u'\n"
"\tCustom data class: '%s'\n"
"\t Device ID: '%s'\n"
"\t Firmware info: '%s'\n"
"\t Hardware info: '%s'\n"
"\t Executor Index: '%u'\n",
mbim_device_get_path_display (device),
VALIDATE_UNKNOWN (device_type_str),
VALIDATE_UNKNOWN (cellular_class_str),
VALIDATE_UNKNOWN (voice_class_str),
VALIDATE_UNKNOWN (sim_class_str),
VALIDATE_UNKNOWN (data_class_str),
VALIDATE_UNKNOWN (sms_caps_str),
VALIDATE_UNKNOWN (ctrl_caps_str),
max_sessions,
VALIDATE_UNKNOWN (custom_data_class),
VALIDATE_UNKNOWN (device_id),
VALIDATE_UNKNOWN (firmware_info),
VALIDATE_UNKNOWN (hardware_info),
executor_index);
shutdown (TRUE);
}
static gboolean
query_slot_information_status_slot_index_parse (const gchar *str,
guint32 *slot_index,
......@@ -621,6 +722,18 @@ mbimcli_ms_basic_connect_extensions_run (MbimDevice *device,
return;
}
if (query_device_caps_flag) {
g_debug ("Asynchronously querying device capabilities...");
request = mbim_message_ms_basic_connect_extensions_device_caps_query_new (NULL);
mbim_device_command (ctx->device,
request,
10,
ctx->cancellable,
(GAsyncReadyCallback)query_device_caps_ready,
NULL);
return;
}
/*Request to query slot information status? */
if (query_slot_info_status_str) {
guint32 slot_index;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment