location: new 'unmanaged' GPS setup
Standard GPS setup (raw/nmea) will both enable the GPS module and take full control of the GPS port. This prevents other processes from reading the NMEA traces from e.g. a tty. In order to handle this, a new 'unmanaged' GPS location source is introduced, which will just enable/disable the GPS module, without reading anything from the GPS port. Of course, both raw/nmea and unmanaged setups cannot be enabled at the same time.
This commit is contained in:
@@ -58,6 +58,8 @@ 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 enable_gps_unmanaged_flag;
|
||||
static gboolean disable_gps_unmanaged_flag;
|
||||
static gboolean get_all_flag;
|
||||
|
||||
static GOptionEntry entries[] = {
|
||||
@@ -117,6 +119,14 @@ static GOptionEntry entries[] = {
|
||||
"Get CDMA base station location.",
|
||||
NULL
|
||||
},
|
||||
{ "location-enable-gps-unmanaged", 0, 0, G_OPTION_ARG_NONE, &enable_gps_unmanaged_flag,
|
||||
"Enable unmanaged GPS location gathering.",
|
||||
NULL
|
||||
},
|
||||
{ "location-disable-gps-unmanaged", 0, 0, G_OPTION_ARG_NONE, &disable_gps_unmanaged_flag,
|
||||
"Disable unmanaged GPS location gathering.",
|
||||
NULL
|
||||
},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@@ -147,6 +157,7 @@ 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_unmanaged_flag && disable_gps_unmanaged_flag) ||
|
||||
(enable_cdma_bs_flag && disable_cdma_bs_flag)) {
|
||||
g_printerr ("error: cannot enable and disable the same source\n");
|
||||
exit (EXIT_FAILURE);
|
||||
@@ -167,7 +178,9 @@ mmcli_modem_location_options_enabled (void)
|
||||
enable_gps_raw_flag +
|
||||
disable_gps_raw_flag +
|
||||
enable_cdma_bs_flag +
|
||||
disable_cdma_bs_flag) +
|
||||
disable_cdma_bs_flag +
|
||||
enable_gps_unmanaged_flag +
|
||||
disable_gps_unmanaged_flag) +
|
||||
!!(get_3gpp_flag +
|
||||
get_gps_nmea_flag +
|
||||
get_gps_raw_flag +
|
||||
@@ -302,6 +315,11 @@ build_sources_from_flags (void)
|
||||
if (disable_cdma_bs_flag)
|
||||
sources &= ~MM_MODEM_LOCATION_SOURCE_CDMA_BS;
|
||||
|
||||
if (enable_gps_unmanaged_flag)
|
||||
sources |= MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED;
|
||||
if (disable_gps_unmanaged_flag)
|
||||
sources &= ~MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED;
|
||||
|
||||
return sources;
|
||||
}
|
||||
|
||||
@@ -473,7 +491,9 @@ get_modem_ready (GObject *source,
|
||||
enable_gps_raw_flag ||
|
||||
disable_gps_raw_flag ||
|
||||
enable_cdma_bs_flag ||
|
||||
disable_cdma_bs_flag) {
|
||||
disable_cdma_bs_flag ||
|
||||
enable_gps_unmanaged_flag ||
|
||||
disable_gps_unmanaged_flag) {
|
||||
g_debug ("Asynchronously setting up location gathering...");
|
||||
mm_modem_location_setup (ctx->modem_location,
|
||||
build_sources_from_flags (),
|
||||
@@ -550,7 +570,9 @@ mmcli_modem_location_run_synchronous (GDBusConnection *connection)
|
||||
enable_gps_raw_flag ||
|
||||
disable_gps_raw_flag ||
|
||||
enable_cdma_bs_flag ||
|
||||
disable_cdma_bs_flag) {
|
||||
disable_cdma_bs_flag ||
|
||||
enable_gps_unmanaged_flag ||
|
||||
disable_gps_unmanaged_flag) {
|
||||
gboolean result;
|
||||
|
||||
g_debug ("Synchronously setting up location gathering...");
|
||||
|
||||
@@ -359,6 +359,13 @@ Disable location discovery using the 3GPP2 network.
|
||||
.TP
|
||||
.B \-\-location\-get\-cdma-bs
|
||||
Show 3GPP2 based location information (location of the CDMA base station).
|
||||
.TP
|
||||
.B \-\-location\-enable\-gps\-unmanaged
|
||||
Enable location discovery using GPS but without taking control of the NMEA tty
|
||||
port.
|
||||
.TP
|
||||
.B \-\-location\-disable\-gps\-unmanaged
|
||||
Disable location discovery using GPS and unmanaged port.
|
||||
|
||||
.SH MESSAGING OPTIONS
|
||||
All messaging options must be used with \fB\-\-modem\fR or \fB\-m\fR.
|
||||
|
||||
@@ -818,15 +818,17 @@ typedef enum { /*< underscore_name=mm_sms_cdma_service_category >*/
|
||||
* @MM_MODEM_LOCATION_SOURCE_GPS_RAW: GPS location given by predefined keys.
|
||||
* @MM_MODEM_LOCATION_SOURCE_GPS_NMEA: GPS location given as NMEA traces.
|
||||
* @MM_MODEM_LOCATION_SOURCE_CDMA_BS: CDMA base station position.
|
||||
* @MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED: No location given, just GPS module setup.
|
||||
*
|
||||
* Sources of location information supported by the modem.
|
||||
*/
|
||||
typedef enum { /*< underscore_name=mm_modem_location_source >*/
|
||||
MM_MODEM_LOCATION_SOURCE_NONE = 0,
|
||||
MM_MODEM_LOCATION_SOURCE_3GPP_LAC_CI = 1 << 0,
|
||||
MM_MODEM_LOCATION_SOURCE_GPS_RAW = 1 << 1,
|
||||
MM_MODEM_LOCATION_SOURCE_GPS_NMEA = 1 << 2,
|
||||
MM_MODEM_LOCATION_SOURCE_CDMA_BS = 1 << 3,
|
||||
MM_MODEM_LOCATION_SOURCE_NONE = 0,
|
||||
MM_MODEM_LOCATION_SOURCE_3GPP_LAC_CI = 1 << 0,
|
||||
MM_MODEM_LOCATION_SOURCE_GPS_RAW = 1 << 1,
|
||||
MM_MODEM_LOCATION_SOURCE_GPS_NMEA = 1 << 2,
|
||||
MM_MODEM_LOCATION_SOURCE_CDMA_BS = 1 << 3,
|
||||
MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED = 1 << 4,
|
||||
} MMModemLocationSource;
|
||||
|
||||
/**
|
||||
|
||||
@@ -137,6 +137,8 @@ build_location_dictionary (GVariant *previous,
|
||||
case MM_MODEM_LOCATION_SOURCE_CDMA_BS:
|
||||
location_cdma_bs_value = value;
|
||||
break;
|
||||
case MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED:
|
||||
g_assert_not_reached ();
|
||||
default:
|
||||
g_warn_if_reached ();
|
||||
break;
|
||||
@@ -505,6 +507,8 @@ update_location_source_status (MMIfaceModemLocation *self,
|
||||
} else
|
||||
g_clear_object (&ctx->location_cdma_bs);
|
||||
break;
|
||||
case MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED:
|
||||
/* Nothing to setup in the context */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -612,7 +616,7 @@ setup_gathering_step (SetupGatheringContext *ctx)
|
||||
return;
|
||||
}
|
||||
|
||||
while (ctx->current <= MM_MODEM_LOCATION_SOURCE_CDMA_BS) {
|
||||
while (ctx->current <= MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED) {
|
||||
gchar *source_str;
|
||||
|
||||
if (ctx->to_enable & ctx->current) {
|
||||
@@ -709,7 +713,7 @@ setup_gathering (MMIfaceModemLocation *self,
|
||||
|
||||
/* Loop through all known bits in the bitmask to enable/disable specific location sources */
|
||||
for (source = MM_MODEM_LOCATION_SOURCE_3GPP_LAC_CI;
|
||||
source <= MM_MODEM_LOCATION_SOURCE_CDMA_BS;
|
||||
source <= MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED;
|
||||
source = source << 1) {
|
||||
/* skip unsupported sources */
|
||||
if (!(mm_gdbus_modem_location_get_capabilities (ctx->skeleton) & source))
|
||||
@@ -734,6 +738,22 @@ setup_gathering (MMIfaceModemLocation *self,
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
/* When standard GPS retrieval (RAW/NMEA) is enabled, we cannot enable the
|
||||
* UNMANAGED setup, and viceversa. */
|
||||
if ((ctx->to_enable & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED &&
|
||||
currently_enabled & (MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA)) ||
|
||||
(ctx->to_enable & (MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA) &&
|
||||
currently_enabled & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED) ||
|
||||
(ctx->to_enable & (MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA) &&
|
||||
ctx->to_enable & MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED)) {
|
||||
g_simple_async_result_set_error (ctx->result,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_FAILED,
|
||||
"Cannot have both unmanaged GPS and raw/nmea GPS enabled at the same time");
|
||||
setup_gathering_context_complete_and_free (ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx->to_enable != MM_MODEM_LOCATION_SOURCE_NONE) {
|
||||
str = mm_modem_location_source_build_string_from_mask (ctx->to_enable);
|
||||
mm_dbg ("Need to enable the following location sources: '%s'", str);
|
||||
@@ -1162,7 +1182,9 @@ interface_enabling_step (EnablingContext *ctx)
|
||||
|
||||
/* By default, we'll enable all NON-GPS sources */
|
||||
default_sources = mm_gdbus_modem_location_get_capabilities (ctx->skeleton);
|
||||
default_sources &= ~(MM_MODEM_LOCATION_SOURCE_GPS_RAW | MM_MODEM_LOCATION_SOURCE_GPS_NMEA);
|
||||
default_sources &= ~(MM_MODEM_LOCATION_SOURCE_GPS_RAW |
|
||||
MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
||||
MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED);
|
||||
|
||||
setup_gathering (ctx->self,
|
||||
default_sources,
|
||||
|
||||
Reference in New Issue
Block a user