Deprecate original LoRa drivers. Update rust-lorawan releases.

This commit is contained in:
ceekdee 2023-04-25 13:51:19 -05:00
parent 73f25093c7
commit f729d2d060
8 changed files with 12 additions and 129 deletions

View file

@ -40,5 +40,5 @@ embedded-hal = { version = "0.2", features = ["unproven"] }
bit_field = { version = "0.10" }
lora-phy = { version = "1", optional = true }
lorawan-device = { version = "0.9.0", path = "../../rust-lorawan/device", default-features = false, features = ["async"] }
lorawan = { version = "0.7.2", path = "../../rust-lorawan/encoding", default-features = false }
lorawan-device = { version = "0.10.0", default-features = false, features = ["async"] }
lorawan = { version = "0.7.3", default-features = false }

View file

@ -1,4 +1,5 @@
//! A radio driver integration for the radio found on STM32WL family devices.
#![allow(deprecated)]
use core::future::poll_fn;
use core::task::Poll;

View file

@ -56,6 +56,7 @@ pub mod sdmmc;
#[cfg(spi)]
pub mod spi;
#[cfg(stm32wl)]
#[deprecated(note = "use the external LoRa physical layer crate - https://crates.io/crates/lora-phy")]
pub mod subghz;
#[cfg(usart)]
pub mod usart;

View file

@ -20,8 +20,8 @@ embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defm
embedded-io = "0.4.0"
embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx126x", "time", "defmt", "external-lora-phy"], optional = true }
lora-phy = { version = "1" }
lorawan-device = { version = "0.9.0", path = "../../../rust-lorawan/device", default-features = false, features = ["async", "external-lora-phy"], optional = true }
lorawan = { version = "0.7.2", path = "../../../rust-lorawan/encoding", default-features = false, features = ["default-crypto"], optional = true }
lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"], optional = true }
lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"], optional = true }
defmt = "0.3"
defmt-rtt = "0.4"

View file

@ -17,8 +17,8 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
embassy-usb-logger = { version = "0.1.0", path = "../../embassy-usb-logger" }
embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["time", "defmt", "external-lora-phy"] }
lora-phy = { version = "1" }
lorawan-device = { version = "0.9.0", path = "../../../rust-lorawan/device", default-features = false, features = ["async", "external-lora-phy"] }
lorawan = { version = "0.7.2", path = "../../../rust-lorawan/encoding", default-features = false, features = ["default-crypto"] }
lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"] }
lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"] }
defmt = "0.3"
defmt-rtt = "0.4"

View file

@ -15,8 +15,8 @@ embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["ni
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32l072cz", "time-driver-any", "exti", "unstable-traits", "memory-x"] }
embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["sx127x", "time", "defmt", "external-lora-phy"], optional = true }
lora-phy = { version = "1" }
lorawan-device = { version = "0.9.0", path = "../../../rust-lorawan/device", default-features = false, features = ["async", "external-lora-phy"], optional = true }
lorawan = { version = "0.7.2", path = "../../../rust-lorawan/encoding", default-features = false, features = ["default-crypto"], optional = true }
lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"], optional = true }
lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"], optional = true }
defmt = "0.3"
defmt-rtt = "0.4"

View file

