mirror of
https://gitlab.com/mobian1/eg25-manager.git
synced 2025-08-29 15:22:20 +02:00
udev: don't reset immediately
Executing a reset each time the modem is unbound is a bit too extreme: the modem sometimes recovers by itself and only needs a "soft" reset sequence (unbind/bind). This commit introduces a short timer (2s) so we the modem can settle in. If reset fails after this time, the modem is probably completely broken, or already rebooting, so we can safely issue a reset AT command.
This commit is contained in:
@@ -145,13 +145,13 @@ static gboolean modem_reset_done(struct EG25Manager* manager)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void modem_reset(struct EG25Manager *manager)
|
||||
gboolean modem_reset(struct EG25Manager *manager)
|
||||
{
|
||||
int fd, ret, len;
|
||||
|
||||
if (manager->reset_timer) {
|
||||
g_message("modem_reset: timer already setup, skipping...");
|
||||
return;
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -161,7 +161,7 @@ void modem_reset(struct EG25Manager *manager)
|
||||
*/
|
||||
if (manager->modem_iface != MODEM_IFACE_MODEMMANAGER) {
|
||||
g_message("modem_reset: not using ModemManager, bail out!");
|
||||
return;
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
if (manager->modem_recovery_timer) {
|
||||
@@ -212,7 +212,7 @@ void modem_reset(struct EG25Manager *manager)
|
||||
*/
|
||||
manager->reset_timer = g_timeout_add_seconds(3, G_SOURCE_FUNC(modem_reset_done), manager);
|
||||
|
||||
return;
|
||||
return G_SOURCE_REMOVE;
|
||||
|
||||
error:
|
||||
// Release blocking sleep inhibitor
|
||||
@@ -229,6 +229,8 @@ error:
|
||||
|
||||
// Setup timer for making sure we don't queue other reset commands
|
||||
manager->reset_timer = g_timeout_add_seconds(30, G_SOURCE_FUNC(modem_reset_done), manager);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
void modem_suspend_pre(struct EG25Manager *manager)
|
||||
|
@@ -119,7 +119,7 @@ struct EG25Manager {
|
||||
};
|
||||
|
||||
void modem_configure(struct EG25Manager *data);
|
||||
void modem_reset(struct EG25Manager *data);
|
||||
gboolean modem_reset(struct EG25Manager *data);
|
||||
void modem_suspend_pre(struct EG25Manager *data);
|
||||
void modem_suspend_post(struct EG25Manager *data);
|
||||
void modem_resume_pre(struct EG25Manager *data);
|
||||
|
@@ -16,12 +16,12 @@ static void udev_event_cb(GUdevClient *client, gchar *action, GUdevDevice *devic
|
||||
manager->modem_state == EG25_STATE_RESETTING ||
|
||||
!manager->modem_usb_id) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (strncmp(g_udev_device_get_name(device), manager->modem_usb_id, strlen(manager->modem_usb_id)) == 0 &&
|
||||
if (strcmp(g_udev_device_get_name(device), manager->modem_usb_id) == 0 &&
|
||||
manager->reset_timer == 0) {
|
||||
g_message("Lost modem, resetting...");
|
||||
modem_reset(manager);
|
||||
g_timeout_add_seconds(2, G_SOURCE_FUNC(modem_reset), manager);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user