mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-21 22:32:29 +00:00
examples: request_handler is mutable
This commit is contained in:
parent
41415fae0d
commit
9341ef3b47
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user