Open DavidCarl opened 2 years ago
I just wanted to confirm that this lib is working with TTGO ESP32 LORA v2.0 (esp32 based).
Example quick &dirty code
let config = <spi::config::Config as Default>::default().baudrate(200.kHz().into());
let sclk = pins.gpio5;
let miso = pins.gpio27;
let mosi = pins.gpio19;
let cs = pins.gpio18;
let rst = pins.gpio12;
let spi = peripherals.spi2;
let spi = spi::Master::<spi::SPI2, _, _, _, _>::new(
spi,
spi::Pins {
sclk,
sdo: miso,
sdi: Some(mosi),
cs: Option::<gpio::Gpio18<gpio::Unknown>>::None,
},
config,
).unwrap();
let mut lora = sx127x_lora::LoRa::new(
spi,
cs.into_output().unwrap(),
rst.into_input_output().unwrap(),
868,
Ets
);
match lora {
Ok(_) => info!("lora succes"),
Err(ref x) => error!("error {:?}", x),
};
let mut lora = lora.unwrap();
let message = b"Hello, world!";
let mut buff = [0u8; 255];
buff[..message.len()].clone_from_slice(message);
let transmit = lora.transmit_payload(
buff,
message.len()
);
match transmit {
Ok(_) => info!("Sent packet"),
Err(e) => error!("Error: {:?}", e),
}
loop {
let poll = lora.poll_irq(Some(30)); //30 Second timeout
match poll {
Ok(size) =>{
info!("with Payload: ");
let buffer = lora.read_packet().unwrap(); // Received buffer. NOTE: 255 bytes are always returned
for i in 0..size{
print!("{}", buffer[i] as char);
}
println!();
},
Err(err) => (), //info!("Timeout {:?}", err),
}
thread::sleep(Duration::from_millis(100));
}
Hi, @bernii, were you able to send messages with the module using this code?
I added a full example that I made for the Lora32 board in #18
Hello
I am looking to implement this library for a project I am doing with a ESP32.
The issue is the following when I try to instantiate this library in the SPI pin from the ESP32.
It simply gives me this error:
Is this anything you have experience with by any chance?
Sincerely