huawei: enable GPS_UNMANAGED for Huawei modems
Signed-off-by: David McCullough <david.mccullough@accelecon.com>
This commit is contained in:

committed by
Aleksander Morgado

parent
054c77224d
commit
07fd7faea5
@@ -3211,7 +3211,9 @@ parent_load_capabilities_ready (MMIfaceModemLocation *self,
|
|||||||
|
|
||||||
/* not sure how to check if GPS is supported, just allow it */
|
/* not sure how to check if GPS is supported, just allow it */
|
||||||
if (mm_base_modem_peek_port_gps (MM_BASE_MODEM (self)))
|
if (mm_base_modem_peek_port_gps (MM_BASE_MODEM (self)))
|
||||||
sources |= (MM_MODEM_LOCATION_SOURCE_GPS_NMEA | MM_MODEM_LOCATION_SOURCE_GPS_RAW);
|
sources |= (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
||||||
|
MM_MODEM_LOCATION_SOURCE_GPS_RAW |
|
||||||
|
MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED);
|
||||||
|
|
||||||
/* So we're done, complete */
|
/* So we're done, complete */
|
||||||
g_simple_async_result_set_op_res_gpointer (simple,
|
g_simple_async_result_set_op_res_gpointer (simple,
|
||||||
@@ -3240,7 +3242,26 @@ location_load_capabilities (MMIfaceModemLocation *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Disable location gathering (Location interface) */
|
/* Enable/Disable location gathering (Location interface) */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MMBroadbandModemHuawei *self;
|
||||||
|
GSimpleAsyncResult *result;
|
||||||
|
MMModemLocationSource source;
|
||||||
|
int idx;
|
||||||
|
} LocationGatheringContext;
|
||||||
|
|
||||||
|
static void
|
||||||
|
location_gathering_context_complete_and_free (LocationGatheringContext *ctx)
|
||||||
|
{
|
||||||
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
|
g_object_unref (ctx->result);
|
||||||
|
g_object_unref (ctx->self);
|
||||||
|
g_slice_free (LocationGatheringContext, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************/
|
||||||
|
/* Disable location gathering */
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
disable_location_gathering_finish (MMIfaceModemLocation *self,
|
disable_location_gathering_finish (MMIfaceModemLocation *self,
|
||||||
@@ -3253,23 +3274,26 @@ disable_location_gathering_finish (MMIfaceModemLocation *self,
|
|||||||
static void
|
static void
|
||||||
gps_disabled_ready (MMBaseModem *self,
|
gps_disabled_ready (MMBaseModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GSimpleAsyncResult *simple)
|
LocationGatheringContext *ctx)
|
||||||
{
|
{
|
||||||
MMPortSerialGps *gps_port;
|
MMPortSerialGps *gps_port;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!mm_base_modem_at_command_full_finish (self, res, &error))
|
if (!mm_base_modem_at_command_full_finish (self, res, &error))
|
||||||
g_simple_async_result_take_error (simple, error);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
else
|
else
|
||||||
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||||
|
|
||||||
|
/* Only use the GPS port in NMEA/RAW setups */
|
||||||
|
if (ctx->source & (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
||||||
|
MM_MODEM_LOCATION_SOURCE_GPS_RAW)) {
|
||||||
/* Even if we get an error here, we try to close the GPS port */
|
/* Even if we get an error here, we try to close the GPS port */
|
||||||
gps_port = mm_base_modem_peek_port_gps (self);
|
gps_port = mm_base_modem_peek_port_gps (self);
|
||||||
if (gps_port)
|
if (gps_port)
|
||||||
mm_port_serial_close (MM_PORT_SERIAL (gps_port));
|
mm_port_serial_close (MM_PORT_SERIAL (gps_port));
|
||||||
|
}
|
||||||
|
|
||||||
g_simple_async_result_complete (simple);
|
location_gathering_context_complete_and_free (ctx);
|
||||||
g_object_unref (simple);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -3279,21 +3303,26 @@ disable_location_gathering (MMIfaceModemLocation *_self,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
MMBroadbandModemHuawei *self = MM_BROADBAND_MODEM_HUAWEI (_self);
|
MMBroadbandModemHuawei *self = MM_BROADBAND_MODEM_HUAWEI (_self);
|
||||||
GSimpleAsyncResult *result;
|
|
||||||
gboolean stop_gps = FALSE;
|
gboolean stop_gps = FALSE;
|
||||||
|
LocationGatheringContext *ctx;
|
||||||
|
|
||||||
result = g_simple_async_result_new (G_OBJECT (_self),
|
ctx = g_slice_new (LocationGatheringContext);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
user_data,
|
user_data,
|
||||||
disable_location_gathering);
|
disable_location_gathering);
|
||||||
|
ctx->source = source;
|
||||||
|
|
||||||
/* Only stop GPS engine if no GPS-related sources enabled */
|
/* Only stop GPS engine if no GPS-related sources enabled */
|
||||||
if (source & (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
if (source & (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
||||||
MM_MODEM_LOCATION_SOURCE_GPS_RAW)) {
|
MM_MODEM_LOCATION_SOURCE_GPS_RAW |
|
||||||
|
MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED)) {
|
||||||
self->priv->enabled_sources &= ~source;
|
self->priv->enabled_sources &= ~source;
|
||||||
|
|
||||||
if (!(self->priv->enabled_sources & (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
if (!(self->priv->enabled_sources & (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
||||||
MM_MODEM_LOCATION_SOURCE_GPS_RAW)))
|
MM_MODEM_LOCATION_SOURCE_GPS_RAW |
|
||||||
|
MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED)))
|
||||||
stop_gps = TRUE;
|
stop_gps = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3306,35 +3335,18 @@ disable_location_gathering (MMIfaceModemLocation *_self,
|
|||||||
FALSE, /* raw */
|
FALSE, /* raw */
|
||||||
NULL, /* cancellable */
|
NULL, /* cancellable */
|
||||||
(GAsyncReadyCallback)gps_disabled_ready,
|
(GAsyncReadyCallback)gps_disabled_ready,
|
||||||
result);
|
ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For any other location (e.g. 3GPP), or if still some GPS needed, just return */
|
/* For any other location (e.g. 3GPP), or if still some GPS needed, just return */
|
||||||
g_simple_async_result_set_op_res_gboolean (result, TRUE);
|
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||||
g_simple_async_result_complete_in_idle (result);
|
location_gathering_context_complete_and_free (ctx);
|
||||||
g_object_unref (result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Enable location gathering (Location interface) */
|
/* Enable location gathering (Location interface) */
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
MMBroadbandModemHuawei *self;
|
|
||||||
GSimpleAsyncResult *result;
|
|
||||||
MMModemLocationSource source;
|
|
||||||
int idx;
|
|
||||||
} EnableLocationGatheringContext;
|
|
||||||
|
|
||||||
static void
|
|
||||||
enable_location_gathering_context_complete_and_free (EnableLocationGatheringContext *ctx)
|
|
||||||
{
|
|
||||||
g_simple_async_result_complete (ctx->result);
|
|
||||||
g_object_unref (ctx->result);
|
|
||||||
g_object_unref (ctx->self);
|
|
||||||
g_free (ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
enable_location_gathering_finish (MMIfaceModemLocation *self,
|
enable_location_gathering_finish (MMIfaceModemLocation *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
@@ -3354,7 +3366,7 @@ static char *gps_startup[] = {
|
|||||||
static void
|
static void
|
||||||
gps_enabled_ready (MMBaseModem *self,
|
gps_enabled_ready (MMBaseModem *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
EnableLocationGatheringContext *ctx)
|
LocationGatheringContext *ctx)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
MMPortSerialGps *gps_port;
|
MMPortSerialGps *gps_port;
|
||||||
@@ -3362,11 +3374,11 @@ gps_enabled_ready (MMBaseModem *self,
|
|||||||
if (!mm_base_modem_at_command_full_finish (self, res, &error)) {
|
if (!mm_base_modem_at_command_full_finish (self, res, &error)) {
|
||||||
ctx->idx = 0;
|
ctx->idx = 0;
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
enable_location_gathering_context_complete_and_free (ctx);
|
location_gathering_context_complete_and_free (ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ctx->idx++; */
|
/* ctx->idx++; make sure ctx->idx is a valid command */
|
||||||
if (gps_startup[ctx->idx++] && gps_startup[ctx->idx]) {
|
if (gps_startup[ctx->idx++] && gps_startup[ctx->idx]) {
|
||||||
mm_base_modem_at_command_full (MM_BASE_MODEM (self),
|
mm_base_modem_at_command_full (MM_BASE_MODEM (self),
|
||||||
mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
|
mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
|
||||||
@@ -3380,6 +3392,9 @@ gps_enabled_ready (MMBaseModem *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Only use the GPS port in NMEA/RAW setups */
|
||||||
|
if (ctx->source & (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
||||||
|
MM_MODEM_LOCATION_SOURCE_GPS_RAW)) {
|
||||||
gps_port = mm_base_modem_peek_port_gps (self);
|
gps_port = mm_base_modem_peek_port_gps (self);
|
||||||
if (!gps_port ||
|
if (!gps_port ||
|
||||||
!mm_port_serial_open (MM_PORT_SERIAL (gps_port), &error)) {
|
!mm_port_serial_open (MM_PORT_SERIAL (gps_port), &error)) {
|
||||||
@@ -3392,21 +3407,23 @@ gps_enabled_ready (MMBaseModem *self,
|
|||||||
"Couldn't open raw GPS serial port");
|
"Couldn't open raw GPS serial port");
|
||||||
} else
|
} else
|
||||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||||
|
} else
|
||||||
|
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||||
|
|
||||||
enable_location_gathering_context_complete_and_free (ctx);
|
location_gathering_context_complete_and_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parent_enable_location_gathering_ready (MMIfaceModemLocation *self,
|
parent_enable_location_gathering_ready (MMIfaceModemLocation *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
EnableLocationGatheringContext *ctx)
|
LocationGatheringContext *ctx)
|
||||||
{
|
{
|
||||||
gboolean start_gps = FALSE;
|
gboolean start_gps = FALSE;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!iface_modem_location_parent->enable_location_gathering_finish (self, res, &error)) {
|
if (!iface_modem_location_parent->enable_location_gathering_finish (self, res, &error)) {
|
||||||
g_simple_async_result_take_error (ctx->result, error);
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
enable_location_gathering_context_complete_and_free (ctx);
|
location_gathering_context_complete_and_free (ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3414,10 +3431,12 @@ parent_enable_location_gathering_ready (MMIfaceModemLocation *self,
|
|||||||
|
|
||||||
/* NMEA and RAW are both enabled in the same way */
|
/* NMEA and RAW are both enabled in the same way */
|
||||||
if (ctx->source & (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
if (ctx->source & (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
||||||
MM_MODEM_LOCATION_SOURCE_GPS_RAW)) {
|
MM_MODEM_LOCATION_SOURCE_GPS_RAW |
|
||||||
|
MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED)) {
|
||||||
/* Only start GPS engine if not done already */
|
/* Only start GPS engine if not done already */
|
||||||
if (!(ctx->self->priv->enabled_sources & (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
if (!(ctx->self->priv->enabled_sources & (MM_MODEM_LOCATION_SOURCE_GPS_NMEA |
|
||||||
MM_MODEM_LOCATION_SOURCE_GPS_RAW)))
|
MM_MODEM_LOCATION_SOURCE_GPS_RAW |
|
||||||
|
MM_MODEM_LOCATION_SOURCE_GPS_UNMANAGED)))
|
||||||
start_gps = TRUE;
|
start_gps = TRUE;
|
||||||
ctx->self->priv->enabled_sources |= ctx->source;
|
ctx->self->priv->enabled_sources |= ctx->source;
|
||||||
}
|
}
|
||||||
@@ -3437,7 +3456,7 @@ parent_enable_location_gathering_ready (MMIfaceModemLocation *self,
|
|||||||
|
|
||||||
/* For any other location (e.g. 3GPP), or if GPS already running just return */
|
/* For any other location (e.g. 3GPP), or if GPS already running just return */
|
||||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||||
enable_location_gathering_context_complete_and_free (ctx);
|
location_gathering_context_complete_and_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -3446,9 +3465,9 @@ enable_location_gathering (MMIfaceModemLocation *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
EnableLocationGatheringContext *ctx;
|
LocationGatheringContext *ctx;
|
||||||
|
|
||||||
ctx = g_new (EnableLocationGatheringContext, 1);
|
ctx = g_slice_new (LocationGatheringContext);
|
||||||
ctx->self = g_object_ref (self);
|
ctx->self = g_object_ref (self);
|
||||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
callback,
|
callback,
|
||||||
|
Reference in New Issue
Block a user