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
15 changes: 14 additions & 1 deletion hidi2c-target-service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,14 @@ impl<
// but as soon as the aggregation / HID library goes in, look into leveraging it for filtering out invalid report
// IDs here.

match bus.listen_for_response().await? {
Request::Read(_address) => {}
other => {
error!("Expected read request after get report command, got {:?}", other);
return Err(Error::Protocol(ProtocolError::InvalidCommand));
}
}

hid_device
.process_get_report(report_type.try_into()?, report_id, async |report| {
// Note: per HID spec, the length field needs to include its own length (2 bytes)
Expand Down Expand Up @@ -639,8 +647,13 @@ impl<
.checked_sub(device_descriptor::HID_REPORT_HEADER_SIZE_BYTES))
.ok_or(Error::Protocol(ProtocolError::InvalidSize))? as usize;

let data_start_index = if hid_device.report_descriptor().report_ids_implicit() {
0
} else {
1
};
let report_data = data
.get(..report_size)
.get(data_start_index..data_start_index + report_size)
.ok_or(Error::Protocol(ProtocolError::InvalidSize))?;

let set_report = match report_type {
Expand Down
Loading