diff options
author | Jason Simmons <jsimmons@chromium.org> | 2015-03-13 15:30:58 -0700 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2015-03-23 11:31:32 +0100 |
commit | 3ad64c8f5aed43697bf289fce277bde48f208051 (patch) | |
tree | 58cdbad518e592df883d8b2db681ad7a32aaf76b /src/mm-broadband-modem.c | |
parent | a92566ec0e01bc606fd3673276eb5f7ece3b8291 (diff) |
broadband-modem: default implementation of the network time interface
Add a default implementation that queries the real-time clock using the
AT+CCLK? command. Also set AT+CTZU=1 in case a modem requires it.
Diffstat (limited to 'src/mm-broadband-modem.c')
-rw-r--r-- | src/mm-broadband-modem.c | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index 17c128ce..feebbc6e 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -7511,6 +7511,96 @@ enable_location_gathering (MMIfaceModemLocation *self, } /*****************************************************************************/ +/* Load network time (Time interface) */ + +static gchar * +modem_time_load_network_time_finish (MMIfaceModemTime *self, + GAsyncResult *res, + GError **error) +{ + const gchar *response; + gchar *result = NULL; + + response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error); + if (response) + mm_parse_cclk_response (response, &result, NULL, error); + return result; +} + +static void +modem_time_load_network_time (MMIfaceModemTime *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + mm_base_modem_at_command (MM_BASE_MODEM (self), + "+CCLK?", + 3, + FALSE, + callback, + user_data); +} + +/*****************************************************************************/ +/* Load network timezone (Time interface) */ + +static MMNetworkTimezone * +modem_time_load_network_timezone_finish (MMIfaceModemTime *self, + GAsyncResult *res, + GError **error) +{ + const gchar *response; + MMNetworkTimezone *tz = NULL; + + response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, NULL); + if (response) + mm_parse_cclk_response (response, NULL, &tz, error); + return tz; +} + +static void +modem_time_load_network_timezone (MMIfaceModemTime *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + mm_base_modem_at_command (MM_BASE_MODEM (self), + "+CCLK?", + 3, + FALSE, + callback, + user_data); +} + +/*****************************************************************************/ +/* Check support (Time interface) */ + +static const MMBaseModemAtCommand time_check_sequence[] = { + { "+CTZU=1", 3, TRUE, mm_base_modem_response_processor_no_result_continue }, + { "+CCLK?", 3, TRUE, mm_base_modem_response_processor_string }, + { NULL } +}; + +static gboolean +modem_time_check_support_finish (MMIfaceModemTime *self, + GAsyncResult *res, + GError **error) +{ + return !!mm_base_modem_at_sequence_finish (MM_BASE_MODEM (self), res, NULL, error); +} + +static void +modem_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 const gchar *primary_init_sequence[] = { /* Ensure echo is off */ @@ -9824,6 +9914,12 @@ iface_modem_messaging_init (MMIfaceModemMessaging *iface) static void iface_modem_time_init (MMIfaceModemTime *iface) { + iface->check_support = modem_time_check_support; + iface->check_support_finish = modem_time_check_support_finish; + iface->load_network_time = modem_time_load_network_time; + iface->load_network_time_finish = modem_time_load_network_time_finish; + iface->load_network_timezone = modem_time_load_network_timezone; + iface->load_network_timezone_finish = modem_time_load_network_timezone_finish; } static void |