mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2024-05-18 16:28:22 +00:00
adapt beginner material to BSP changes
This commit is contained in:
parent
5ff9fd0f8a
commit
2758be8412
|
@ -29,7 +29,7 @@ fn main() -> ! {
|
||||||
// single letter (byte) packet
|
// single letter (byte) packet
|
||||||
packet.copy_from_slice(&[source]);
|
packet.copy_from_slice(&[source]);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
// response should be one byte large
|
// response should be one byte large
|
||||||
|
|
|
@ -26,7 +26,7 @@ fn main() -> ! {
|
||||||
for source in b'A'..=b'B' {
|
for source in b'A'..=b'B' {
|
||||||
packet.copy_from_slice(&[source]);
|
packet.copy_from_slice(&[source]);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
// response should be one byte large
|
// response should be one byte large
|
||||||
|
|
|
@ -24,7 +24,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
/* # Retrieve the secret string */
|
/* # Retrieve the secret string */
|
||||||
packet.copy_from_slice(&[]); // empty packet
|
packet.copy_from_slice(&[]); // empty packet
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn main() -> ! {
|
||||||
for source in 0..=127 {
|
for source in 0..=127 {
|
||||||
packet.copy_from_slice(&[source]);
|
packet.copy_from_slice(&[source]);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
// response should be one byte large
|
// response should be one byte large
|
||||||
|
@ -48,7 +48,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
/* # Retrieve the secret string */
|
/* # Retrieve the secret string */
|
||||||
packet.copy_from_slice(&[]); // empty packet
|
packet.copy_from_slice(&[]); // empty packet
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn main() -> ! {
|
||||||
for source in 0..=127 {
|
for source in 0..=127 {
|
||||||
packet.copy_from_slice(&[source]);
|
packet.copy_from_slice(&[source]);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
// response should be one byte large
|
// response should be one byte large
|
||||||
|
@ -48,7 +48,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
/* # Retrieve the secret string */
|
/* # Retrieve the secret string */
|
||||||
packet.copy_from_slice(&[]); // empty packet
|
packet.copy_from_slice(&[]); // empty packet
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
@ -79,7 +79,7 @@ fn main() -> ! {
|
||||||
/* # (NEW) Verify decrypted text */
|
/* # (NEW) Verify decrypted text */
|
||||||
packet.copy_from_slice(&buffer);
|
packet.copy_from_slice(&buffer);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn main() -> ! {
|
||||||
for plainletter in 0..=127 {
|
for plainletter in 0..=127 {
|
||||||
packet.copy_from_slice(&[plainletter]);
|
packet.copy_from_slice(&[plainletter]);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
// response should be one byte large
|
// response should be one byte large
|
||||||
|
@ -48,7 +48,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
/* # Retrieve the secret string */
|
/* # Retrieve the secret string */
|
||||||
packet.copy_from_slice(&[]); // empty packet
|
packet.copy_from_slice(&[]); // empty packet
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
@ -79,7 +79,7 @@ fn main() -> ! {
|
||||||
);
|
);
|
||||||
|
|
||||||
/* # Verify decrypted text */
|
/* # Verify decrypted text */
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
|
|
@ -29,7 +29,7 @@ fn main() -> ! {
|
||||||
// ^^^^^^^ NOTE complete ASCII range
|
// ^^^^^^^ NOTE complete ASCII range
|
||||||
packet.copy_from_slice(&[plainletter]);
|
packet.copy_from_slice(&[plainletter]);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
// response should be one byte large
|
// response should be one byte large
|
||||||
|
@ -51,7 +51,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
/* # Retrieve the secret string */
|
/* # Retrieve the secret string */
|
||||||
packet.copy_from_slice(&[]); // empty packet
|
packet.copy_from_slice(&[]); // empty packet
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
@ -83,7 +83,7 @@ fn main() -> ! {
|
||||||
/* # Verify decrypted text */
|
/* # Verify decrypted text */
|
||||||
packet.copy_from_slice(&buffer);
|
packet.copy_from_slice(&buffer);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_err() {
|
||||||
log::error!("no response or response packet was corrupted");
|
log::error!("no response or response packet was corrupted");
|
||||||
|
|
|
@ -38,7 +38,7 @@ fn main() -> ! {
|
||||||
str::from_utf8(msg).expect("msg was not valid UTF-8 data")
|
str::from_utf8(msg).expect("msg was not valid UTF-8 data")
|
||||||
);
|
);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
if radio.recv_timeout(&mut packet, &mut timer, TEN_MS).is_ok() {
|
||||||
log::info!(
|
log::info!(
|
||||||
"received: {}",
|
"received: {}",
|
||||||
|
|
|
@ -28,7 +28,7 @@ fn main() -> ! {
|
||||||
"sending: {}",
|
"sending: {}",
|
||||||
str::from_utf8(msg).expect("message is not valid UTF-8")
|
str::from_utf8(msg).expect("message is not valid UTF-8")
|
||||||
);
|
);
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
// TODO try uncommenting this line
|
// TODO try uncommenting this line
|
||||||
// timer.delay(1_000);
|
// timer.delay(1_000);
|
||||||
|
|
|
@ -32,7 +32,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
packet.copy_from_slice(msg);
|
packet.copy_from_slice(msg);
|
||||||
|
|
||||||
radio.send(&packet);
|
radio.send(&mut packet);
|
||||||
|
|
||||||
dk::exit();
|
dk::exit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue