api: support location assistance data

Sometimes SUPL-server based A-GPS is not possible, e.g. if the module
doesn't have Internet connectivity. In such cases, the modem may
support injecting additional "assistance data" that may be downloaded
from the Internet using external means (e.g. WiFi), in order to keep
having a quick time to first fix.

We now support using this location assistance data, with the following
new API elements:

 * A new mask of supported assistance data types is provided in the
   SupportedAssistanceData property.

 * A new list of URLs from where the aassistance data may be
   downloaded is also provided in a new AssistanceDataServers
   property.

 * A new InjectAssistanceData() method is provided, to perform the
   data injection in the module once it's been downloaded to the host
   system.
This commit is contained in:
Aleksander Morgado
2018-08-21 13:26:08 +00:00
committed by Dan Williams
parent 0798f32362
commit 091bf4dbd8
9 changed files with 596 additions and 14 deletions
+153
View File
@@ -100,6 +100,24 @@ mm_modem_location_get_capabilities (MMModemLocation *self)
/*****************************************************************************/
/**
* mm_modem_location_get_supported_assistance_data:
* @self: A #MMModemLocation.
*
* Gets a bitmask of the supported assistance data types.
*
* Returns: A #MMModemLocationAssistanceDataType.
*/
MMModemLocationAssistanceDataType
mm_modem_location_get_supported_assistance_data (MMModemLocation *self)
{
g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), MM_MODEM_LOCATION_ASSISTANCE_DATA_TYPE_NONE);
return (MMModemLocationAssistanceDataType) mm_gdbus_modem_location_get_supported_assistance_data (MM_GDBUS_MODEM_LOCATION (self));
}
/*****************************************************************************/
/**
* mm_modem_location_get_enabled:
* @self: A #MMModemLocation.
@@ -306,6 +324,91 @@ mm_modem_location_set_supl_server_sync (MMModemLocation *self,
/*****************************************************************************/
/**
* mm_modem_location_inject_assistance_data_finish:
* @self: A #MMModemLocation.
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_location_inject_assistance_data().
* @error: Return location for error or %NULL.
*
* Finishes an operation started with mm_modem_location_inject_assistance_data().
*
* Returns: %TRUE if the injection was successful, %FALSE if @error is set.
*/
gboolean
mm_modem_location_inject_assistance_data_finish (MMModemLocation *self,
GAsyncResult *res,
GError **error)
{
g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE);
return mm_gdbus_modem_location_call_inject_assistance_data_finish (MM_GDBUS_MODEM_LOCATION (self), res, error);
}
/**
* mm_modem_location_inject_assistance_data:
* @self: A #MMModemLocation.
* @data: (array length=data_size): Data to inject.
* @data_size: size of @data.
* @cancellable: (allow-none): A #GCancellable or %NULL.
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
* @user_data: User data to pass to @callback.
*
* Aynchronously injects assistance data to the GNSS module.
*
* When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
* You can then call mm_modem_location_inject_assistance_data_finish() to get the result of the operation.
*
* See mm_modem_location_inject_assistance_data_sync() for the synchronous, blocking version of this method.
*/
void
mm_modem_location_inject_assistance_data (MMModemLocation *self,
const guint8 *data,
gsize data_size,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (MM_IS_MODEM_LOCATION (self));
mm_gdbus_modem_location_call_inject_assistance_data (MM_GDBUS_MODEM_LOCATION (self),
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, data, data_size, sizeof (guint8)),
cancellable,
callback,
user_data);
}
/**
* mm_modem_location_inject_assistance_data_sync:
* @self: A #MMModemLocation.
* @data: (array length=data_size): Data to inject.
* @data_size: size of @data.
* @cancellable: (allow-none): A #GCancellable or %NULL.
* @error: Return location for error or %NULL.
*
* Synchronously injects assistance data to the GNSS module.
*
* The calling thread is blocked until a reply is received. See mm_modem_location_inject_assistance_data()
* for the asynchronous version of this method.
*
* Returns: %TRUE if the injection was successful, %FALSE if @error is set.
*/
gboolean
mm_modem_location_inject_assistance_data_sync (MMModemLocation *self,
const guint8 *data,
gsize data_size,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), FALSE);
return mm_gdbus_modem_location_call_inject_assistance_data_sync (MM_GDBUS_MODEM_LOCATION (self),
g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, data, data_size, sizeof (guint8)),
cancellable,
error);
}
/*****************************************************************************/
/**
* mm_modem_location_set_gps_refresh_rate_finish:
* @self: A #MMModemLocation.
@@ -876,6 +979,56 @@ mm_modem_location_dup_supl_server (MMModemLocation *self)
/*****************************************************************************/
/**
* mm_modem_location_get_assistance_data_servers:
* @self: A #MMModemLocation.
*
* Gets the list of assistance data servers.
*
* <warning>The returned value is only valid until the property changes so
* it is only safe to use this function on the thread where
* @self was constructed. Use mm_modem_location_dup_assistance_data_servers() if on another
* thread.</warning>
*
* Returns: (transfer none): a %NULL-terminated array of server addresses, or %NULL if none available. Do not free the returned value, it belongs to @self.
*/
const gchar **
mm_modem_location_get_assistance_data_servers (MMModemLocation *self)
{
const gchar **tmp;
g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), NULL);
tmp = (const gchar **) mm_gdbus_modem_location_get_assistance_data_servers (MM_GDBUS_MODEM_LOCATION (self));
return ((tmp && tmp[0]) ? tmp : NULL);
}
/**
* mm_modem_location_dup_assistance_data_servers:
* @self: A #MMModemLocation.
*
* Gets the list of assistance data servers.
*
* Returns: (transfer full): a %NULL-terminated array of server addresses, or %NULL if none available. The returned value should be freed with g_strfreev().
*/
gchar **
mm_modem_location_dup_assistance_data_servers (MMModemLocation *self)
{
gchar **tmp;
g_return_val_if_fail (MM_IS_MODEM_LOCATION (self), NULL);
tmp = mm_gdbus_modem_location_dup_assistance_data_servers (MM_GDBUS_MODEM_LOCATION (self));
if (tmp && tmp[0])
return tmp;
g_strfreev (tmp);
return NULL;
}
/*****************************************************************************/
/**
* mm_modem_location_get_gps_refresh_rate:
* @self: A #MMModemLocation.
+20
View File
@@ -76,9 +76,14 @@ MMModemLocationSource mm_modem_location_get_enabled (MMModemLocation *self)
gboolean mm_modem_location_signals_location (MMModemLocation *self);
MMModemLocationAssistanceDataType mm_modem_location_get_supported_assistance_data (MMModemLocation *self);
const gchar *mm_modem_location_get_supl_server (MMModemLocation *self);
gchar *mm_modem_location_dup_supl_server (MMModemLocation *self);
const gchar **mm_modem_location_get_assistance_data_servers (MMModemLocation *self);
gchar **mm_modem_location_dup_assistance_data_servers (MMModemLocation *self);
guint mm_modem_location_get_gps_refresh_rate (MMModemLocation *self);
void mm_modem_location_setup (MMModemLocation *self,
@@ -109,6 +114,21 @@ gboolean mm_modem_location_set_supl_server_sync (MMModemLocation *self,
GCancellable *cancellable,
GError **error);
void mm_modem_location_inject_assistance_data (MMModemLocation *self,
const guint8 *data,
gsize data_size,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_modem_location_inject_assistance_data_finish (MMModemLocation *self,
GAsyncResult *res,
GError **error);
gboolean mm_modem_location_inject_assistance_data_sync (MMModemLocation *self,
const guint8 *data,
gsize data_size,
GCancellable *cancellable,
GError **error);
void mm_modem_location_set_gps_refresh_rate (MMModemLocation *self,
guint rate,
GCancellable *cancellable,