modem: Load current channels on startup

Signed-off-by: Guido Günther <agx@sigxcpu.org>
This commit is contained in:
Guido Günther
2025-03-28 20:53:52 +00:00
committed by Dan Williams
parent 2878833f5c
commit b83df955fa
3 changed files with 109 additions and 0 deletions
+61
View File
@@ -10499,6 +10499,65 @@ modem_cdma_register_in_network (MMIfaceModemCdma *_self,
task);
}
/*****************************************************************************/
/* Load currently active channels (CellBroadcast interface) */
static GArray *
modem_cell_broadcast_load_channels_finish (MMIfaceModemCellBroadcast *self,
GAsyncResult *res,
GError **error)
{
return g_task_propagate_pointer (G_TASK (res), error);
}
static void
cscb_channels_format_check_ready (MMBroadbandModem *self,
GAsyncResult *res,
GTask *task)
{
const gchar *response;
GError *error = NULL;
GArray *result;
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
if (error) {
g_task_return_error (task, error);
g_object_unref (task);
return;
}
/* Parse reply */
result = mm_3gpp_parse_cscb_response (response, &error);
if (!result) {
g_task_return_error (task, error);
g_object_unref (task);
return;
}
g_task_return_pointer (task,
result,
(GDestroyNotify)g_array_unref);
g_object_unref (task);
}
static void
modem_cell_broadcast_load_channels (MMIfaceModemCellBroadcast *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
GTask *task;
task = g_task_new (self, NULL, callback, user_data);
/* Load configured channels */
mm_base_modem_at_command (MM_BASE_MODEM (self),
"+CSCB?",
3,
TRUE,
(GAsyncReadyCallback)cscb_channels_format_check_ready,
task);
}
/*****************************************************************************/
static gboolean
@@ -14402,6 +14461,8 @@ iface_modem_cell_broadcast_init (MMIfaceModemCellBroadcastInterface *iface)
iface->check_support_finish = modem_cell_broadcast_check_support_finish;
iface->setup_unsolicited_events = modem_cell_broadcast_setup_unsolicited_events;
iface->setup_unsolicited_events_finish = modem_cell_broadcast_setup_cleanup_unsolicited_events_finish;
iface->load_channels = modem_cell_broadcast_load_channels;
iface->load_channels_finish = modem_cell_broadcast_load_channels_finish;
iface->cleanup_unsolicited_events = modem_cell_broadcast_cleanup_unsolicited_events;
iface->cleanup_unsolicited_events_finish = modem_cell_broadcast_setup_cleanup_unsolicited_events_finish;
iface->set_channels = modem_cell_broadcast_set_channels;
+39
View File
@@ -527,6 +527,7 @@ typedef enum {
ENABLING_STEP_FIRST,
ENABLING_STEP_SETUP_UNSOLICITED_EVENTS,
ENABLING_STEP_ENABLE_UNSOLICITED_EVENTS,
ENABLING_STEP_GET_CHANNELS,
ENABLING_STEP_LAST
} EnablingStep;
@@ -592,6 +593,31 @@ enable_unsolicited_events_ready (MMIfaceModemCellBroadcast *self,
interface_enabling_step (task);
}
static void
load_channels_ready (MMIfaceModemCellBroadcast *self,
GAsyncResult *res,
GTask *task)
{
EnablingContext *ctx;
g_autoptr (GError) error = NULL;
g_autoptr (GArray) channels = NULL;
ctx = g_task_get_task_data (task);
channels = MM_IFACE_MODEM_CELL_BROADCAST_GET_IFACE (self)->load_channels_finish (self, res, &error);
if (channels) {
mm_gdbus_modem_cell_broadcast_set_channels (
ctx->skeleton,
mm_common_cell_broadcast_channels_garray_to_variant (channels));
} else {
/* Not critical! */
mm_obj_warn (self, "Couldn't load current channel list: %s", error->message);
}
/* Go on with next step */
ctx->step++;
interface_enabling_step (task);
}
static void
interface_enabling_step (GTask *task)
{
@@ -654,6 +680,19 @@ interface_enabling_step (GTask *task)
ctx->step++;
/* fall through */
case ENABLING_STEP_GET_CHANNELS:
/* Read current channel list */
if (MM_IFACE_MODEM_CELL_BROADCAST_GET_IFACE (self)->load_channels &&
MM_IFACE_MODEM_CELL_BROADCAST_GET_IFACE (self)->load_channels_finish) {
MM_IFACE_MODEM_CELL_BROADCAST_GET_IFACE (self)->load_channels (
self,
(GAsyncReadyCallback)load_channels_ready,
task);
return;
}
ctx->step++;
/* fall through */
case ENABLING_STEP_LAST:
/* We are done without errors! */
g_task_return_boolean (task, TRUE);
+9
View File
@@ -74,6 +74,15 @@ struct _MMIfaceModemCellBroadcastInterface {
GAsyncResult *res,
GError **error);
/* Asynchronous loading of channel list */
GArray * (*load_channels_finish) (MMIfaceModemCellBroadcast *self,
GAsyncResult *res,
GError **error);
void (*load_channels) (MMIfaceModemCellBroadcast *self,
GAsyncReadyCallback callback,
gpointer user_data);
/* Create Cbm objects */
MMBaseCbm * (* create_cbm) (MMIfaceModemCellBroadcast *self);