quectel,shared: implement custom time support check

We require CTZU=3 during the time support check, instead of CTZU=1, so
that the Quectel modem reports localtime instead of UTC time in +CCLK.

Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/233
This commit is contained in:
Aleksander Morgado
2020-06-30 13:12:25 +02:00
parent ffca45d9cc
commit 23f8b580c3
4 changed files with 68 additions and 6 deletions
@@ -10,18 +10,21 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2018 Aleksander Morgado <aleksander@aleksander.es>
* Copyright (C) 2018-2020 Aleksander Morgado <aleksander@aleksander.es>
*/
#include <config.h>
#include "mm-broadband-modem-qmi-quectel.h"
#include "mm-shared-quectel.h"
#include "mm-iface-modem-firmware.h"
#include "mm-iface-modem-location.h"
#include "mm-iface-modem-time.h"
#include "mm-shared-quectel.h"
static void iface_modem_init (MMIfaceModem *iface);
static void iface_modem_firmware_init (MMIfaceModemFirmware *iface);
static void iface_modem_location_init (MMIfaceModemLocation *iface);
static void iface_modem_time_init (MMIfaceModemTime *iface);
static void shared_quectel_init (MMSharedQuectel *iface);
static MMIfaceModemLocation *iface_modem_location_parent;
@@ -30,6 +33,7 @@ G_DEFINE_TYPE_EXTENDED (MMBroadbandModemQmiQuectel, mm_broadband_modem_qmi_quect
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_FIRMWARE, iface_modem_firmware_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_TIME, iface_modem_time_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_QUECTEL, shared_quectel_init))
/*****************************************************************************/
@@ -88,6 +92,13 @@ peek_parent_location_interface (MMSharedQuectel *self)
return iface_modem_location_parent;
}
static void
iface_modem_time_init (MMIfaceModemTime *iface)
{
iface->check_support = mm_shared_quectel_time_check_support;
iface->check_support_finish = mm_shared_quectel_time_check_support_finish;
}
static void
shared_quectel_init (MMSharedQuectel *iface)
{
+12 -2
View File
@@ -10,19 +10,21 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2018 Aleksander Morgado <aleksander@aleksander.es>
* Copyright (C) 2018-2020 Aleksander Morgado <aleksander@aleksander.es>
*/
#include <config.h>
#include "mm-broadband-modem-quectel.h"
#include "mm-shared-quectel.h"
#include "mm-iface-modem-firmware.h"
#include "mm-iface-modem-location.h"
#include "mm-iface-modem-time.h"
#include "mm-shared-quectel.h"
static void iface_modem_init (MMIfaceModem *iface);
static void iface_modem_firmware_init (MMIfaceModemFirmware *iface);
static void iface_modem_location_init (MMIfaceModemLocation *iface);
static void iface_modem_time_init (MMIfaceModemTime *iface);
static void shared_quectel_init (MMSharedQuectel *iface);
static MMIfaceModemLocation *iface_modem_location_parent;
@@ -31,6 +33,7 @@ G_DEFINE_TYPE_EXTENDED (MMBroadbandModemQuectel, mm_broadband_modem_quectel, MM_
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_FIRMWARE, iface_modem_firmware_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_TIME, iface_modem_time_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_QUECTEL, shared_quectel_init))
/*****************************************************************************/
@@ -89,6 +92,13 @@ peek_parent_location_interface (MMSharedQuectel *self)
return iface_modem_location_parent;
}
static void
iface_modem_time_init (MMIfaceModemTime *iface)
{
iface->check_support = mm_shared_quectel_time_check_support;
iface->check_support_finish = mm_shared_quectel_time_check_support_finish;
}
static void
shared_quectel_init (MMSharedQuectel *iface)
{
+34 -1
View File
@@ -10,7 +10,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2018 Aleksander Morgado <aleksander@aleksander.es>
* Copyright (C) 2018-2020 Aleksander Morgado <aleksander@aleksander.es>
*/
#include <config.h>
@@ -574,6 +574,39 @@ mm_shared_quectel_disable_location_gathering (MMIfaceModemLocation *self,
g_object_unref (task);
}
/*****************************************************************************/
/* Custom time support check because Quectel modems require +CTZU=3 in order to
* have the CCLK? time reported in localtime, instead of UTC time. */
static const MMBaseModemAtCommand time_check_sequence[] = {
{ "+CTZU=3", 3, TRUE, mm_base_modem_response_processor_no_result_continue },
{ "+CCLK?", 3, TRUE, mm_base_modem_response_processor_string },
{ NULL }
};
gboolean
mm_shared_quectel_time_check_support_finish (MMIfaceModemTime *self,
GAsyncResult *res,
GError **error)
{
return !!mm_base_modem_at_sequence_finish (MM_BASE_MODEM (self), res, NULL, error);
}
void
mm_shared_quectel_time_check_support (MMIfaceModemTime *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
mm_base_modem_at_sequence (MM_BASE_MODEM (self),
time_check_sequence,
NULL, /* response_processor_context */
NULL, /* response_processor_context_free */
callback,
user_data);
}
/*****************************************************************************/
static void
shared_quectel_init (gpointer g_iface)
{
+9 -1
View File
@@ -10,7 +10,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2018 Aleksander Morgado <aleksander@aleksander.es>
* Copyright (C) 2018-2020 Aleksander Morgado <aleksander@aleksander.es>
*/
#ifndef MM_SHARED_QUECTEL_H
@@ -26,6 +26,7 @@
#include "mm-iface-modem.h"
#include "mm-iface-modem-firmware.h"
#include "mm-iface-modem-location.h"
#include "mm-iface-modem-time.h"
#define MM_TYPE_SHARED_QUECTEL (mm_shared_quectel_get_type ())
#define MM_SHARED_QUECTEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SHARED_QUECTEL, MMSharedQuectel))
@@ -78,4 +79,11 @@ gboolean mm_shared_quectel_disable_location_gathering_finish (MMIfa
GAsyncResult *res,
GError **error);
void mm_shared_quectel_time_check_support (MMIfaceModemTime *self,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_shared_quectel_time_check_support_finish (MMIfaceModemTime *self,
GAsyncResult *res,
GError **error);
#endif /* MM_SHARED_QUECTEL_H */