From 2364a02d72dd008aa162665b4a51cf79f1991e5f Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 28 Mar 2025 16:50:00 +0100 Subject: mmcli/cell-broadcast: Add status output This allows to get the current channel list: $ mmcli -m any --cell-broadcast-status -------------------------- Cell Broadcast | channels: 0-9999,4353 --- cli/mmcli-modem-cell-broadcast.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'cli/mmcli-modem-cell-broadcast.c') diff --git a/cli/mmcli-modem-cell-broadcast.c b/cli/mmcli-modem-cell-broadcast.c index 8121e8a5..faf361ba 100644 --- a/cli/mmcli-modem-cell-broadcast.c +++ b/cli/mmcli-modem-cell-broadcast.c @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * - * Copyright (C) 2024 Guido Günther + * Copyright (C) 2024-2025 Guido Günther */ #include "config.h" @@ -51,6 +51,10 @@ static gboolean list_flag; static gchar *delete_str; static GOptionEntry entries[] = { + { "cell-broadcast-status", 0, 0, G_OPTION_ARG_NONE, &status_flag, + "Show cell broadcast status", + NULL + }, { "cell-broadcast-list-cbm", 0, 0, G_OPTION_ARG_NONE, &list_flag, "List cell broadcast messages available in a given modem", NULL @@ -86,7 +90,8 @@ mmcli_modem_cell_broadcast_options_enabled (void) if (checked) return !!n_actions; - n_actions = (list_flag + + n_actions = (status_flag + + list_flag + !!delete_str); if (n_actions > 1) { @@ -155,6 +160,21 @@ output_cbm_info (MMCbm *cbm) g_free (extra); } +static void +print_cell_broadcast_status (void) +{ + g_autofree MMCellBroadcastChannels *channels = NULL; + guint channels_len = 0; + gchar *str = NULL; + + mm_modem_cell_broadcast_get_channels (ctx->modem_cell_broadcast, &channels, &channels_len); + if (channels) + str = mm_common_build_channels_string (channels, channels_len); + + mmcli_output_string_take (MMC_F_CELL_BROADCAST_CHANNELS, str); + mmcli_output_dump (); +} + static void list_process_reply (GList *result, const GError *error) @@ -313,6 +333,13 @@ mmcli_modem_cell_broadcast_run_synchronous (GDBusConnection *connection) ensure_modem_cell_broadcast (); + /* Request to get cell broadcst status? */ + if (status_flag) { + g_debug ("Printing cell broadcast status..."); + print_cell_broadcast_status (); + return; + } + /* Request to list the CBM? */ if (list_flag) { GList *result; -- cgit v1.2.3-70-g09d2