@@ -27,8 +27,13 @@ use radio_sx127x::prelude::*;
2727#[ derive( StructOpt ) ]
2828#[ structopt( name = "Sx127x-util" ) ]
2929/// A Command Line Interface (CLI) for interacting with a local Sx127x radio device
30- /// Configuration 1: --spi=/dev/spidev0.0 --cs-pin 16 --rst-pin 17 --busy-pin 5
31- /// Configuration 2: --spi=/dev/spidev0.0 --cs-pin 13 --rst-pin 18 --busy-pin 8
30+ ///
31+ /// Configuration 1: --cs-pin 16 --rst-pin 17 --busy-pin 5
32+ ///
33+ /// Configuration 2: --cs-pin 13 --rst-pin 18 --busy-pin 8
34+ ///
35+ /// Configuration 3: --cs-pin 8 --rst-pin 17 --busy-pin 5
36+ ///
3237pub struct Options {
3338
3439 #[ structopt( subcommand) ]
@@ -52,19 +57,10 @@ pub struct Options {
5257 #[ structopt( long = "busy-pin" , default_value = "5" , env = "SX127X_BUSY" ) ]
5358 busy : u64 ,
5459
55- /// DIO1 pin
56- #[ structopt( long = "dio1-pin" , default_value = "20" , env = "SX127X_DIO1" ) ]
57- dio1 : u64 ,
58-
59- /// DIO2 pin
60- #[ structopt( long = "dio2-pin" , default_value = "23" , env = "SX127X_DIO2" ) ]
61- _dio2 : u64 ,
62-
6360 /// Baud rate setting
6461 #[ structopt( long = "baud" , default_value = "1000000" , env = "SX127X_BAUD" ) ]
6562 baud : u32 ,
6663
67-
6864 #[ structopt( long = "log-level" , default_value = "info" ) ]
6965 /// Enable verbose logging
7066 level : LevelFilter ,
@@ -147,7 +143,7 @@ fn main() {
147143 // Connect to hardware
148144 let mut spi = Spidev :: open ( opts. spi ) . expect ( "error opening spi device" ) ;
149145 let mut config = spidev:: SpidevOptions :: new ( ) ;
150- config. mode ( spidev:: SPI_MODE_0 ) ;
146+ config. mode ( spidev:: SPI_MODE_0 | spidev :: SPI_NO_CS ) ;
151147 config. max_speed_hz ( opts. baud ) ;
152148 spi. configure ( & config) . expect ( "error configuring spi device" ) ;
153149
@@ -165,11 +161,6 @@ fn main() {
165161 busy. export ( ) . expect ( "error exporting busy pin" ) ;
166162 busy. set_direction ( Direction :: Out ) . expect ( "error setting busy pin direction" ) ;
167163
168- let dio1 = PinDev :: new ( opts. dio1 ) ;
169- dio1. export ( ) . expect ( "error exporting dio1 pin" ) ;
170- dio1. set_direction ( Direction :: Out ) . expect ( "error setting dio1 pin direction" ) ;
171-
172-
173164 debug ! ( "Creating radio instance" ) ;
174165
175166 let settings = Settings :: default ( ) ;
@@ -247,4 +238,6 @@ fn main() {
247238 //_ => warn!("unsuppored command: {:?}", opts.command),
248239 }
249240
241+
242+
250243}
0 commit comments