Hey Aleksander,

They have similar data but not in the same order for example +CTZE URC is
<tz>,<dst>,<time>, so like this "+32",0,"2018/03/23,06:51:13" but for CTZU
it's like this <tz>,<time>,<dst>  "+32","2018/03/23,06:51:13",0 and for
Cinterion the dst is optional

Thanks for the advice to get the signal, you are right I should use
libmm-glib shipped with ModemManager. I changed to this

GList *l = NULL;
int ret = 0;
GList *modem_list = g_dbus_object_manager_get_objects(G_DBUS_OBJECT_MANAGER(
manager));

for (l = modem_list; l; l = g_list_next(l))
{
MMObject *obj;
MMModemTime *modem_time;
obj = MM_OBJECT(l->data);
modem_time = MM_MODEM_TIME(mm_object_peek_modem_time(obj));
if (ret = g_signal_connect(modem_time, NETWORK_TIME_CHANGED_DBUS_SIGNAL,
G_CALLBACK(update_local_modem_time), NULL) <= 0)
{
DBG_PRINT("Failed to connect signal %s to modem %d\n", "network-time-changed
", ret);
}
}

Best regards,

Le mer. 3 mai 2023 à 15:12, Aleksander Morgado <aleksande...@chromium.org>
a écrit :

> Hey Thomas,
>
> > I do get the +CTZU notification, but it worked differently for quectel
> because it doesn't receive the new time we need to check for +CTZE that's
> the URC that we get when we receive notification that the time has been
> changed.
>
> What is the format of the +CTZE URC? is it similar to +CTZU? how are
> they different?
>
> > For my use case, I would like to update my local time automatically on a
> linux environment using modemmanager with quectel modules.
> > So right now I manage to change cinterion's function to process +CTZE
> events and I receive the signal like this
> > GDBusProxy *proxy = g_dbus_proxy_new_sync(connection,
> > G_DBUS_PROXY_FLAGS_NONE,
> > NULL,
> > "org.freedesktop.ModemManager1",
> > modemPath,
> > "org.freedesktop.ModemManager1.Modem.Time",
> > NULL,
> > &error);
> > if (error != NULL) {
> > g_printerr("Error creating ModemManager1.Modem proxy: %s\n",
> error->message);
> > g_error_free(error);
> > return 1;
> > }
> >
> > g_signal_connect(proxy, "g-properties-changed",
> G_CALLBACK(update_local_time), NULL);
> > }
> > But I'm not sure it's the best way to process the signal
>
> Wondering, why not use the libmm-glib  we ship with ModemManager
> instead of manually creating the proxies and parsing the list of
> updated properties?
> E.g. you could:
>  * create a new MMManager with mm_manager_new()
>  * list the MMObjects it handles with g_dbus_object_manager_get_objects()
>  * get a MMModemTime interface object with mm_object_get_modem_time()
>  * listen to the "network-time-changed" signal
>
> --
> Aleksander
>

Reply via email to