diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2014-06-27 10:28:16 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2014-06-27 10:28:16 +0200 |
commit | d01586df0ac5ab29c96fd2d1c20a25e6f8cec019 (patch) | |
tree | c12a36e8c2d1bae3c086dbce461f232504e55657 | |
parent | 4406b1e6ece6507518362cf5fdb53d09243ddfb8 (diff) | |
download | ModemManager-d01586df0ac5ab29c96fd2d1c20a25e6f8cec019.tar.gz |
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.
-rw-r--r-- | include/ModemManager-enums.h | 12 | ||||
-rw-r--r-- | src/mm-iface-modem-location.c | 24 |
2 files changed, 30 insertions, 6 deletions
diff --git a/include/ModemManager-enums.h b/include/ModemManager-enums.h index 5ff799f0c..87e5c5e7a 100644 --- a/include/ModemManager-enums.h +++ b/include/ModemManager-enums.h @@ -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; /** diff --git a/src/mm-iface-modem-location.c b/src/mm-iface-modem-location.c index 32f9a7311..d3ae680b6 100644 --- a/src/mm-iface-modem-location.c +++ b/src/mm-iface-modem-location.c @@ -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; } @@ -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, |