@@ -488,12 +488,19 @@ hw_ostc3_device_id (hw_ostc3_device_t *device, unsigned char data[], unsigned in
488
488
if (size != SZ_HARDWARE && size != SZ_HARDWARE2 )
489
489
return DC_STATUS_INVALIDARGS ;
490
490
491
- // Send the command.
491
+ // We need to try the HARDWARE command first, as HARDWARE2 results
492
+ // in a bluetooth disconnect when the OSTC4 is in bootloader mode.
492
493
unsigned char hardware [SZ_HARDWARE2 ] = {0 };
493
- status = hw_ostc3_transfer (device , NULL , HARDWARE2 , NULL , 0 , hardware , SZ_HARDWARE2 , NULL , NODELAY );
494
- if (status == DC_STATUS_UNSUPPORTED ) {
495
- status = hw_ostc3_transfer (device , NULL , HARDWARE , NULL , 0 , hardware + 1 , SZ_HARDWARE , NULL , NODELAY );
494
+ status = hw_ostc3_transfer (device , NULL , HARDWARE , NULL , 0 , hardware + 1 , SZ_HARDWARE , NULL , NODELAY );
495
+ if (size == SZ_HARDWARE2 && array_uint16_be (hardware ) != OSTC4 ) {
496
+ // HARDWARE2 returns additional information
497
+ unsigned char hardware2 [SZ_HARDWARE2 ] = {0 };
498
+ status = hw_ostc3_transfer (device , NULL , HARDWARE2 , NULL , 0 , hardware2 , SZ_HARDWARE2 , NULL , NODELAY );
499
+ if (status == DC_STATUS_SUCCESS ) {
500
+ memcpy (hardware , hardware2 , SZ_HARDWARE2 );
501
+ }
496
502
}
503
+
497
504
if (status != DC_STATUS_SUCCESS )
498
505
return status ;
499
506
@@ -615,8 +622,10 @@ hw_ostc3_device_init (hw_ostc3_device_t *device, hw_ostc3_state_t state)
615
622
616
623
// Cache the descriptor.
617
624
device -> hardware = array_uint16_be (hardware + 0 );
618
- device -> feature = array_uint16_be (hardware + 2 );
619
- device -> model = hardware [4 ];
625
+ if (device -> hardware != OSTC4 ) {
626
+ device -> feature = array_uint16_be (hardware + 2 );
627
+ device -> model = hardware [4 ];
628
+ }
620
629
device -> serial = array_uint16_le (version + 0 );
621
630
if (device -> hardware == OSTC4 ) {
622
631
device -> firmware = array_uint16_le (version + 2 );
0 commit comments