From 79974bc9ee494d5890f78ba74ecb63e6d51e228b Mon Sep 17 00:00:00 2001 From: Arnaud Ferraris Date: Thu, 14 Jan 2021 00:06:55 +0100 Subject: [PATCH] manager: don't manage the GNSS by default --- src/at.c | 9 ++++++--- src/manager.c | 13 +++++++++++++ src/manager.h | 1 + 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/at.c b/src/at.c index c417ffa..39a857a 100644 --- a/src/at.c +++ b/src/at.c @@ -268,7 +268,8 @@ void at_sequence_configure(struct EG25Manager *manager) append_at_command(manager, "QCFG", "apready", NULL, "1,0,500"); } append_at_command(manager, "QURCCFG", "urcport", NULL, "\"usbat\""); - append_at_command(manager, "QGPS", NULL, NULL, "1"); + if (manager->manage_gnss) + append_at_command(manager, "QGPS", NULL, NULL, "1"); append_at_command(manager, "QSCLK", NULL, "1", NULL); // Make sure URC cache is disabled append_at_command(manager, "QCFG", "urc/cache", "0", NULL); @@ -277,7 +278,8 @@ void at_sequence_configure(struct EG25Manager *manager) void at_sequence_suspend(struct EG25Manager *manager) { - append_at_command(manager, "QGPSEND", NULL, NULL, NULL); + if (manager->manage_gnss) + append_at_command(manager, "QGPSEND", NULL, NULL, NULL); append_at_command(manager, "QCFG", "urc/cache", "1", NULL); send_at_command(manager); } @@ -285,7 +287,8 @@ void at_sequence_suspend(struct EG25Manager *manager) void at_sequence_resume(struct EG25Manager *manager) { append_at_command(manager, "QCFG", "urc/cache", "0", NULL); - append_at_command(manager, "QGPS", NULL, "1", NULL); + if (manager->manage_gnss) + append_at_command(manager, "QGPS", NULL, "1", NULL); send_at_command(manager); } diff --git a/src/manager.c b/src/manager.c index 423cbfa..6445e0f 100644 --- a/src/manager.c +++ b/src/manager.c @@ -193,14 +193,27 @@ void modem_resume_post(struct EG25Manager *manager) int main(int argc, char *argv[]) { + g_autoptr(GOptionContext) opt_context = NULL; + g_autoptr(GError) err = NULL; struct EG25Manager manager; char compatible[32]; int fd, ret; + const GOptionEntry options[] = { + { "gnss", 'g', 0, G_OPTION_ARG_NONE, &manager.manage_gnss, "Manage the GNSS feature.", NULL }, + { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } + }; memset(&manager, 0, sizeof(manager)); manager.at_fd = -1; manager.suspend_inhibit_fd = -1; + opt_context = g_option_context_new ("- Power management for the Quectel EG25 modem"); + g_option_context_add_main_entries (opt_context, options, NULL); + if (!g_option_context_parse (opt_context, &argc, &argv, &err)) { + g_warning ("%s", err->message); + return 1; + } + manager.loop = g_main_loop_new(NULL, FALSE); fd = open("/proc/device-tree/compatible", O_RDONLY); diff --git a/src/manager.h b/src/manager.h index 605d73e..f6351be 100644 --- a/src/manager.h +++ b/src/manager.h @@ -28,6 +28,7 @@ enum EG25State { struct EG25Manager { GMainLoop *loop; guint reset_timer; + gboolean manage_gnss; int at_fd; guint at_source;