pub fn new_lora_radio(
    frequency: u64,
    _spreading_factor: u32,
    transmission_power: u8,
) -> Result<Channel, MeshSimError> {
    use hal::spidev::{self, SpidevOptions};
    use hal::sysfs_gpio::Direction;
    use hal::{Pin, Spidev};

    let mut spi = Spidev::open("/dev/spidev0.0").unwrap();
    let options = SpidevOptions::new()
        .bits_per_word(8)
        .max_speed_hz(1_000_000)
        .mode(spidev::SPI_MODE_0)
        .build();
    spi.configure(&options).unwrap();

    let cs = Pin::new(NSS_PIN);
    cs.export().unwrap();
    cs.set_direction(Direction::Out).unwrap();

    let irq = Pin::new(IRQ_PIN);
    irq.export().unwrap();
    irq.set_direction(Direction::In).unwrap();

    let reset = Pin::new(RESET_PIN);
    reset.export().unwrap();
    reset.set_direction(Direction::Out).unwrap();

    let lora = LoRa::from({
        let sx1276 = sx1276::SX1276::new(spi, cs, irq, reset, frequency).unwrap();
        sx1276.set_transmission_power(transmission_power);
        sx1276
    });

    Ok((
        Arc::new(lora.clone()) as Arc<dyn Radio>,
        Box::new(lora) as Box<dyn Listener>,
    ))
}
///Used to produce a Lora Radio trait object
Used to produce a Lora Radio trait object
Used to produce a Lora Radio trait object
pub fn new_lora_radio(
    frequency: u64,
    _spreading_factor: u32,
    transmission_power: u8,
) -> Result<Channel, MeshSimError> {
    use hal::spidev::{self, SpidevOptions};
    use hal::sysfs_gpio::Direction;
    use hal::{Pin, Spidev};
    let mut spi = Spidev::open("/dev/spidev0.0").unwrap();
    let options = SpidevOptions::new()
        .bits_per_word(8)
        .max_speed_hz(1_000_000)
        .mode(spidev::SPI_MODE_0)
        .build();
    spi.configure(&options).unwrap();
    let cs = Pin::new(NSS_PIN);
    cs.export().unwrap();
    cs.set_direction(Direction::Out).unwrap();
    let irq = Pin::new(IRQ_PIN);
    irq.export().unwrap();
    irq.set_direction(Direction::In).unwrap();
    let reset = Pin::new(RESET_PIN);
    reset.export().unwrap();
    reset.set_direction(Direction::Out).unwrap();
    let lora = LoRa::from({
        let sx1276 = sx1276::SX1276::new(spi, cs, irq, reset, frequency).unwrap();
        sx1276.set_transmission_power(transmission_power);
        sx1276
    });
    Ok((
        Arc::new(lora.clone()) as Arc<dyn Radio>,
        Box::new(lora) as Box<dyn Listener>,
    ))
}
pub fn new_lora_radio ( frequency : u64 , _spreading_factor : u32 , transmission_power : u8 , ) -> Result < Channel , MeshSimError > { use hal :: spidev :: { self , SpidevOptions } ; use hal :: sysfs_gpio :: Direction ; use hal :: { Pin , Spidev } ; let mut spi = Spidev :: open ( " " ) . unwrap ( ) ; let options = SpidevOptions :: new ( ) . bits_per_word ( 8 ) . max_speed_hz ( 1_000_000 ) . mode ( spidev :: SPI_MODE_0 ) . build ( ) ; spi . configure ( & options ) . unwrap ( ) ; let cs = Pin :: new ( NSS_PIN ) ; cs . export ( ) . unwrap ( ) ; cs . set_direction ( Direction :: Out ) . unwrap ( ) ; let irq = Pin :: new ( IRQ_PIN ) ; irq . export ( ) . unwrap ( ) ; irq . set_direction ( Direction :: In ) . unwrap ( ) ; let reset = Pin :: new ( RESET_PIN ) ; reset . export ( ) . unwrap ( ) ; reset . set_direction ( Direction :: Out ) . unwrap ( ) ; let lora = LoRa :: from ( { let sx1276 = sx1276 :: SX1276 :: new ( spi , cs , irq , reset , frequency ) . unwrap ( ) ; sx1276 . set_transmission_power ( transmission_power ) ; sx1276 } ) ; Ok ( ( Arc :: new ( lora . clone ( ) ) as Arc < dyn Radio > , Box :: new ( lora ) as Box < dyn Listener > , ) ) }
Used to produce a Lora Radio trait object
Used to produce a Lora Radio trait object
frequency
u64
_spreading_factor
u32
transmission_power
u8