@@ -17,7 +17,8 @@ import { CommonModule } from '@angular/common';
1717type DiscoveredDevicesFilter = ( devices : DiscoveredDevice [ ] ) => DiscoveredDevice [ ] ;
1818
1919const NoFilter : DiscoveredDevicesFilter = devices => devices ;
20- const CubingPrefixes = [ 'GAN' , 'MG' , 'AiCube' , 'Gi' , 'Mi Smart Magic Cube' , 'GoCube' , 'Rubiks' , 'MHC' , 'WCU' , 'QY-' ] ;
20+ const QiYiPrefix = 'QY-' ;
21+ const CubingPrefixes = [ 'GAN' , 'MG' , 'AiCube' , 'Gi' , 'Mi Smart Magic Cube' , 'GoCube' , 'Rubiks' , 'MHC' , 'WCU' , QiYiPrefix ] ;
2122const CubingDeviceFilter : DiscoveredDevicesFilter = devices => devices . filter ( isCubingDevice ) ;
2223const ScanTimeout = 30000 ;
2324
@@ -94,10 +95,22 @@ export class DiscoveryComponent {
9495 return undefined ;
9596 }
9697
97- // extract the last 6 bytes of the manufacturer data, reverse them and format them as a MAC address
98+ if ( device . name ?. startsWith ( QiYiPrefix ) ) {
99+ return this . qiyiEncryptionKey ( manufacturerDataPart ) ;
100+ } else {
101+ return this . ganEncryptionKey ( manufacturerDataPart ) ;
102+ }
103+ }
104+
105+ private ganEncryptionKey ( manufacturerDataPart : number [ ] ) : string | undefined {
98106 return manufacturerDataPart . slice ( - 6 ) . reverse ( ) . map ( byte => byte . toString ( 16 ) . padStart ( 2 , '0' ) ) . join ( ':' ) . toUpperCase ( ) ;
99107 }
100108
109+
110+ private qiyiEncryptionKey ( manufacturerDataPart : number [ ] ) : string | undefined {
111+ return manufacturerDataPart . slice ( 0 , 6 ) . reverse ( ) . map ( byte => byte . toString ( 16 ) . padStart ( 2 , '0' ) ) . join ( ':' ) . toUpperCase ( ) ;
112+ }
113+
101114 async copyToClipboard ( text : string ) : Promise < void > {
102115 await writeText ( text ) ;
103116
0 commit comments