Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/hw_ostc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,19 @@ hw_ostc3_device_id (hw_ostc3_device_t *device, unsigned char data[], unsigned in
if (size != SZ_HARDWARE && size != SZ_HARDWARE2)
return DC_STATUS_INVALIDARGS;

// Send the command.
// We need to try the HARDWARE command first, as HARDWARE2 results
// in a bluetooth disconnect when the OSTC4 is in bootloader mode.
unsigned char hardware[SZ_HARDWARE2] = {0};
status = hw_ostc3_transfer (device, NULL, HARDWARE2, NULL, 0, hardware, SZ_HARDWARE2, NULL, NODELAY);
if (status == DC_STATUS_UNSUPPORTED) {
status = hw_ostc3_transfer (device, NULL, HARDWARE, NULL, 0, hardware + 1, SZ_HARDWARE, NULL, NODELAY);
status = hw_ostc3_transfer(device, NULL, HARDWARE, NULL, 0, hardware + 1, SZ_HARDWARE, NULL, NODELAY);
if (size == SZ_HARDWARE2 && array_uint16_be(hardware) != OSTC4) {
// HARDWARE2 returns additional information
unsigned char hardware2[SZ_HARDWARE2] = {0};
status = hw_ostc3_transfer(device, NULL, HARDWARE2, NULL, 0, hardware2, SZ_HARDWARE2, NULL, NODELAY);
if (status == DC_STATUS_SUCCESS) {
memcpy(hardware, hardware2, SZ_HARDWARE2);
}
}

if (status != DC_STATUS_SUCCESS)
return status;

Expand Down Expand Up @@ -615,8 +622,10 @@ hw_ostc3_device_init (hw_ostc3_device_t *device, hw_ostc3_state_t state)

// Cache the descriptor.
device->hardware = array_uint16_be(hardware + 0);
device->feature = array_uint16_be(hardware + 2);
device->model = hardware[4];
if (device->hardware != OSTC4) {
device->feature = array_uint16_be(hardware + 2);
device->model = hardware[4];
}
device->serial = array_uint16_le (version + 0);
if (device->hardware == OSTC4) {
device->firmware = array_uint16_le (version + 2);
Expand Down
Loading