2020-06-09 09:52:27 +00:00
|
|
|
#![deny(unused_must_use)]
|
|
|
|
#![no_main]
|
|
|
|
#![no_std]
|
|
|
|
|
|
|
|
use core::str;
|
|
|
|
|
|
|
|
use cortex_m_rt::entry;
|
2020-06-17 16:37:53 +00:00
|
|
|
use dk::ieee802154::{Channel, Packet};
|
2020-06-09 09:52:27 +00:00
|
|
|
use panic_log as _; // the panicking behavior
|
|
|
|
|
|
|
|
#[entry]
|
|
|
|
fn main() -> ! {
|
|
|
|
let board = dk::init().unwrap();
|
|
|
|
let mut radio = board.radio;
|
|
|
|
|
2020-06-17 16:37:53 +00:00
|
|
|
// puzzle.hex uses channel 25
|
|
|
|
radio.set_channel(Channel::_25);
|
|
|
|
|
2020-06-09 09:52:27 +00:00
|
|
|
let mut packet = Packet::new();
|
|
|
|
|
|
|
|
// try these
|
|
|
|
let msg = "";
|
|
|
|
// let msg = "A";
|
|
|
|
// let msg = "Hello?";
|
|
|
|
|
|
|
|
packet.copy_from_slice(msg.as_bytes());
|
|
|
|
radio.send(&packet);
|
|
|
|
log::info!("sent: {:?}", msg);
|
2020-06-17 12:30:07 +00:00
|
|
|
// listen for a response packet and ensure it is not corrupted
|
|
|
|
if radio.recv(&mut packet).is_ok() {
|
|
|
|
// convert the packet contents to str or print error message on failure
|
|
|
|
let response = str::from_utf8(&*packet).expect("could not convert response to str");
|
|
|
|
log::info!("received: {}", response);
|
2020-06-09 09:52:27 +00:00
|
|
|
}
|
|
|
|
dk::exit()
|
|
|
|
}
|