2021-09-30 09:25:45 +02:00
|
|
|
#![no_std]
|
2023-04-14 23:01:13 +02:00
|
|
|
#![feature(async_fn_in_trait, impl_trait_projections)]
|
|
|
|
#![allow(incomplete_features)]
|
2023-04-27 18:05:33 +02:00
|
|
|
//! embassy-lora holds LoRa-specific functionality.
|
2021-09-30 09:25:45 +02:00
|
|
|
|
|
|
|
pub(crate) mod fmt;
|
2023-04-21 08:20:46 +02:00
|
|
|
#[cfg(feature = "external-lora-phy")]
|
2023-04-27 18:05:33 +02:00
|
|
|
/// interface variants required by the external lora physical layer crate (lora-phy)
|
2023-04-21 08:20:46 +02:00
|
|
|
pub mod iv;
|
2021-09-30 09:25:45 +02:00
|
|
|
|
2022-08-09 12:17:30 +02:00
|
|
|
#[cfg(feature = "time")]
|
|
|
|
use embassy_time::{Duration, Instant, Timer};
|
|
|
|
|
2021-09-30 09:25:45 +02:00
|
|
|
/// A convenience timer to use with the LoRaWAN crate
|
2022-08-09 12:17:30 +02:00
|
|
|
#[cfg(feature = "time")]
|
|
|
|
pub struct LoraTimer {
|
|
|
|
start: Instant,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "time")]
|
|
|
|
impl LoraTimer {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
Self { start: Instant::now() }
|
|
|
|
}
|
|
|
|
}
|
2021-09-30 09:25:45 +02:00
|
|
|
|
|
|
|
#[cfg(feature = "time")]
|
|
|
|
impl lorawan_device::async_device::radio::Timer for LoraTimer {
|
2022-08-09 12:17:30 +02:00
|
|
|
fn reset(&mut self) {
|
|
|
|
self.start = Instant::now();
|
|
|
|
}
|
|
|
|
|
2023-04-14 23:01:13 +02:00
|
|
|
async fn at(&mut self, millis: u64) {
|
|
|
|
Timer::at(self.start + Duration::from_millis(millis)).await
|
2022-08-09 12:17:30 +02:00
|
|
|
}
|
|
|
|
|
2023-04-14 23:01:13 +02:00
|
|
|
async fn delay_ms(&mut self, millis: u64) {
|
|
|
|
Timer::after(Duration::from_millis(millis)).await
|
2021-09-30 09:25:45 +02:00
|
|
|
}
|
|
|
|
}
|