diff --git a/plugins/unifying/fu-plugin-unifying.c b/plugins/unifying/fu-plugin-unifying.c index 7757e2b0c..a6c4e9c7e 100644 --- a/plugins/unifying/fu-plugin-unifying.c +++ b/plugins/unifying/fu-plugin-unifying.c @@ -155,7 +155,7 @@ fu_plugin_update_online (FuPlugin *plugin, g_timeout_add (50, fu_plugin_unifying_detach_cb, device); if (!lu_context_wait_for_replug (data->ctx, device, - 2000, + FU_DEVICE_TIMEOUT_REPLUG, error)) return FALSE; g_object_unref (device); @@ -169,8 +169,8 @@ fu_plugin_update_online (FuPlugin *plugin, /* write the firmware */ fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_WRITE); if (!lu_device_write_firmware (device, blob_fw, - lu_write_progress_cb, plugin, - error)) + lu_write_progress_cb, plugin, + error)) return FALSE; fu_plugin_set_status (plugin, FWUPD_STATUS_DEVICE_RESTART); if (!lu_device_attach (device, error)) @@ -178,6 +178,24 @@ fu_plugin_update_online (FuPlugin *plugin, if (!lu_device_close (device, error)) return FALSE; + /* wait for it to appear back in runtime mode */ + if (!lu_context_wait_for_replug (data->ctx, + device, + FU_DEVICE_TIMEOUT_REPLUG, + error)) + return FALSE; + g_object_unref (device); + + /* get the new device version */ + device = fu_plugin_unifying_get_device (plugin, dev, error); + if (device == NULL) + return FALSE; + if (!lu_device_open (device, error)) + return FALSE; + fu_device_set_version (dev, lu_device_get_version_fw (device)); + if (!lu_device_close (device, error)) + return FALSE; + /* success */ data->ignore_replug = FALSE; return TRUE; diff --git a/plugins/unifying/lu-device.h b/plugins/unifying/lu-device.h index 4782be6c8..57a107541 100644 --- a/plugins/unifying/lu-device.h +++ b/plugins/unifying/lu-device.h @@ -64,6 +64,9 @@ struct _LuDeviceClass #define LU_DEVICE_EP3 0x83 #define LU_DEVICE_TIMEOUT_MS 2500 +/* some USB hubs take a looong time to re-connect the device */ +#define FU_DEVICE_TIMEOUT_REPLUG 10000 /* ms */ + typedef enum { LU_DEVICE_KIND_UNKNOWN, LU_DEVICE_KIND_RUNTIME, diff --git a/plugins/unifying/lu-tool.c b/plugins/unifying/lu-tool.c index 62dbc0b67..a7bb202d6 100644 --- a/plugins/unifying/lu-tool.c +++ b/plugins/unifying/lu-tool.c @@ -407,7 +407,7 @@ lu_tool_write (FuLuToolPrivate *priv, gchar **values, GError **error) if (lu_device_has_flag (device, LU_DEVICE_FLAG_DETACH_WILL_REPLUG)) { if (!lu_context_wait_for_replug (priv->ctx, device, - 5000, + FU_DEVICE_TIMEOUT_REPLUG, error)) return FALSE; g_usleep (G_USEC_PER_SEC);