@ -12,8 +12,8 @@ embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["
embassy-embedded-hal = {version = "0.1.0", path = "../../embassy-embedded-hal" }
embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time", "defmt", "external-lora-phy"] }
lora-phy = { version = "1" }
lorawan-device = { version = "0.9.0", path = "../../../rust-lorawan/device", default-features = false, features = ["async", "external-lora-phy"] }
lorawan = { version = "0.7.2", path = "../../../rust-lorawan/encoding", default-features = false, features = ["default-crypto"] }
lorawan-device = { version = "0.10.0", default-features = false, features = ["async", "external-lora-phy"] }
lorawan = { version = "0.7.3", default-features = false, features = ["default-crypto"] }
defmt = "0.3"
defmt-rtt = "0.4"

View file

@ -1,119 +0,0 @@
#![no_std]
#![no_main]
#![macro_use]
#![allow(dead_code)]
#![feature(type_alias_impl_trait)]
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::dma::NoDma;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::interrupt;
use embassy_stm32::interrupt::{Interrupt, InterruptExt};
use embassy_stm32::subghz::*;
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use embassy_sync::signal::Signal;
use {defmt_rtt as _, panic_probe as _};
const PING_DATA: &str = "PING";
const DATA_LEN: u8 = PING_DATA.len() as u8;
const PING_DATA_BYTES: &[u8] = PING_DATA.as_bytes();
const PREAMBLE_LEN: u16 = 5 * 8;
const RF_FREQ: RfFreq = RfFreq::from_frequency(867_500_000);
const SYNC_WORD: [u8; 8] = [0x79, 0x80, 0x0C, 0xC0, 0x29, 0x95, 0xF8, 0x4A];
const SYNC_WORD_LEN: u8 = SYNC_WORD.len() as u8;
const SYNC_WORD_LEN_BITS: u8 = SYNC_WORD_LEN * 8;
const TX_BUF_OFFSET: u8 = 128;
const RX_BUF_OFFSET: u8 = 0;
const LORA_PACKET_PARAMS: LoRaPacketParams = LoRaPacketParams::new()
.set_crc_en(true)
.set_preamble_len(PREAMBLE_LEN)
.set_payload_len(DATA_LEN)
.set_invert_iq(false)
.set_header_type(HeaderType::Fixed);
const LORA_MOD_PARAMS: LoRaModParams = LoRaModParams::new()
.set_bw(LoRaBandwidth::Bw125)
.set_cr(CodingRate::Cr45)
.set_ldro_en(true)
.set_sf(SpreadingFactor::Sf7);
// configuration for +10 dBm output power
// see table 35 "PA optimal setting and operating modes"
const PA_CONFIG: PaConfig = PaConfig::new().set_pa_duty_cycle(0x1).set_hp_max(0x0).set_pa(PaSel::Lp);
const TCXO_MODE: TcxoMode = TcxoMode::new()
.set_txco_trim(TcxoTrim::Volts1pt7)
.set_timeout(Timeout::from_duration_sat(core::time::Duration::from_millis(10)));
const TX_PARAMS: TxParams = TxParams::new().set_power(0x0D).set_ramp_time(RampTime::Micros40);
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let mut config = embassy_stm32::Config::default();
config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32;
let p = embassy_stm32::init(config);
let mut led1 = Output::new(p.PB15, Level::High, Speed::Low);
let mut led2 = Output::new(p.PB9, Level::Low, Speed::Low);
let mut led3 = Output::new(p.PB11, Level::Low, Speed::Low);
let button = Input::new(p.PA0, Pull::Up);
let mut pin = ExtiInput::new(button, p.EXTI0);
static IRQ_SIGNAL: Signal<CriticalSectionRawMutex, ()> = Signal::new();
let radio_irq = interrupt::take!(SUBGHZ_RADIO);
radio_irq.set_handler(|_| {
IRQ_SIGNAL.signal(());
unsafe { interrupt::SUBGHZ_RADIO::steal() }.disable();
});
let mut radio = SubGhz::new(p.SUBGHZSPI, NoDma, NoDma);
defmt::info!("Radio ready for use");
led1.set_low();
led2.set_high();
unwrap!(radio.set_standby(StandbyClk::Rc));
unwrap!(radio.set_tcxo_mode(&TCXO_MODE));
unwrap!(radio.set_standby(StandbyClk::Hse));
unwrap!(radio.set_regulator_mode(RegMode::Ldo));
unwrap!(radio.set_buffer_base_address(TX_BUF_OFFSET, RX_BUF_OFFSET));
unwrap!(radio.set_pa_config(&PA_CONFIG));
unwrap!(radio.set_pa_ocp(Ocp::Max60m));
unwrap!(radio.set_tx_params(&TX_PARAMS));
unwrap!(radio.set_packet_type(PacketType::LoRa));
unwrap!(radio.set_lora_sync_word(LoRaSyncWord::Public));
unwrap!(radio.set_lora_mod_params(&LORA_MOD_PARAMS));
unwrap!(radio.set_lora_packet_params(&LORA_PACKET_PARAMS));
unwrap!(radio.calibrate_image(CalibrateImage::ISM_863_870));
unwrap!(radio.set_rf_frequency(&RF_FREQ));
defmt::info!("Status: {:?}", unwrap!(radio.status()));
led2.set_low();
loop {
pin.wait_for_rising_edge().await;
led3.set_high();
unwrap!(radio.set_irq_cfg(&CfgIrq::new().irq_enable_all(Irq::TxDone)));
unwrap!(radio.write_buffer(TX_BUF_OFFSET, PING_DATA_BYTES));
unwrap!(radio.set_tx(Timeout::DISABLED));
radio_irq.enable();
IRQ_SIGNAL.wait().await;
let (_, irq_status) = unwrap!(radio.irq_status());
if irq_status & Irq::TxDone.mask() != 0 {
defmt::info!("TX done");
}
unwrap!(radio.clear_irq_status(irq_status));
led3.set_low();
}
}