diff options
author | Guido Günther <agx@sigxcpu.org> | 2025-03-28 16:50:00 +0100 |
---|---|---|
committer | Dan Williams <dan@ioncontrol.co> | 2025-03-29 22:19:17 +0000 |
commit | 2364a02d72dd008aa162665b4a51cf79f1991e5f (patch) | |
tree | 7c2cc2b27351d501179302f1e8b13262087a648a /cli/mmcli-modem-cell-broadcast.c | |
parent | 577639659ce3427d5768476e55f705780c23110e (diff) |
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
Diffstat (limited to 'cli/mmcli-modem-cell-broadcast.c')
-rw-r--r-- | cli/mmcli-modem-cell-broadcast.c | 31 |
1 files changed, 29 insertions, 2 deletions
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 <http://www.gnu.org/licenses/>. * - * Copyright (C) 2024 Guido Günther <agx@sigxcpu.org> + * Copyright (C) 2024-2025 Guido Günther <agx@sigxcpu.org> */ #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) { @@ -156,6 +161,21 @@ output_cbm_info (MMCbm *cbm) } 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; |