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
This commit is contained in:
committed by
Dan Williams
parent
577639659c
commit
2364a02d72
@@ -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) {
|
||||
@@ -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;
|
||||
|
||||
@@ -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, },
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user