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 | |
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')
-rw-r--r-- | cli/mmcli-modem-cell-broadcast.c | 31 | ||||
-rw-r--r-- | cli/mmcli-output.c | 2 | ||||
-rw-r--r-- | cli/mmcli-output.h | 3 |
3 files changed, 34 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; diff --git a/cli/mmcli-output.c b/cli/mmcli-output.c index 1884e906..440d6059 100644 --- a/cli/mmcli-output.c +++ b/cli/mmcli-output.c @@ -50,6 +50,7 @@ static SectionInfo section_infos[] = { [MMC_S_MODEM_3GPP_USSD] = { "3GPP USSD" }, [MMC_S_MODEM_3GPP_PROFILE_MANAGER] = { "3GPP profile manager" }, [MMC_S_MODEM_CDMA] = { "CDMA" }, + [MMC_S_MODEM_CELL_BROADCAST] = { "Cell Broadcast" }, [MMC_S_MODEM_SIM] = { "SIM" }, [MMC_S_MODEM_BEARER] = { "Bearer" }, [MMC_S_MODEM_TIME] = { "Time" }, @@ -167,6 +168,7 @@ static FieldInfo field_infos[] = { [MMC_F_CDMA_REGISTRATION_CDMA1X] = { "modem.cdma.cdma1x-registration-state", "registration cdma1x", MMC_S_MODEM_CDMA, }, [MMC_F_CDMA_REGISTRATION_EVDO] = { "modem.cdma.evdo-registration-state", "registration evdo", MMC_S_MODEM_CDMA, }, [MMC_F_CDMA_ACTIVATION] = { "modem.cdma.activation-state", "activation", MMC_S_MODEM_CDMA, }, + [MMC_F_CELL_BROADCAST_CHANNELS] = { "modem.cellbroadcast.channels", "channels", MMC_S_MODEM_CELL_BROADCAST, }, [MMC_F_SIM_PATH] = { "modem.generic.sim", "primary sim path", MMC_S_MODEM_SIM, }, [MMC_F_SIM_PRIMARY_SLOT] = { "modem.generic.primary-sim-slot", NULL, MMC_S_MODEM_SIM, }, [MMC_F_SIM_SLOT_PATHS] = { "modem.generic.sim-slots", "sim slot paths", MMC_S_MODEM_SIM, }, diff --git a/cli/mmcli-output.h b/cli/mmcli-output.h index 8dde1412..a9f050d8 100644 --- a/cli/mmcli-output.h +++ b/cli/mmcli-output.h @@ -46,6 +46,7 @@ typedef enum { MMC_S_MODEM_3GPP_USSD, MMC_S_MODEM_3GPP_PROFILE_MANAGER, MMC_S_MODEM_CDMA, + MMC_S_MODEM_CELL_BROADCAST, MMC_S_MODEM_SIM, MMC_S_MODEM_BEARER, MMC_S_MODEM_TIME, @@ -173,6 +174,8 @@ typedef enum { MMC_F_CDMA_REGISTRATION_CDMA1X, MMC_F_CDMA_REGISTRATION_EVDO, MMC_F_CDMA_ACTIVATION, + /* CellBroadcast section */ + MMC_F_CELL_BROADCAST_CHANNELS, /* SIM section */ MMC_F_SIM_PATH, MMC_F_SIM_PRIMARY_SLOT, |