Move examples to examples/
This commit is contained in:
parent
acf059aa1a
commit
36bdf9dd16
|
@ -13,12 +13,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- `Rn2903::system_module_reset()`
|
||||
- `Rn2903::mac_pause()` and `::mac_resume()`
|
||||
- `BadResponse` and `CannotPause` error variants
|
||||
- Examples directory with LED blinky and LoRa packet RX examples
|
||||
|
||||
### Changed
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
- `main.rs` (moved to an example)
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
use rn2903::Rn2903;
|
||||
use std::env::args;
|
||||
use std::process::exit;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<_> = args().collect();
|
||||
if args.len() <= 1 {
|
||||
eprintln!("rn2903_blinky <serial port>");
|
||||
eprintln!("\tReset the module and toggle pin 0b10 on and off.");
|
||||
eprintln!("\tThis corresponds to the blue user LED on the LoStik.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
let mut txvr = Rn2903::new_at(&args[1]).expect("Could not open device. Error");
|
||||
println!(
|
||||
"Successfully connected. Version: {}",
|
||||
txvr.system_version()
|
||||
.expect("Could not read from device. Error:")
|
||||
);
|
||||
|
||||
txvr.system_module_reset().unwrap();
|
||||
txvr.transact(b"mac pause").unwrap();
|
||||
|
||||
loop {
|
||||
txvr.transact(b"sys set pindig GPIO10 1").unwrap();
|
||||
thread::sleep(Duration::from_millis(1000));
|
||||
txvr.transact(b"sys set pindig GPIO10 0").unwrap();
|
||||
thread::sleep(Duration::from_millis(1000));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
use rn2903::Rn2903;
|
||||
use std::env::args;
|
||||
use std::process::exit;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<_> = args().collect();
|
||||
if args.len() <= 1 {
|
||||
eprintln!("rn2903_lora_packet_rx <serial port>");
|
||||
eprintln!("\tRecieve LoRa packets and print their corresponding hex values.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
let mut txvr = Rn2903::new_at(&args[1]).expect("Could not open device. Error");
|
||||
println!(
|
||||
"Successfully connected. Version: {}",
|
||||
txvr.system_version()
|
||||
.expect("Could not read from device. Error:")
|
||||
);
|
||||
|
||||
txvr.mac_pause().unwrap();
|
||||
txvr.transact(b"sys set pindig GPIO10 0").unwrap();
|
||||
txvr.transact(b"radio rx 0").unwrap();
|
||||
loop {
|
||||
println!("{:?}", txvr.read_line().unwrap());
|
||||
txvr.transact(b"sys set pindig GPIO10 1").unwrap();
|
||||
thread::sleep(Duration::from_millis(100));
|
||||
txvr.transact(b"sys set pindig GPIO10 0").unwrap();
|
||||
txvr.transact(b"radio rx 0").unwrap();
|
||||
}
|
||||
}
|
17
src/main.rs
17
src/main.rs
|
@ -1,17 +0,0 @@
|
|||
use rn2903::{Rn2903, bytes_to_string};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() {
|
||||
let mut txvr = Rn2903::new_at("/dev/ttyUSB0").expect("Could not open device. Error");
|
||||
println!(
|
||||
"Successfully connected. Version: {}",
|
||||
txvr
|
||||
.system_version()
|
||||
.expect("Could not read from device. Error:")
|
||||
);
|
||||
|
||||
dbg!(bytes_to_string(&txvr.transact(b"sys set pindig GPIO10 1").unwrap()));
|
||||
thread::sleep(Duration::from_millis(200));
|
||||
dbg!(bytes_to_string(&txvr.transact(b"sys set pindig GPIO10 0").unwrap()));
|
||||
}
|
Loading…
Reference in New Issue