broadband-bearer: rely on profile management for the cid selection

There is no longer need to perform all the CID selection logic in the
broadband bearer connection procedure, we can rely on the new profile
management operations to do the same thing.

We can do this because we're sure that all the MMBroadbandModem
objects implement the MMModem3gppProfileManager interface.

Additionally, given that we now provide the profile ID value as part
of the MMBearerConnectResult, we no longer need a custom
mm_broadband_bearer_get_3gpp_cid() as we can use the generic
mm_base_bearer_get_profile_id() for the same purpose.
This commit is contained in:
Aleksander Morgado
2021-04-29 10:13:22 +00:00
parent 4b2e63aa86
commit 887358663d
10 changed files with 192 additions and 606 deletions
@@ -132,14 +132,21 @@ out:
static void
load_connection_status_by_cid (MMBroadbandBearerCinterion *bearer,
guint cid,
gint cid,
GAsyncReadyCallback callback,
gpointer user_data)
{
GTask *task;
MMBaseModem *modem;
GTask *task;
g_autoptr(MMBaseModem) modem = NULL;
task = g_task_new (bearer, NULL, callback, user_data);
if (cid == MM_3GPP_PROFILE_ID_UNKNOWN) {
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Unknown profile id to check connection status");
g_object_unref (task);
return;
}
g_task_set_task_data (task, GUINT_TO_POINTER (cid), NULL);
g_object_get (bearer,
@@ -152,7 +159,6 @@ load_connection_status_by_cid (MMBroadbandBearerCinterion *bearer,
FALSE,
(GAsyncReadyCallback) swwan_check_status_ready,
task);
g_object_unref (modem);
}
static void
@@ -161,7 +167,7 @@ load_connection_status (MMBaseBearer *bearer,
gpointer user_data)
{
load_connection_status_by_cid (MM_BROADBAND_BEARER_CINTERION (bearer),
mm_broadband_bearer_get_3gpp_cid (MM_BROADBAND_BEARER (bearer)),
mm_base_bearer_get_profile_id (bearer),
callback,
user_data);
}
@@ -358,7 +364,7 @@ dial_3gpp_context_step (GTask *task)
mm_obj_dbg (self, "dial step %u/%u: checking SWWAN interface %u status...",
ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST, usb_interface_configs[ctx->usb_interface_config_index].swwan_index);
load_connection_status_by_cid (ctx->self,
ctx->cid,
(gint) ctx->cid,
(GAsyncReadyCallback) dial_connection_status_ready,
task);
return;
@@ -556,7 +562,7 @@ disconnect_3gpp_context_step (GTask *task)
ctx->step, DISCONNECT_3GPP_CONTEXT_STEP_LAST,
usb_interface_configs[ctx->usb_interface_config_index].swwan_index);
load_connection_status_by_cid (MM_BROADBAND_BEARER_CINTERION (ctx->self),
ctx->cid,
(gint) ctx->cid,
(GAsyncReadyCallback) disconnect_connection_status_ready,
task);
return;
+1 -1
View File
@@ -399,7 +399,7 @@ static void
bearer_list_report_status_foreach (MMBaseBearer *bearer,
BearerListReportStatusForeachContext *ctx)
{
if (mm_broadband_bearer_get_3gpp_cid (MM_BROADBAND_BEARER (bearer)) != ctx->cid)
if (mm_base_bearer_get_profile_id (bearer) != (gint)ctx->cid)
return;
if (!MM_IS_BROADBAND_BEARER_ICERA (bearer))
+4 -8
View File
@@ -198,7 +198,7 @@ static void
bearer_list_report_status_foreach (MMBaseBearer *bearer,
BearerListReportStatusForeachContext *ctx)
{
if (mm_broadband_bearer_get_3gpp_cid (MM_BROADBAND_BEARER (bearer)) != ctx->cid)
if (mm_base_bearer_get_profile_id (bearer) != (gint)ctx->cid)
return;
mm_base_bearer_report_connection_status (MM_BASE_BEARER (bearer), ctx->status);
@@ -209,7 +209,7 @@ hso_connection_status_changed (MMPortSerialAt *port,
GMatchInfo *match_info,
MMBroadbandModemHso *self)
{
MMBearerList *list = NULL;
g_autoptr(MMBearerList) list = NULL;
BearerListReportStatusForeachContext ctx;
guint cid;
guint status;
@@ -245,14 +245,10 @@ hso_connection_status_changed (MMPortSerialAt *port,
g_object_get (self,
MM_IFACE_MODEM_BEARER_LIST, &list,
NULL);
if (!list)
return;
/* Will report status only in the bearer with the specific CID */
mm_bearer_list_foreach (list,
(MMBearerListForeachFunc)bearer_list_report_status_foreach,
&ctx);
g_object_unref (list);
if (list)
mm_bearer_list_foreach (list, (MMBearerListForeachFunc)bearer_list_report_status_foreach, &ctx);
}
static gboolean
+5 -5
View File
@@ -119,7 +119,7 @@ load_connection_status (MMBaseBearer *self,
GTask *task;
MMBaseModem *modem = NULL;
MMPortSerialAt *port;
guint cid;
gint profile_id;
task = g_task_new (self, NULL, callback, user_data);
@@ -128,14 +128,14 @@ load_connection_status (MMBaseBearer *self,
NULL);
/* If CID not defined, error out */
cid = mm_broadband_bearer_get_3gpp_cid (MM_BROADBAND_BEARER (self));
if (!cid) {
profile_id = mm_base_bearer_get_profile_id (self);
if (profile_id == MM_3GPP_PROFILE_ID_UNKNOWN) {
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Couldn't load connection status: cid not defined");
"Couldn't load connection status: profile id not defined");
g_object_unref (task);
goto out;
}
g_task_set_task_data (task, GUINT_TO_POINTER (cid), NULL);
g_task_set_task_data (task, GUINT_TO_POINTER ((guint)profile_id), NULL);
/* If no control port available, error out */
port = mm_base_modem_peek_best_at_port (modem, NULL);
+13 -8
View File
@@ -775,19 +775,24 @@ ugcntrd_ready (MMBaseModem *modem,
GError *error = NULL;
guint64 tx_bytes = 0;
guint64 rx_bytes = 0;
guint cid;
gint cid;
self = MM_BROADBAND_BEARER_UBLOX (g_task_get_source_object (task));
cid = mm_broadband_bearer_get_3gpp_cid (MM_BROADBAND_BEARER (self));
cid = mm_base_bearer_get_profile_id (MM_BASE_BEARER (self));
response = mm_base_modem_at_command_finish (modem, res, &error);
if (response)
mm_ublox_parse_ugcntrd_response_for_cid (response,
cid,
&tx_bytes, &rx_bytes,
NULL, NULL,
&error);
if (response) {
if (cid == MM_3GPP_PROFILE_ID_UNKNOWN)
error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
"Unknown profile id");
else
mm_ublox_parse_ugcntrd_response_for_cid (response,
cid,
&tx_bytes, &rx_bytes,
NULL, NULL,
&error);
}
if (error) {
g_prefix_error (&error, "Couldn't load PDP context %u statistics: ", cid);