aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/reference/libmm-glib/libmm-glib-docs.xml1
-rw-r--r--docs/reference/libmm-glib/libmm-glib-sections.txt29
-rw-r--r--libmm-glib/Makefile.am3
-rw-r--r--libmm-glib/libmm-glib.h1
-rw-r--r--libmm-glib/meson.build2
-rw-r--r--libmm-glib/mm-cell-info-cdma.c308
-rw-r--r--libmm-glib/mm-cell-info-cdma.h98
-rw-r--r--libmm-glib/mm-cell-info.c7
8 files changed, 448 insertions, 1 deletions
diff --git a/docs/reference/libmm-glib/libmm-glib-docs.xml b/docs/reference/libmm-glib/libmm-glib-docs.xml
index e6df9256..2b68948f 100644
--- a/docs/reference/libmm-glib/libmm-glib-docs.xml
+++ b/docs/reference/libmm-glib/libmm-glib-docs.xml
@@ -93,6 +93,7 @@
<xi:include href="xml/mm-cdma-manual-activation-properties.xml"/>
<xi:include href="xml/mm-unlock-retries.xml"/>
<xi:include href="xml/mm-cell-info.xml"/>
+ <xi:include href="xml/mm-cell-info-cdma.xml"/>
<xi:include href="xml/mm-pco.xml"/>
<xi:include href="xml/mm-nr5g-registration-settings.xml"/>
</section>
diff --git a/docs/reference/libmm-glib/libmm-glib-sections.txt b/docs/reference/libmm-glib/libmm-glib-sections.txt
index 254c1dea..a6bc3fa3 100644
--- a/docs/reference/libmm-glib/libmm-glib-sections.txt
+++ b/docs/reference/libmm-glib/libmm-glib-sections.txt
@@ -307,6 +307,35 @@ mm_cell_info_get_type
</SECTION>
<SECTION>
+<FILE>mm-cell-info-cdma</FILE>
+<TITLE>MMCellInfoCdma</TITLE>
+MMCellInfoCdma
+<SUBSECTION Getters>
+mm_cell_info_cdma_get_nid
+mm_cell_info_cdma_get_sid
+mm_cell_info_cdma_get_base_station_id
+mm_cell_info_cdma_get_ref_pn
+mm_cell_info_cdma_get_pilot_strength
+<SUBSECTION Private>
+mm_cell_info_cdma_new_from_dictionary
+mm_cell_info_cdma_set_nid
+mm_cell_info_cdma_set_sid
+mm_cell_info_cdma_set_base_station_id
+mm_cell_info_cdma_set_ref_pn
+mm_cell_info_cdma_set_pilot_strength
+<SUBSECTION Standard>
+MMCellInfoCdmaClass
+MMCellInfoCdmaPrivate
+MM_IS_CELL_INFO_CDMA
+MM_IS_CELL_INFO_CDMA_CLASS
+MM_TYPE_CELL_INFO_CDMA
+MM_CELL_INFO_CDMA
+MM_CELL_INFO_CDMA_CLASS
+MM_CELL_INFO_CDMA_GET_CLASS
+mm_cell_info_cdma_get_type
+</SECTION>
+
+<SECTION>
<FILE>mm-modem-3gpp</FILE>
<TITLE>MMModem3gpp</TITLE>
MMModem3gpp
diff --git a/libmm-glib/Makefile.am b/libmm-glib/Makefile.am
index 4fa050ee..893478ee 100644
--- a/libmm-glib/Makefile.am
+++ b/libmm-glib/Makefile.am
@@ -103,6 +103,8 @@ libmm_glib_la_SOURCES = \
mm-nr5g-registration-settings.c \
mm-cell-info.h \
mm-cell-info.c \
+ mm-cell-info-cdma.h \
+ mm-cell-info-cdma.c \
mm-compat.h \
mm-compat.c \
$(NULL)
@@ -183,6 +185,7 @@ include_HEADERS = \
mm-signal-threshold-properties.h \
mm-nr5g-registration-settings.h \
mm-cell-info.h \
+ mm-cell-info-cdma.h \
mm-compat.h \
$(NULL)
diff --git a/libmm-glib/libmm-glib.h b/libmm-glib/libmm-glib.h
index cf0e93f7..dc92cb8f 100644
--- a/libmm-glib/libmm-glib.h
+++ b/libmm-glib/libmm-glib.h
@@ -87,6 +87,7 @@
#include <mm-signal-threshold-properties.h>
#include <mm-nr5g-registration-settings.h>
#include <mm-cell-info.h>
+#include <mm-cell-info-cdma.h>
#include <mm-compat.h>
/* generated */
diff --git a/libmm-glib/meson.build b/libmm-glib/meson.build
index 1a906db2..40af7a0a 100644
--- a/libmm-glib/meson.build
+++ b/libmm-glib/meson.build
@@ -17,6 +17,7 @@ headers = files(
'mm-call-properties.h',
'mm-cdma-manual-activation-properties.h',
'mm-cell-info.h',
+ 'mm-cell-info-cdma.h',
'mm-compat.h',
'mm-firmware-properties.h',
'mm-firmware-update-settings.h',
@@ -73,6 +74,7 @@ sources = files(
'mm-call-properties.c',
'mm-cdma-manual-activation-properties.c',
'mm-cell-info.c',
+ 'mm-cell-info-cdma.c',
'mm-common-helpers.c',
'mm-compat.c',
'mm-firmware-properties.c',
diff --git a/libmm-glib/mm-cell-info-cdma.c b/libmm-glib/mm-cell-info-cdma.c
new file mode 100644
index 00000000..f288ee26
--- /dev/null
+++ b/libmm-glib/mm-cell-info-cdma.c
@@ -0,0 +1,308 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * libmm-glib -- Access modem status & information from glib applications
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright (C) 2022 Aleksander Morgado <aleksander@aleksander.es>
+ */
+
+#include "mm-helpers.h"
+#include "mm-cell-info-cdma.h"
+
+/**
+ * SECTION: mm-cell-info-cdma
+ * @title: MMCellInfoCdma
+ * @short_description: Helper object to report CDMA cell info
+ *
+ * The #MMCellInfoCdma is an object used to report CDMA cell
+ * information.
+ *
+ * The object inherits from the generic #MMCellInfo.
+ */
+
+G_DEFINE_TYPE (MMCellInfoCdma, mm_cell_info_cdma, MM_TYPE_CELL_INFO)
+
+#define PROPERTY_NID "nid"
+#define PROPERTY_SID "sid"
+#define PROPERTY_BASE_STATION_ID "base-station-id"
+#define PROPERTY_REF_PN "ref-pn"
+#define PROPERTY_PILOT_STRENGTH "pilot-strength"
+
+struct _MMCellInfoCdmaPrivate {
+ gchar *nid;
+ gchar *sid;
+ gchar *base_station_id;
+ gchar *ref_pn;
+ guint pilot_strength;
+};
+
+/*****************************************************************************/
+
+/**
+ * mm_cell_info_cdma_get_nid:
+ * @self: a #MMCellInfoCdma.
+ *
+ * Get the CDMA network id.
+ *
+ * Encoded in upper-case hexadecimal format without leading zeros.
+ *
+ * Returns: (transfer none): the CDMA network id, or %NULL if not available.
+ *
+ * Since: 1.20
+ */
+const gchar *
+mm_cell_info_cdma_get_nid (MMCellInfoCdma *self)
+{
+ g_return_val_if_fail (MM_IS_CELL_INFO_CDMA (self), NULL);
+
+ RETURN_NON_EMPTY_CONSTANT_STRING (self->priv->nid);
+}
+
+/**
+ * mm_cell_info_cdma_set_nid: (skip)
+ */
+void
+mm_cell_info_cdma_set_nid (MMCellInfoCdma *self,
+ const gchar *nid)
+{
+ g_free (self->priv->nid);
+ self->priv->nid = g_strdup (nid);
+}
+
+/**
+ * mm_cell_info_cdma_get_sid:
+ * @self: a #MMCellInfoCdma.
+ *
+ * Get the CDMA system id.
+ *
+ * Encoded in upper-case hexadecimal format without leading zeros.
+ *
+ * Returns: (transfer none): the CDMA system id, or %NULL if not available.
+ *
+ * Since: 1.20
+ */
+const gchar *
+mm_cell_info_cdma_get_sid (MMCellInfoCdma *self)
+{
+ g_return_val_if_fail (MM_IS_CELL_INFO_CDMA (self), NULL);
+
+ RETURN_NON_EMPTY_CONSTANT_STRING (self->priv->sid);
+}
+
+/**
+ * mm_cell_info_cdma_set_sid: (skip)
+ */
+void
+mm_cell_info_cdma_set_sid (MMCellInfoCdma *self,
+ const gchar *sid)
+{
+ g_free (self->priv->sid);
+ self->priv->sid = g_strdup (sid);
+}
+
+/**
+ * mm_cell_info_cdma_get_base_station_id:
+ * @self: a #MMCellInfoCdma.
+ *
+ * Get the CDMA base station id.
+ *
+ * Encoded in upper-case hexadecimal format without leading zeros.
+ *
+ * Returns: (transfer none): the CDMA base station id, or %NULL if not available.
+ *
+ * Since: 1.20
+ */
+const gchar *
+mm_cell_info_cdma_get_base_station_id (MMCellInfoCdma *self)
+{
+ g_return_val_if_fail (MM_IS_CELL_INFO_CDMA (self), NULL);
+
+ RETURN_NON_EMPTY_CONSTANT_STRING (self->priv->base_station_id);
+}
+
+/**
+ * mm_cell_info_cdma_set_base_station_id: (skip)
+ */
+void
+mm_cell_info_cdma_set_base_station_id (MMCellInfoCdma *self,
+ const gchar *base_station_id)
+{
+ g_free (self->priv->base_station_id);
+ self->priv->base_station_id = g_strdup (base_station_id);
+}
+
+/**
+ * mm_cell_info_cdma_get_ref_pn:
+ * @self: a #MMCellInfoCdma.
+ *
+ * Get the CDMA base station PN number.
+ *
+ * Encoded in upper-case hexadecimal format without leading zeros.
+ *
+ * Returns: (transfer none): the CDMA base station PN number, or %NULL if not available.
+ *
+ * Since: 1.20
+ */
+const gchar *
+mm_cell_info_cdma_get_ref_pn (MMCellInfoCdma *self)
+{
+ g_return_val_if_fail (MM_IS_CELL_INFO_CDMA (self), NULL);
+
+ RETURN_NON_EMPTY_CONSTANT_STRING (self->priv->ref_pn);
+}
+
+/**
+ * mm_cell_info_cdma_set_ref_pn: (skip)
+ */
+void
+mm_cell_info_cdma_set_ref_pn (MMCellInfoCdma *self,
+ const gchar *ref_pn)
+{
+ g_free (self->priv->ref_pn);
+ self->priv->ref_pn = g_strdup (ref_pn);
+}
+
+/**
+ * mm_cell_info_cdma_get_pilot_strength:
+ * @self: a #MMCellInfoCdma.
+ *
+ * Get the signal strength of the pilot.
+ *
+ * Given in the same format and scale as the GSM SINR level.
+ *
+ * Returns: the pilot strength, or %G_MAXUINT if not available.
+ *
+ * Since: 1.20
+ */
+guint
+mm_cell_info_cdma_get_pilot_strength (MMCellInfoCdma *self)
+{
+ g_return_val_if_fail (MM_IS_CELL_INFO_CDMA (self), G_MAXUINT);
+
+ return self->priv->pilot_strength;
+}
+
+/**
+ * mm_cell_info_cdma_set_pilot_strength: (skip)
+ */
+void
+mm_cell_info_cdma_set_pilot_strength (MMCellInfoCdma *self,
+ guint pilot_strength)
+{
+ self->priv->pilot_strength = pilot_strength;
+}
+
+/*****************************************************************************/
+
+static GString *
+build_string (MMCellInfo *_self)
+{
+ MMCellInfoCdma *self = MM_CELL_INFO_CDMA (_self);
+ GString *str;
+
+ str = g_string_new (NULL);
+
+ MM_CELL_INFO_BUILD_STRING_APPEND ("nid", "%s", nid, NULL);
+ MM_CELL_INFO_BUILD_STRING_APPEND ("sid", "%s", sid, NULL);
+ MM_CELL_INFO_BUILD_STRING_APPEND ("base station id", "%s", base_station_id, NULL);
+ MM_CELL_INFO_BUILD_STRING_APPEND ("ref pn", "%s", ref_pn, NULL);
+ MM_CELL_INFO_BUILD_STRING_APPEND ("pilot strength", "%u", pilot_strength, G_MAXUINT);
+
+ return str;
+}
+
+/*****************************************************************************/
+
+/**
+ * mm_cell_info_cdma_get_dictionary: (skip)
+ */
+static GVariantDict *
+get_dictionary (MMCellInfo *_self)
+{
+ MMCellInfoCdma *self = MM_CELL_INFO_CDMA (_self);
+ GVariantDict *dict;
+
+ dict = g_variant_dict_new (NULL);
+
+ MM_CELL_INFO_GET_DICTIONARY_INSERT (NID, nid, string, NULL);
+ MM_CELL_INFO_GET_DICTIONARY_INSERT (SID, sid, string, NULL);
+ MM_CELL_INFO_GET_DICTIONARY_INSERT (BASE_STATION_ID, base_station_id, string, NULL);
+ MM_CELL_INFO_GET_DICTIONARY_INSERT (REF_PN, ref_pn, string, NULL);
+ MM_CELL_INFO_GET_DICTIONARY_INSERT (PILOT_STRENGTH, pilot_strength, uint32, G_MAXUINT);
+
+ return dict;
+}
+
+/*****************************************************************************/
+
+/**
+ * mm_cell_info_cdma_new_from_dictionary: (skip)
+ */
+MMCellInfo *
+mm_cell_info_cdma_new_from_dictionary (GVariantDict *dict)
+{
+ MMCellInfoCdma *self;
+
+ self = MM_CELL_INFO_CDMA (g_object_new (MM_TYPE_CELL_INFO_CDMA, NULL));
+
+ if (dict) {
+
+ MM_CELL_INFO_NEW_FROM_DICTIONARY_STRING_SET (cdma, NID, nid);
+ MM_CELL_INFO_NEW_FROM_DICTIONARY_STRING_SET (cdma, SID, sid);
+ MM_CELL_INFO_NEW_FROM_DICTIONARY_STRING_SET (cdma, BASE_STATION_ID, base_station_id);
+ MM_CELL_INFO_NEW_FROM_DICTIONARY_STRING_SET (cdma, REF_PN, ref_pn);
+ MM_CELL_INFO_NEW_FROM_DICTIONARY_NUM_SET (cdma, PILOT_STRENGTH, pilot_strength, UINT32, uint32);
+ }
+
+ return MM_CELL_INFO (self);
+}
+
+/*****************************************************************************/
+
+static void
+mm_cell_info_cdma_init (MMCellInfoCdma *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_CELL_INFO_CDMA, MMCellInfoCdmaPrivate);
+ self->priv->pilot_strength = G_MAXUINT;
+}
+
+static void
+finalize (GObject *object)
+{
+ MMCellInfoCdma *self = MM_CELL_INFO_CDMA (object);
+
+ g_free (self->priv->sid);
+ g_free (self->priv->nid);
+ g_free (self->priv->base_station_id);
+ g_free (self->priv->ref_pn);
+
+ G_OBJECT_CLASS (mm_cell_info_cdma_parent_class)->finalize (object);
+}
+
+static void
+mm_cell_info_cdma_class_init (MMCellInfoCdmaClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ MMCellInfoClass *cell_info_class = MM_CELL_INFO_CLASS (klass);
+
+ g_type_class_add_private (object_class, sizeof (MMCellInfoCdmaPrivate));
+
+ object_class->finalize = finalize;
+ cell_info_class->get_dictionary = get_dictionary;
+ cell_info_class->build_string = build_string;
+
+}
diff --git a/libmm-glib/mm-cell-info-cdma.h b/libmm-glib/mm-cell-info-cdma.h
new file mode 100644
index 00000000..994fbcc1
--- /dev/null
+++ b/libmm-glib/mm-cell-info-cdma.h
@@ -0,0 +1,98 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * libmm-glib -- Access modem status & information from glib applications
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright (C) 2022 Aleksander Morgado <aleksander@aleksander.es>
+ */
+
+#ifndef MM_CELL_INFO_CDMA_H
+#define MM_CELL_INFO_CDMA_H
+
+#if !defined (__LIBMM_GLIB_H_INSIDE__) && !defined (LIBMM_GLIB_COMPILATION)
+#error "Only <libmm-glib.h> can be included directly."
+#endif
+
+#include <ModemManager.h>
+#include <glib-object.h>
+
+#include "mm-cell-info.h"
+
+G_BEGIN_DECLS
+
+#define MM_TYPE_CELL_INFO_CDMA (mm_cell_info_cdma_get_type ())
+#define MM_CELL_INFO_CDMA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_CELL_INFO_CDMA, MMCellInfoCdma))
+#define MM_CELL_INFO_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_CELL_INFO_CDMA, MMCellInfoCdmaClass))
+#define MM_IS_CELL_INFO_CDMA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_CELL_INFO_CDMA))
+#define MM_IS_CELL_INFO_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_CELL_INFO_CDMA))
+#define MM_CELL_INFO_CDMA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_CELL_INFO_CDMA, MMCellInfoCdmaClass))
+
+typedef struct _MMCellInfoCdma MMCellInfoCdma;
+typedef struct _MMCellInfoCdmaClass MMCellInfoCdmaClass;
+typedef struct _MMCellInfoCdmaPrivate MMCellInfoCdmaPrivate;
+
+/**
+ * MMCellInfoCdma:
+ *
+ * The #MMCellInfoCdma structure contains private data and should only be
+ * accessed using the provided API.
+ */
+struct _MMCellInfoCdma {
+ /*< private >*/
+ MMCellInfo parent;
+ MMCellInfoCdmaPrivate *priv;
+};
+
+struct _MMCellInfoCdmaClass {
+ /*< private >*/
+ MMCellInfoClass parent;
+};
+
+GType mm_cell_info_cdma_get_type (void);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (MMCellInfoCdma, g_object_unref)
+
+const gchar *mm_cell_info_cdma_get_nid (MMCellInfoCdma *self);
+const gchar *mm_cell_info_cdma_get_sid (MMCellInfoCdma *self);
+const gchar *mm_cell_info_cdma_get_base_station_id (MMCellInfoCdma *self);
+const gchar *mm_cell_info_cdma_get_ref_pn (MMCellInfoCdma *self);
+guint mm_cell_info_cdma_get_pilot_strength (MMCellInfoCdma *self);
+
+/*****************************************************************************/
+/* ModemManager/libmm-glib/mmcli specific methods */
+
+#if defined (_LIBMM_INSIDE_MM) || \
+ defined (_LIBMM_INSIDE_MMCLI) || \
+ defined (LIBMM_GLIB_COMPILATION)
+
+void mm_cell_info_cdma_set_nid (MMCellInfoCdma *self,
+ const gchar *nid);
+void mm_cell_info_cdma_set_sid (MMCellInfoCdma *self,
+ const gchar *sid);
+void mm_cell_info_cdma_set_base_station_id (MMCellInfoCdma *self,
+ const gchar *base_station_id);
+void mm_cell_info_cdma_set_ref_pn (MMCellInfoCdma *self,
+ const gchar *ref_pn);
+void mm_cell_info_cdma_set_pilot_strength (MMCellInfoCdma *self,
+ guint pilot_strength);
+
+MMCellInfo *mm_cell_info_cdma_new_from_dictionary (GVariantDict *dict);
+
+#endif
+
+G_END_DECLS
+
+#endif /* MM_CELL_INFO_CDMA_H */
diff --git a/libmm-glib/mm-cell-info.c b/libmm-glib/mm-cell-info.c
index e733c769..c7267001 100644
--- a/libmm-glib/mm-cell-info.c
+++ b/libmm-glib/mm-cell-info.c
@@ -21,6 +21,7 @@
*/
#include "mm-cell-info.h"
+#include "mm-cell-info-cdma.h"
#include "mm-enums-types.h"
#include "mm-errors-types.h"
@@ -54,7 +55,9 @@ ensure_cell_type (MMCellInfo *self)
if (self->priv->cell_type != MM_CELL_TYPE_UNKNOWN)
return;
- /* MM_CELL_TYPE_CDMA; */
+ if (MM_IS_CELL_INFO_CDMA (self))
+ self->priv->cell_type = MM_CELL_TYPE_CDMA;
+
/* MM_CELL_TYPE_GSM; */
/* MM_CELL_TYPE_UMTS; */
/* MM_CELL_TYPE_TDSCDMA; */
@@ -154,6 +157,8 @@ mm_cell_info_new_from_dictionary (GVariant *dictionary,
}
switch (g_variant_get_uint32 (aux)) {
case MM_CELL_TYPE_CDMA:
+ self = mm_cell_info_cdma_new_from_dictionary (dict);
+ break;
case MM_CELL_TYPE_GSM:
case MM_CELL_TYPE_UMTS:
case MM_CELL_TYPE_TDSCDMA: