summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-10-31 12:35:01 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-11-02 08:23:11 +0100
commitb508316a5a87409e9acf5a625f7501280dd29f74 (patch)
treef1d789f50669076ceec5acd72367f7ef931ace49
parentd9241d08db31cf5bbb91ecc13c5b6839161a3804 (diff)
cli: new actions to setup or gather CDMA BS location source
-rw-r--r--cli/mmcli-modem-location.c74
-rw-r--r--docs/man/mmcli.824
2 files changed, 82 insertions, 16 deletions
diff --git a/cli/mmcli-modem-location.c b/cli/mmcli-modem-location.c
index d96aabae..caf1bf29 100644
--- a/cli/mmcli-modem-location.c
+++ b/cli/mmcli-modem-location.c
@@ -55,6 +55,9 @@ static gboolean get_gps_nmea_flag;
static gboolean enable_gps_raw_flag;
static gboolean disable_gps_raw_flag;
static gboolean get_gps_raw_flag;
+static gboolean enable_cdma_bs_flag;
+static gboolean disable_cdma_bs_flag;
+static gboolean get_cdma_bs_flag;
static gboolean get_all_flag;
static GOptionEntry entries[] = {
@@ -102,6 +105,18 @@ static GOptionEntry entries[] = {
"Get raw GPS location.",
NULL
},
+ { "location-enable-cdma-bs", 0, 0, G_OPTION_ARG_NONE, &enable_cdma_bs_flag,
+ "Enable CDMA base station location gathering.",
+ NULL
+ },
+ { "location-disable-cdma-bs", 0, 0, G_OPTION_ARG_NONE, &disable_cdma_bs_flag,
+ "Disable CDMA base station location gathering.",
+ NULL
+ },
+ { "location-get-cdma-bs", 0, 0, G_OPTION_ARG_NONE, &get_cdma_bs_flag,
+ "Get CDMA base station location.",
+ NULL
+ },
{ NULL }
};
@@ -131,7 +146,8 @@ mmcli_modem_location_options_enabled (void)
if ((enable_3gpp_flag && disable_3gpp_flag) ||
(enable_gps_nmea_flag && disable_gps_nmea_flag) ||
- (enable_gps_raw_flag && disable_gps_raw_flag)) {
+ (enable_gps_raw_flag && disable_gps_raw_flag) ||
+ (enable_cdma_bs_flag && disable_cdma_bs_flag)) {
g_printerr ("error: cannot enable and disable the same source\n");
exit (EXIT_FAILURE);
}
@@ -140,6 +156,7 @@ mmcli_modem_location_options_enabled (void)
get_3gpp_flag = TRUE;
get_gps_nmea_flag = TRUE;
get_gps_raw_flag = TRUE;
+ get_cdma_bs_flag = TRUE;
}
n_actions = (status_flag +
@@ -148,10 +165,13 @@ mmcli_modem_location_options_enabled (void)
enable_gps_nmea_flag +
disable_gps_nmea_flag +
enable_gps_raw_flag +
- disable_gps_raw_flag) +
+ disable_gps_raw_flag +
+ enable_cdma_bs_flag +
+ disable_cdma_bs_flag) +
!!(get_3gpp_flag +
get_gps_nmea_flag +
- get_gps_raw_flag));
+ get_gps_raw_flag +
+ get_cdma_bs_flag));
if (n_actions > 1) {
g_printerr ("error: too many Location actions requested\n");
@@ -277,6 +297,11 @@ build_sources_from_flags (void)
if (disable_gps_raw_flag)
sources &= ~MM_MODEM_LOCATION_SOURCE_GPS_RAW;
+ if (enable_cdma_bs_flag)
+ sources |= MM_MODEM_LOCATION_SOURCE_CDMA_BS;
+ if (disable_cdma_bs_flag)
+ sources &= ~MM_MODEM_LOCATION_SOURCE_CDMA_BS;
+
return sources;
}
@@ -284,6 +309,7 @@ static void
get_location_process_reply (MMLocation3gpp *location_3gpp,
MMLocationGpsNmea *location_gps_nmea,
MMLocationGpsRaw *location_gps_raw,
+ MMLocationCdmaBs *location_cdma_bs,
const GError *error)
{
/* First, check for failures */
@@ -308,6 +334,12 @@ get_location_process_reply (MMLocation3gpp *location_3gpp,
exit_error = TRUE;
}
+ if (get_cdma_bs_flag && !location_cdma_bs) {
+ g_printerr ("error: couldn't get CDMA base station location from the modem: '%s'\n",
+ error ? error->message : "not available");
+ exit_error = TRUE;
+ }
+
if (exit_error)
exit (EXIT_FAILURE);
} else if (error) {
@@ -372,12 +404,26 @@ get_location_process_reply (MMLocation3gpp *location_3gpp,
" Raw GPS | Not available\n");
}
+ if (get_cdma_bs_flag) {
+ if (location_cdma_bs)
+ g_print (" -------------------------\n"
+ " CDMA BS | Longitude: '%lf'\n"
+ " | Latitude: '%lf'\n",
+ mm_location_cdma_bs_get_longitude (location_cdma_bs),
+ mm_location_cdma_bs_get_latitude (location_cdma_bs));
+ else
+ g_print (" -------------------------\n"
+ " CDMA BS | Not available\n");
+ }
+
if (location_3gpp)
g_object_unref (location_3gpp);
if (location_gps_nmea)
g_object_unref (location_gps_nmea);
if (location_gps_raw)
g_object_unref (location_gps_raw);
+ if (location_cdma_bs)
+ g_object_unref (location_cdma_bs);
}
static void
@@ -387,6 +433,7 @@ get_location_ready (MMModemLocation *modem_location,
MMLocation3gpp *location_3gpp = NULL;
MMLocationGpsNmea *location_gps_nmea = NULL;
MMLocationGpsRaw *location_gps_raw = NULL;
+ MMLocationCdmaBs *location_cdma_bs = NULL;
GError *error = NULL;
mm_modem_location_get_full_finish (modem_location,
@@ -394,8 +441,9 @@ get_location_ready (MMModemLocation *modem_location,
get_3gpp_flag ? &location_3gpp : NULL,
get_gps_nmea_flag ? &location_gps_nmea : NULL,
get_gps_raw_flag ? &location_gps_raw : NULL,
+ get_cdma_bs_flag ? &location_cdma_bs : NULL,
&error);
- get_location_process_reply (location_3gpp, location_gps_nmea, location_gps_raw, error);
+ get_location_process_reply (location_3gpp, location_gps_nmea, location_gps_raw, location_cdma_bs, error);
mmcli_async_operation_done ();
}
@@ -423,7 +471,9 @@ get_modem_ready (GObject *source,
enable_gps_nmea_flag ||
disable_gps_nmea_flag ||
enable_gps_raw_flag ||
- disable_gps_raw_flag) {
+ disable_gps_raw_flag ||
+ enable_cdma_bs_flag ||
+ disable_cdma_bs_flag) {
g_debug ("Asynchronously setting up location gathering...");
mm_modem_location_setup (ctx->modem_location,
build_sources_from_flags (),
@@ -437,7 +487,8 @@ get_modem_ready (GObject *source,
/* Request to get location from the modem? */
if (get_3gpp_flag ||
get_gps_nmea_flag ||
- get_gps_raw_flag) {
+ get_gps_raw_flag ||
+ get_cdma_bs_flag) {
g_debug ("Asynchronously getting location from the modem...");
mm_modem_location_get_full (ctx->modem_location,
ctx->cancellable,
@@ -497,7 +548,9 @@ mmcli_modem_location_run_synchronous (GDBusConnection *connection)
enable_gps_nmea_flag ||
disable_gps_nmea_flag ||
enable_gps_raw_flag ||
- disable_gps_raw_flag) {
+ disable_gps_raw_flag ||
+ enable_cdma_bs_flag ||
+ disable_cdma_bs_flag) {
gboolean result;
g_debug ("Synchronously setting up location gathering...");
@@ -513,19 +566,22 @@ mmcli_modem_location_run_synchronous (GDBusConnection *connection)
/* Request to get location from the modem? */
if (get_3gpp_flag ||
get_gps_nmea_flag ||
- get_gps_raw_flag) {
+ get_gps_raw_flag ||
+ get_cdma_bs_flag) {
MMLocation3gpp *location_3gpp = NULL;
MMLocationGpsNmea *location_gps_nmea = NULL;
MMLocationGpsRaw *location_gps_raw = NULL;
+ MMLocationCdmaBs *location_cdma_bs = NULL;
g_debug ("Synchronously getting location from the modem...");
mm_modem_location_get_full_sync (ctx->modem_location,
get_3gpp_flag ? &location_3gpp : NULL,
get_gps_nmea_flag ? &location_gps_nmea : NULL,
get_gps_raw_flag ? &location_gps_raw : NULL,
+ get_cdma_bs_flag ? &location_cdma_bs : NULL,
NULL,
&error);
- get_location_process_reply (location_3gpp, location_gps_nmea, location_gps_raw, error);
+ get_location_process_reply (location_3gpp, location_gps_nmea, location_gps_raw, location_cdma_bs, error);
return;
}
diff --git a/docs/man/mmcli.8 b/docs/man/mmcli.8
index 9f59725a..8d022b34 100644
--- a/docs/man/mmcli.8
+++ b/docs/man/mmcli.8
@@ -317,9 +317,8 @@ Display the status of the given modem.
.SH LOCATION OPTIONS
These options detail how to discover your location using Global
-Positioning System (GPS), 3rd Generation Partnership Project
-(3GPP) and National Marine Electronics Association (NMEA)
-technologies.
+Positioning System (GPS) or directly from your mobile network infrastructure
+(either 3GPP or 3GPP2).
All location options must be used with \fB\-\-modem\fR or \fB\-m\fR.
@@ -331,13 +330,13 @@ Show the current status for discovering our location.
Show all location information available.
.TP
.B \-\-location\-enable\-3gpp
-Enable location discovery using 3GPP.
+Enable location discovery using the 3GPP network.
.TP
.B \-\-location\-disable\-3gpp
-Disable location discovery using 3GPP.
+Disable location discovery using the 3GPP network.
.TP
.B \-\-location\-get\-3gpp
-Show 3GPP based location information.
+Show 3GPP based location information (MCC, MNC, LAC, CI).
.TP
.B \-\-location\-enable\-gps\-nmea
Enable location discovery using GPS and reported with NMEA traces.
@@ -356,7 +355,16 @@ longitude/latitude) values.
Disable location discovery using GPS and raw values.
.TP
.B \-\-location\-get\-gps\-raw
-Show GPS based location information with raw values.
+Show GPS based location information with raw values (e.g. latitude, longitude).
+.TP
+.B \-\-location\-enable\-cdma-bs
+Enable location discovery using the 3GPP2 network.
+.TP
+.B \-\-location\-disable\-cdma-bs
+Disable location discovery using the 3GPP2 network.
+.TP
+.B \-\-location\-get\-cdma-bs
+Show 3GPP2 based location information (location of the CDMA base station).
.SH MESSAGING OPTIONS
All messaging options must be used with \fB\-\-modem\fR or \fB\-m\fR.
@@ -705,6 +713,8 @@ You can query location source specific information with
| $GPVTG,,T,,M,,N,,K,N*2C
-------------------------
Raw GPS | Not available
+ -------------------------
+ CDMA BS | Not available
.Ed
An example of RAW GPS location information: