MBIM: Can we get the nw error not only error code is MBIM_STATUS_ERROR_FAILURE after connect response in bear-mbim logic
Hi dear Aleksander,
Hope to get your guidance.
Thanks.
[Description]
I want to get the nw error after we connect failed, but for some modem, the connect error code is not MBIM_STATUS_ERROR_FAILURE, it is MBIM_STATUS_ERROR_SERVICE_NOT_ACTIVATED.
The logic feedback nw error info only when error code is MBIM_STATUS_ERROR_FAILURE now.
static void
connect_set_ready (MbimDevice *device,
GAsyncResult *res,
GTask *task)
{
if (response &&
(mbim_message_response_get_result (response, MBIM_MESSAGE_TYPE_COMMAND_DONE, &error) ||
error->code == MBIM_STATUS_ERROR_FAILURE)) {
g_autoptr(GError) inner_error = NULL;
if (mbim_message_connect_response_parse (
response,
&session_id,
&activation_state,
NULL, /* voice_call_state */
&ctx->activated_ip_type,
NULL, /* context_type */
&nw_error,
&inner_error)) {
/* Report the IP type we asked for and the one returned by the modem */
mm_obj_dbg (self, "session ID '%u': %s (requested IP type: %s, activated IP type: %s, nw error: %s)",
session_id,
mbim_activation_state_get_string (activation_state),
mbim_context_ip_type_get_string (ctx->requested_ip_type),
mbim_context_ip_type_get_string (ctx->activated_ip_type),
mbim_nw_error_get_string (nw_error));
/* If the response reports an ACTIVATED state, we're good even if
* there is a nw_error set (e.g. asking for IPv4v6 may return a
* 'pdp-type-ipv4-only-allowed' nw_error). */
if (activation_state != MBIM_ACTIVATION_STATE_ACTIVATED &&
activation_state != MBIM_ACTIVATION_STATE_ACTIVATING) {
g_clear_error (&error);
error = mm_mobile_equipment_error_from_mbim_nw_error (nw_error, self);
}
} else {
/* Prefer the error from the result to the parsing error */
if (!error)
error = g_steal_pointer (&inner_error);
}
}
}
The upper application use the nw error info to identify some failure scenario, so if connect failed modem reported MBIM_STATUS_ERROR_SERVICE_NOT_ACTIVATED, upper application can't get the nw error.
Can we add this condition like follow?
if (response &&
(mbim_message_response_get_result (response, MBIM_MESSAGE_TYPE_COMMAND_DONE, &error) ||
error->code == MBIM_STATUS_ERROR_FAILURE ||
error->code == MBIM_STATUS_ERROR_SERVICE_NOT_ACTIVATED)) {
...
}
Edited by Jack Song