@@ -53,6 +53,7 @@ import {
5353 convertBufferToIntArray ,
5454 DevicePropertyIds ,
5555 EnumerationModes ,
56+ findDeviceConfigInFirmwareJson ,
5657 getCurrentUhkDeviceProduct ,
5758 getCurrentUhkDongleHID ,
5859 getCurrenUhk80LeftHID ,
@@ -377,6 +378,11 @@ export class DeviceService {
377378 response . userConfigSaved = false ;
378379 response . firmwareDowngraded = false ;
379380 const data : UpdateFirmwareData = JSON . parse ( args [ 0 ] ) ;
381+
382+ if ( this . options [ 'ignore-firmware-checksums' ] ) {
383+ data . forceUpgrade = true ;
384+ }
385+
380386 let firmwarePathData : TmpFirmware ;
381387
382388 try {
@@ -415,10 +421,15 @@ export class DeviceService {
415421 dongleUhkDevice = new UhkHidDevice ( this . logService , this . options , this . rootDir , dongleHid ) ;
416422 let dongleOperations = new UhkOperations ( this . logService , dongleUhkDevice ) ;
417423 let versionInfo = await dongleOperations . getDeviceVersionInfo ( ) ;
418- this . logService . misc ( '[DeviceService] Dongle firmware version:' ,
419- versionInfo . firmwareVersion ) ;
424+ this . logService . misc ( '[DeviceService] Current Dongle firmware checksum:' ,
425+ versionInfo . firmwareChecksum ) ;
426+
427+ const deviceConfig = findDeviceConfigInFirmwareJson ( UHK_DONGLE , packageJson ) ;
420428
421- if ( data . forceUpgrade || versionInfo . firmwareVersion !== packageJson . firmwareVersion ) {
429+ this . logService . misc ( '[DeviceService] New Dongle firmware checksum:' ,
430+ deviceConfig . md5 ) ;
431+
432+ if ( data . forceUpgrade || versionInfo . firmwareChecksum !== deviceConfig . md5 ) {
422433 event . sender . send ( IpcEvents . device . moduleFirmwareUpgrading , UHK_DONGLE . name ) ;
423434 await dongleOperations . updateDeviceFirmware ( dongleFirmwarePath , UHK_DONGLE ) ;
424435 this . logService . misc ( '[DeviceService] Waiting for keyboard' ) ;
@@ -451,9 +462,14 @@ export class DeviceService {
451462 JSON . stringify ( uhkDeviceProduct , usbDeviceJsonFormatter ) ) ;
452463 const deviceFirmwarePath = getDeviceFirmwarePath ( uhkDeviceProduct , packageJson ) ;
453464
454- this . logService . misc ( '[DeviceService] Device right firmware version:' ,
455- hardwareModules . rightModuleInfo . firmwareVersion ) ;
456- if ( data . forceUpgrade || hardwareModules . rightModuleInfo . firmwareVersion !== packageJson . firmwareVersion ) {
465+ this . logService . misc ( '[DeviceService] Current Device right firmware checksum:' ,
466+ hardwareModules . rightModuleInfo . firmwareChecksum ) ;
467+
468+ const deviceConfig = findDeviceConfigInFirmwareJson ( uhkDeviceProduct , packageJson ) ;
469+ this . logService . misc ( '[DeviceService] New Device right firmware checksum:' ,
470+ deviceConfig . md5 ) ;
471+
472+ if ( data . forceUpgrade || hardwareModules . rightModuleInfo . firmwareChecksum !== deviceConfig . md5 ) {
457473 event . sender . send ( IpcEvents . device . moduleFirmwareUpgrading , RIGHT_HALF_FIRMWARE_UPGRADE_MODULE_NAME ) ;
458474 await this . operations . updateDeviceFirmware ( deviceFirmwarePath , uhkDeviceProduct ) ;
459475 this . logService . misc ( '[DeviceService] Waiting for keyboard' ) ;
0 commit comments