-
Notifications
You must be signed in to change notification settings - Fork 17
/
radio-send.rs
39 lines (29 loc) · 1023 Bytes
/
radio-send.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#![deny(unused_must_use)]
#![no_main]
#![no_std]
use core::str;
use cortex_m_rt::entry;
use dk::ieee802154::{Channel, Packet, TxPower};
// this imports `src/lib.rs`to retrieve our global logger + panicking-behavior
use radio_app as _;
#[entry]
fn main() -> ! {
let board = dk::init().unwrap();
let mut radio = board.radio;
// these are the default settings of the DK's radio
// NOTE if you ran `change-channel` then you may need to update the channel here
radio.set_channel(Channel::_20); // <- must match the Dongle's listening channel
radio.set_txpower(TxPower::Pos8dBm);
let mut packet = Packet::new();
// these three are equivalent
let msg: &[u8; 5] = &[72, 101, 108, 108, 111];
// let msg: &[u8; 5] = &[b'H', b'e', b'l', b'l', b'o'];
// let msg: &[u8; 5] = b"Hello";
defmt::println!(
"sending: {}",
str::from_utf8(msg).expect("msg is not valid UTF-8 data")
);
packet.copy_from_slice(msg);
radio.send(&mut packet);
dk::exit();
}