unifying: Use the actual bootloader VID/PIDs when in firmware mode

This commit is contained in:
Richard Hughes 2016-12-16 21:24:10 +00:00
parent 04042a10e8
commit 0075a98b51

View File

@ -386,6 +386,7 @@ gboolean
unifying_dongle_open (UnifyingDongle *dongle, GError **error) unifying_dongle_open (UnifyingDongle *dongle, GError **error)
{ {
UnifyingDonglePrivate *priv = GET_PRIVATE (dongle); UnifyingDonglePrivate *priv = GET_PRIVATE (dongle);
guint16 pid_for_guid = 0xffff;
guint i; guint i;
guint num_interfaces = 0x1; guint num_interfaces = 0x1;
g_autofree gchar *devid = NULL; g_autofree gchar *devid = NULL;
@ -403,18 +404,27 @@ unifying_dongle_open (UnifyingDongle *dongle, GError **error)
/* generate GUID -- in runtime mode we have to use the release */ /* generate GUID -- in runtime mode we have to use the release */
if (priv->kind == UNIFYING_DONGLE_KIND_RUNTIME) { if (priv->kind == UNIFYING_DONGLE_KIND_RUNTIME) {
guint16 release = g_usb_device_get_release (priv->usb_device); guint16 release = g_usb_device_get_release (priv->usb_device);
release &= 0xff00; switch (release &= 0xff00) {
devid = g_strdup_printf ("USB\\VID_%04X&PID_%04X&REV_%04X", case 0x1200:
g_usb_device_get_vid (priv->usb_device), /* Nordic */
g_usb_device_get_pid (priv->usb_device), pid_for_guid = 0xaaaa;
release); break;
case 0x2400:
/* Texas */
pid_for_guid = 0xaaac;
break;
default:
g_warning ("bootloader release %04x invalid", release);
break;
}
} else { } else {
devid = g_strdup_printf ("USB\\VID_%04X&PID_%04X", pid_for_guid = g_usb_device_get_pid (priv->usb_device);
g_usb_device_get_vid (priv->usb_device),
g_usb_device_get_pid (priv->usb_device));
} }
g_debug ("Using %s for GUID", devid); devid = g_strdup_printf ("USB\\VID_%04X&PID_%04X",
g_usb_device_get_vid (priv->usb_device),
pid_for_guid);
priv->guid = as_utils_guid_from_string (devid); priv->guid = as_utils_guid_from_string (devid);
g_debug ("Using %s for GUID %s", devid, priv->guid);
/* open device */ /* open device */
g_debug ("opening unifying device"); g_debug ("opening unifying device");