mmcli,modem: new '--get-cell-info' action
This commit is contained in:
@@ -64,6 +64,7 @@ static gchar *set_allowed_modes_str;
|
|||||||
static gchar *set_preferred_mode_str;
|
static gchar *set_preferred_mode_str;
|
||||||
static gchar *set_current_bands_str;
|
static gchar *set_current_bands_str;
|
||||||
static gint set_primary_sim_slot_int;
|
static gint set_primary_sim_slot_int;
|
||||||
|
static gboolean get_cell_info_flag;
|
||||||
static gboolean inhibit_flag;
|
static gboolean inhibit_flag;
|
||||||
|
|
||||||
static GOptionEntry entries[] = {
|
static GOptionEntry entries[] = {
|
||||||
@@ -131,6 +132,10 @@ static GOptionEntry entries[] = {
|
|||||||
"Switch to the selected SIM slot",
|
"Switch to the selected SIM slot",
|
||||||
"[SLOT NUMBER]"
|
"[SLOT NUMBER]"
|
||||||
},
|
},
|
||||||
|
{ "get-cell-info", 0, 0, G_OPTION_ARG_NONE, &get_cell_info_flag,
|
||||||
|
"Get cell info",
|
||||||
|
NULL
|
||||||
|
},
|
||||||
{ "inhibit", 0, 0, G_OPTION_ARG_NONE, &inhibit_flag,
|
{ "inhibit", 0, 0, G_OPTION_ARG_NONE, &inhibit_flag,
|
||||||
"Inhibit the modem",
|
"Inhibit the modem",
|
||||||
NULL
|
NULL
|
||||||
@@ -179,6 +184,7 @@ mmcli_modem_options_enabled (void)
|
|||||||
!!set_preferred_mode_str +
|
!!set_preferred_mode_str +
|
||||||
!!set_current_bands_str +
|
!!set_current_bands_str +
|
||||||
(set_primary_sim_slot_int > 0) +
|
(set_primary_sim_slot_int > 0) +
|
||||||
|
get_cell_info_flag +
|
||||||
inhibit_flag);
|
inhibit_flag);
|
||||||
|
|
||||||
if (n_actions == 0 && mmcli_get_common_modem_string ()) {
|
if (n_actions == 0 && mmcli_get_common_modem_string ()) {
|
||||||
@@ -939,6 +945,35 @@ set_primary_sim_slot_ready (MMModem *modem,
|
|||||||
mmcli_async_operation_done ();
|
mmcli_async_operation_done ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_cell_info_process_reply (GList *list,
|
||||||
|
const GError *error)
|
||||||
|
{
|
||||||
|
if (!list) {
|
||||||
|
g_printerr ("error: couldn't get cell info in the modem: '%s'\n",
|
||||||
|
error ? error->message : "unknown error");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
mmcli_output_cell_info (list);
|
||||||
|
mmcli_output_dump ();
|
||||||
|
|
||||||
|
g_list_free_full (list, (GDestroyNotify) g_object_unref);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_cell_info_ready (MMModem *modem,
|
||||||
|
GAsyncResult *result)
|
||||||
|
{
|
||||||
|
GList *list;
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
|
||||||
|
list = mm_modem_get_cell_info_finish (modem, result, &error);
|
||||||
|
get_cell_info_process_reply (list, error);
|
||||||
|
|
||||||
|
mmcli_async_operation_done ();
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
state_changed (MMModem *modem,
|
state_changed (MMModem *modem,
|
||||||
MMModemState old_state,
|
MMModemState old_state,
|
||||||
@@ -1191,6 +1226,15 @@ get_modem_ready (GObject *source,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Request to get cell info? */
|
||||||
|
if (get_cell_info_flag) {
|
||||||
|
mm_modem_get_cell_info (ctx->modem,
|
||||||
|
ctx->cancellable,
|
||||||
|
(GAsyncReadyCallback)get_cell_info_ready,
|
||||||
|
NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Request to inhibit the modem? */
|
/* Request to inhibit the modem? */
|
||||||
if (inhibit_flag) {
|
if (inhibit_flag) {
|
||||||
gchar *uid;
|
gchar *uid;
|
||||||
@@ -1459,5 +1503,14 @@ mmcli_modem_run_synchronous (GDBusConnection *connection)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Request to get cell info? */
|
||||||
|
if (get_cell_info_flag) {
|
||||||
|
GList *list;
|
||||||
|
|
||||||
|
list = mm_modem_get_cell_info_sync (ctx->modem, NULL, &error);
|
||||||
|
get_cell_info_process_reply (list, error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_warn_if_reached ();
|
g_warn_if_reached ();
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define _LIBMM_INSIDE_MMCLI
|
||||||
#include <libmm-glib.h>
|
#include <libmm-glib.h>
|
||||||
#include "mm-common-helpers.h"
|
#include "mm-common-helpers.h"
|
||||||
#include "mmcli-output.h"
|
#include "mmcli-output.h"
|
||||||
@@ -41,6 +42,7 @@ static SectionInfo section_infos[] = {
|
|||||||
[MMC_S_MODEM_MODES] = { "Modes" },
|
[MMC_S_MODEM_MODES] = { "Modes" },
|
||||||
[MMC_S_MODEM_BANDS] = { "Bands" },
|
[MMC_S_MODEM_BANDS] = { "Bands" },
|
||||||
[MMC_S_MODEM_IP] = { "IP" },
|
[MMC_S_MODEM_IP] = { "IP" },
|
||||||
|
[MMC_S_MODEM_CELL_INFO] = { "Cell info" },
|
||||||
[MMC_S_MODEM_3GPP] = { "3GPP" },
|
[MMC_S_MODEM_3GPP] = { "3GPP" },
|
||||||
[MMC_S_MODEM_3GPP_EPS] = { "3GPP EPS" },
|
[MMC_S_MODEM_3GPP_EPS] = { "3GPP EPS" },
|
||||||
[MMC_S_MODEM_3GPP_5GNR] = { "3GPP 5GNR" },
|
[MMC_S_MODEM_3GPP_5GNR] = { "3GPP 5GNR" },
|
||||||
@@ -127,6 +129,7 @@ static FieldInfo field_infos[] = {
|
|||||||
[MMC_F_BANDS_SUPPORTED] = { "modem.generic.supported-bands", "supported", MMC_S_MODEM_BANDS, },
|
[MMC_F_BANDS_SUPPORTED] = { "modem.generic.supported-bands", "supported", MMC_S_MODEM_BANDS, },
|
||||||
[MMC_F_BANDS_CURRENT] = { "modem.generic.current-bands", "current", MMC_S_MODEM_BANDS, },
|
[MMC_F_BANDS_CURRENT] = { "modem.generic.current-bands", "current", MMC_S_MODEM_BANDS, },
|
||||||
[MMC_F_IP_SUPPORTED] = { "modem.generic.supported-ip-families", "supported", MMC_S_MODEM_IP, },
|
[MMC_F_IP_SUPPORTED] = { "modem.generic.supported-ip-families", "supported", MMC_S_MODEM_IP, },
|
||||||
|
[MMC_F_CELL_INFO] = { "modem.generic.cell-info", "cells", MMC_S_MODEM_CELL_INFO, },
|
||||||
[MMC_F_3GPP_IMEI] = { "modem.3gpp.imei", "imei", MMC_S_MODEM_3GPP, },
|
[MMC_F_3GPP_IMEI] = { "modem.3gpp.imei", "imei", MMC_S_MODEM_3GPP, },
|
||||||
[MMC_F_3GPP_ENABLED_LOCKS] = { "modem.3gpp.enabled-locks", "enabled locks", MMC_S_MODEM_3GPP, },
|
[MMC_F_3GPP_ENABLED_LOCKS] = { "modem.3gpp.enabled-locks", "enabled locks", MMC_S_MODEM_3GPP, },
|
||||||
[MMC_F_3GPP_OPERATOR_ID] = { "modem.3gpp.operator-code", "operator id", MMC_S_MODEM_3GPP, },
|
[MMC_F_3GPP_OPERATOR_ID] = { "modem.3gpp.operator-code", "operator id", MMC_S_MODEM_3GPP, },
|
||||||
@@ -1112,6 +1115,33 @@ mmcli_output_profile_set (MM3gppProfile *profile)
|
|||||||
g_list_free (profile_list);
|
g_list_free (profile_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* (Custom) Cell info output */
|
||||||
|
|
||||||
|
void
|
||||||
|
mmcli_output_cell_info (GList *cell_info_list)
|
||||||
|
{
|
||||||
|
gchar **cell_infos = NULL;
|
||||||
|
|
||||||
|
if (cell_info_list) {
|
||||||
|
GPtrArray *aux;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
aux = g_ptr_array_new ();
|
||||||
|
for (l = cell_info_list; l; l = g_list_next (l))
|
||||||
|
g_ptr_array_add (aux, mm_cell_info_build_string (MM_CELL_INFO (l->data)));
|
||||||
|
g_ptr_array_add (aux, NULL);
|
||||||
|
cell_infos = (gchar **) g_ptr_array_free (aux, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* When printing human result, we want to show some result even if no networks
|
||||||
|
* are found, so we force a explicit string result. */
|
||||||
|
if (selected_type == MMC_OUTPUT_TYPE_HUMAN && !cell_infos)
|
||||||
|
output_item_new_take_single (MMC_F_CELL_INFO, g_strdup ("n/a"));
|
||||||
|
else
|
||||||
|
output_item_new_take_multiple (MMC_F_CELL_INFO, cell_infos, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* Human-friendly output */
|
/* Human-friendly output */
|
||||||
|
|
||||||
|
@@ -38,6 +38,7 @@ typedef enum {
|
|||||||
MMC_S_MODEM_MODES,
|
MMC_S_MODEM_MODES,
|
||||||
MMC_S_MODEM_BANDS,
|
MMC_S_MODEM_BANDS,
|
||||||
MMC_S_MODEM_IP,
|
MMC_S_MODEM_IP,
|
||||||
|
MMC_S_MODEM_CELL_INFO,
|
||||||
MMC_S_MODEM_3GPP,
|
MMC_S_MODEM_3GPP,
|
||||||
MMC_S_MODEM_3GPP_EPS,
|
MMC_S_MODEM_3GPP_EPS,
|
||||||
MMC_S_MODEM_3GPP_5GNR,
|
MMC_S_MODEM_3GPP_5GNR,
|
||||||
@@ -127,6 +128,8 @@ typedef enum {
|
|||||||
MMC_F_BANDS_CURRENT,
|
MMC_F_BANDS_CURRENT,
|
||||||
/* IP section */
|
/* IP section */
|
||||||
MMC_F_IP_SUPPORTED,
|
MMC_F_IP_SUPPORTED,
|
||||||
|
/* Cell info section */
|
||||||
|
MMC_F_CELL_INFO,
|
||||||
/* 3GPP section */
|
/* 3GPP section */
|
||||||
MMC_F_3GPP_IMEI,
|
MMC_F_3GPP_IMEI,
|
||||||
MMC_F_3GPP_ENABLED_LOCKS,
|
MMC_F_3GPP_ENABLED_LOCKS,
|
||||||
@@ -392,6 +395,7 @@ void mmcli_output_pco_list (GList *pco_list);
|
|||||||
void mmcli_output_preferred_networks (GList *preferred_nets_list);
|
void mmcli_output_preferred_networks (GList *preferred_nets_list);
|
||||||
void mmcli_output_profile_list (GList *profile_list);
|
void mmcli_output_profile_list (GList *profile_list);
|
||||||
void mmcli_output_profile_set (MM3gppProfile *profile);
|
void mmcli_output_profile_set (MM3gppProfile *profile);
|
||||||
|
void mmcli_output_cell_info (GList *cell_info_list);
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* Dump output */
|
/* Dump output */
|
||||||
|
Reference in New Issue
Block a user