examples: request_handler is mutable

This commit is contained in:
Boris Faure 2024-04-14 16:06:21 +02:00
parent 41415fae0d
commit 9341ef3b47
7 changed files with 25 additions and 25 deletions

View File

@ -54,7 +54,7 @@ async fn main(_spawner: Spawner) {
let mut bos_descriptor = [0; 256];
let mut msos_descriptor = [0; 256];
let mut control_buf = [0; 64];
let request_handler = MyRequestHandler {};
let mut request_handler = MyRequestHandler {};
let mut device_handler = MyDeviceHandler::new();
let mut state = State::new();
@ -73,7 +73,7 @@ async fn main(_spawner: Spawner) {
// Create classes on the builder.
let config = embassy_usb::class::hid::Config {
report_descriptor: KeyboardReport::desc(),
request_handler: Some(&request_handler),
request_handler: None,
poll_ms: 60,
max_packet_size: 64,
};
@ -137,7 +137,7 @@ async fn main(_spawner: Spawner) {
};
let out_fut = async {
reader.run(false, &request_handler).await;
reader.run(false, &mut request_handler).await;
};
// Run everything concurrently.
@ -153,7 +153,7 @@ impl RequestHandler for MyRequestHandler {
None
}
fn set_report(&self, id: ReportId, data: &[u8]) -> OutResponse {
fn set_report(&mut self, id: ReportId, data: &[u8]) -> OutResponse {
info!("Set report for {:?}: {=[u8]}", id, data);
OutResponse::Accepted
}

View File

@ -47,7 +47,7 @@ async fn main(_spawner: Spawner) {
let mut bos_descriptor = [0; 256];
let mut msos_descriptor = [0; 256];
let mut control_buf = [0; 64];
let request_handler = MyRequestHandler {};
let mut request_handler = MyRequestHandler {};
let mut state = State::new();
@ -63,7 +63,7 @@ async fn main(_spawner: Spawner) {
// Create classes on the builder.
let config = embassy_usb::class::hid::Config {
report_descriptor: MouseReport::desc(),
request_handler: Some(&request_handler),
request_handler: Some(&mut request_handler),
poll_ms: 60,
max_packet_size: 8,
};
@ -110,7 +110,7 @@ impl RequestHandler for MyRequestHandler {
None
}
fn set_report(&self, id: ReportId, data: &[u8]) -> OutResponse {
fn set_report(&mut self, id: ReportId, data: &[u8]) -> OutResponse {
info!("Set report for {:?}: {=[u8]}", id, data);
OutResponse::Accepted
}

View File

@ -41,7 +41,7 @@ async fn main(_spawner: Spawner) {
// You can also add a Microsoft OS descriptor.
let mut msos_descriptor = [0; 256];
let mut control_buf = [0; 64];
let request_handler = MyRequestHandler {};
let mut request_handler = MyRequestHandler {};
let mut device_handler = MyDeviceHandler::new();
let mut state = State::new();
@ -60,7 +60,7 @@ async fn main(_spawner: Spawner) {
// Create classes on the builder.
let config = embassy_usb::class::hid::Config {
report_descriptor: KeyboardReport::desc(),
request_handler: Some(&request_handler),
request_handler: None,
poll_ms: 60,
max_packet_size: 64,
};
@ -114,7 +114,7 @@ async fn main(_spawner: Spawner) {
};
let out_fut = async {
reader.run(false, &request_handler).await;
reader.run(false, &mut request_handler).await;
};
// Run everything concurrently.
@ -130,7 +130,7 @@ impl RequestHandler for MyRequestHandler {
None
}
fn set_report(&self, id: ReportId, data: &[u8]) -> OutResponse {
fn set_report(&mut self, id: ReportId, data: &[u8]) -> OutResponse {
info!("Set report for {:?}: {=[u8]}", id, data);
OutResponse::Accepted
}

View File

@ -44,7 +44,7 @@ async fn main(_spawner: Spawner) {
// You can also add a Microsoft OS descriptor.
let mut msos_descriptor = [0; 256];
let mut control_buf = [0; 64];
let request_handler = MyRequestHandler {};
let mut request_handler = MyRequestHandler {};
let mut device_handler = MyDeviceHandler::new();
let mut state = State::new();
@ -63,7 +63,7 @@ async fn main(_spawner: Spawner) {
// Create classes on the builder.
let config = embassy_usb::class::hid::Config {
report_descriptor: MouseReport::desc(),
request_handler: Some(&request_handler),
request_handler: None,
poll_ms: 60,
max_packet_size: 64,
};
@ -106,7 +106,7 @@ async fn main(_spawner: Spawner) {
};
let out_fut = async {
reader.run(false, &request_handler).await;
reader.run(false, &mut request_handler).await;
};
// Run everything concurrently.
@ -122,7 +122,7 @@ impl RequestHandler for MyRequestHandler {
None
}
fn set_report(&self, id: ReportId, data: &[u8]) -> OutResponse {
fn set_report(&mut self, id: ReportId, data: &[u8]) -> OutResponse {
info!("Set report for {:?}: {=[u8]}", id, data);
OutResponse::Accepted
}

View File

@ -76,7 +76,7 @@ async fn main(_spawner: Spawner) {
let mut msos_descriptor = [0; 256];
let mut control_buf = [0; 64];
let request_handler = MyRequestHandler {};
let mut request_handler = MyRequestHandler {};
let mut device_handler = MyDeviceHandler::new();
let mut state = State::new();
@ -95,7 +95,7 @@ async fn main(_spawner: Spawner) {
// Create classes on the builder.
let config = embassy_usb::class::hid::Config {
report_descriptor: KeyboardReport::desc(),
request_handler: Some(&request_handler),
request_handler: None,
poll_ms: 60,
max_packet_size: 8,
};
@ -148,7 +148,7 @@ async fn main(_spawner: Spawner) {
};
let out_fut = async {
reader.run(false, &request_handler).await;
reader.run(false, &mut request_handler).await;
};
// Run everything concurrently.
@ -164,7 +164,7 @@ impl RequestHandler for MyRequestHandler {
None
}
fn set_report(&self, id: ReportId, data: &[u8]) -> OutResponse {
fn set_report(&mut self, id: ReportId, data: &[u8]) -> OutResponse {
info!("Set report for {:?}: {=[u8]}", id, data);
OutResponse::Accepted
}

View File

@ -68,7 +68,7 @@ async fn main(_spawner: Spawner) {
let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64];
let request_handler = MyRequestHandler {};
let mut request_handler = MyRequestHandler {};
let mut state = State::new();
@ -84,7 +84,7 @@ async fn main(_spawner: Spawner) {
// Create classes on the builder.
let config = embassy_usb::class::hid::Config {
report_descriptor: MouseReport::desc(),
request_handler: Some(&request_handler),
request_handler: Some(&mut request_handler),
poll_ms: 60,
max_packet_size: 8,
};
@ -131,7 +131,7 @@ impl RequestHandler for MyRequestHandler {
None
}
fn set_report(&self, id: ReportId, data: &[u8]) -> OutResponse {
fn set_report(&mut self, id: ReportId, data: &[u8]) -> OutResponse {
info!("Set report for {:?}: {=[u8]}", id, data);
OutResponse::Accepted
}

View File

@ -54,7 +54,7 @@ async fn main(_spawner: Spawner) {
let mut config_descriptor = [0; 256];
let mut bos_descriptor = [0; 256];
let mut control_buf = [0; 64];
let request_handler = MyRequestHandler {};
let mut request_handler = MyRequestHandler {};
let mut state = State::new();
@ -70,7 +70,7 @@ async fn main(_spawner: Spawner) {
// Create classes on the builder.
let config = embassy_usb::class::hid::Config {
report_descriptor: MouseReport::desc(),
request_handler: Some(&request_handler),
request_handler: Some(&mut request_handler),
poll_ms: 60,
max_packet_size: 8,
};
@ -117,7 +117,7 @@ impl RequestHandler for MyRequestHandler {
None
}
fn set_report(&self, id: ReportId, data: &[u8]) -> OutResponse {
fn set_report(&mut self, id: ReportId, data: &[u8]) -> OutResponse {
info!("Set report for {:?}: {=[u8]}", id, data);
OutResponse::Accepted
}