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:
Arnaud Ferraris
2021-10-06 22:35:36 +02:00
parent 25dd46bb30
commit af4d5ca1c1
3 changed files with 10 additions and 8 deletions

View File

@@ -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);
}
}