8 Commits
0.0.4 ... 0.0.6

Author SHA1 Message Date
Arnaud Ferraris
ff60016e5d release version 0.0.6 2020-12-11 15:10:13 +01:00
Arnaud Ferraris
5715138a96 suspend: reset sleep inhibitor if already present upon resume 2020-12-11 15:09:43 +01:00
Arnaud Ferraris
fd6a292a8f manager: don't change modem state after reset
This makes sure the resume commands (disable URC cache and enable GPS)
are executed.
2020-12-11 15:09:38 +01:00
Arnaud Ferraris
5fa345ec92 mm-iface: don't reset USB ID unless quitting
As ModemManager releases the modem while going to sleep, we clear the
USB ID too, which causes a segfault when trying to recover the modem.
2020-12-11 14:34:34 +01:00
Arnaud Ferraris
a9725243ec meson.build: bump version 2020-12-11 13:37:40 +01:00
Arnaud Ferraris
75b0920e9d Revert "manager: split modem_suspend() into _pre() and _post() functions"
This reverts commit ff9b26b831.
2020-12-11 13:36:28 +01:00
Arnaud Ferraris
9713af7ca8 at: fix GPS disabling on suspend 2020-12-11 13:31:11 +01:00
Arnaud Ferraris
664f82d570 at: add default handling for unrecognized responses 2020-12-11 13:31:11 +01:00
6 changed files with 20 additions and 28 deletions

View File

@@ -8,7 +8,7 @@
project (
'eg25manager',
'c',
version : '0.0.1',
version : '0.0.6',
license : 'GPLv3+',
meson_version : '>= 0.50.0',
default_options :

View File

@@ -55,7 +55,9 @@ static gboolean send_at_command(struct EG25Manager *manager)
struct AtCommand *at_cmd = g_list_nth_data(manager->at_cmds, 0);
if (at_cmd) {
if (at_cmd->subcmd == NULL && at_cmd->value == NULL)
if (at_cmd->subcmd == NULL && at_cmd->value == NULL && at_cmd->expected == NULL)
sprintf(command, "AT+%s\r\n", at_cmd->cmd);
else if (at_cmd->subcmd == NULL && at_cmd->value == NULL)
sprintf(command, "AT+%s?\r\n", at_cmd->cmd);
else if (at_cmd->subcmd == NULL && at_cmd->value)
sprintf(command, "AT+%s=%s\r\n", at_cmd->cmd, at_cmd->value);
@@ -195,6 +197,9 @@ static gboolean modem_response(gint fd,
retry_at_command(manager);
else if (strstr(response, "OK"))
process_at_result(manager, response);
else
// Not a recognized response, try running next command, just in case
next_at_command(manager);
}
return TRUE;
@@ -259,7 +264,7 @@ void at_sequence_configure(struct EG25Manager *manager)
void at_sequence_suspend(struct EG25Manager *manager)
{
append_at_command(manager, "QGPS", NULL, "0", NULL);
append_at_command(manager, "QGPSEND", NULL, NULL, NULL);
append_at_command(manager, "QCFG", "urc/cache", "1", NULL);
send_at_command(manager);
}

View File

@@ -126,7 +126,6 @@ void modem_reset(struct EG25Manager *manager)
write(fd, manager->modem_usb_id, strlen(manager->modem_usb_id));
close(fd);
manager->modem_state = EG25_STATE_CONFIGURED;
return;
error:
@@ -135,20 +134,14 @@ error:
manager->modem_state = EG25_STATE_RESETTING;
}
void modem_suspend_pre(struct EG25Manager *manager)
void modem_suspend(struct EG25Manager *manager)
{
manager->modem_state = EG25_STATE_SUSPENDING;
gpio_sequence_suspend(manager);
}
void modem_suspend_post(struct EG25Manager *manager)
{
at_sequence_suspend(manager);
}
void modem_resume_pre(struct EG25Manager *manager)
{
manager->modem_state = EG25_STATE_RESUMING;
gpio_sequence_resume(manager);
}

View File

@@ -51,8 +51,7 @@ struct EG25Manager {
void modem_configure(struct EG25Manager *data);
void modem_reset(struct EG25Manager *data);
void modem_suspend_pre(struct EG25Manager *data);
void modem_suspend_post(struct EG25Manager *data);
void modem_suspend(struct EG25Manager *data);
void modem_resume_pre(struct EG25Manager *data);
void modem_resume_post(struct EG25Manager *data);
void modem_update_state(struct EG25Manager *data, MMModemState state);

View File

@@ -84,13 +84,8 @@ static void interface_removed_cb(struct EG25Manager *manager,
g_message("ModemManager interface `%s' removed on object `%s'", info->name, path);
if (g_strcmp0(info->name, MM_DBUS_INTERFACE_MODEM) == 0) {
if (g_strcmp0(info->name, MM_DBUS_INTERFACE_MODEM) == 0)
manager->mm_modem = NULL;
if (manager->modem_usb_id) {
g_free(manager->modem_usb_id);
manager->modem_usb_id = NULL;
}
}
}
@@ -132,14 +127,7 @@ static void object_removed_cb(struct EG25Manager *manager, GDBusObject *object)
path = g_dbus_object_get_object_path(object);
g_message("ModemManager object `%s' removed", path);
if (manager->modem_state == EG25_STATE_SUSPENDING)
modem_suspend_post(manager);
manager->mm_modem = NULL;
if (manager->modem_usb_id) {
g_free(manager->modem_usb_id);
manager->modem_usb_id = NULL;
}
}
@@ -199,6 +187,10 @@ void mm_iface_destroy(struct EG25Manager *manager)
g_clear_object(&manager->mm_manager);
manager->mm_manager = NULL;
}
if (manager->modem_usb_id) {
g_free(manager->modem_usb_id);
manager->modem_usb_id = NULL;
}
if (manager->mm_watch != 0) {
g_bus_unwatch_name(manager->mm_watch);
manager->mm_watch = 0;

View File

@@ -66,7 +66,8 @@ static void take_inhibitor(struct EG25Manager *manager)
{
GVariant *variant_arg;
g_assert(manager->suspend_inhibit_fd == -1);
if(manager->suspend_inhibit_fd != -1)
drop_inhibitor(manager);
variant_arg = g_variant_new ("(ssss)", "sleep", "eg25manager",
"eg25manager needs to prepare modem for sleep", "delay");
@@ -92,11 +93,13 @@ static void signal_cb(GDBusProxy *proxy,
if (is_about_to_suspend) {
g_message("system is about to suspend");
modem_suspend_pre(manager);
manager->modem_state = EG25_STATE_SUSPENDING;
modem_suspend(manager);
} else {
g_message("system is resuming");
take_inhibitor(manager);
modem_resume_pre(manager);
manager->modem_state = EG25_STATE_RESUMING;
manager->suspend_source = g_timeout_add_seconds(8, G_SOURCE_FUNC(check_modem_resume), manager);
}
}