Fix heapless vec
Removed unused lorawan patch
This commit is contained in:
@@ -1,160 +1,8 @@
|
|||||||
diff --git a/src/async_device/mod.rs b/src/async_device/mod.rs
|
|
||||||
index 362c3b4..aac0e75 100644
|
|
||||||
--- a/src/async_device/mod.rs
|
|
||||||
+++ b/src/async_device/mod.rs
|
|
||||||
@@ -305,7 +305,7 @@ where
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(unused)]
|
|
||||||
- enum RxcWindowResponse<F: futures::Future<Output = ()> + Sized + Unpin> {
|
|
||||||
+ enum RxcWindowResponse<F: futures::Future<Output=()> + Sized + Unpin> {
|
|
||||||
Rx(usize, RxQuality, F),
|
|
||||||
Timeout(u32),
|
|
||||||
}
|
|
||||||
@@ -318,7 +318,7 @@ where
|
|
||||||
timeout_fut: F,
|
|
||||||
) -> RxcWindowResponse<F>
|
|
||||||
where
|
|
||||||
- F: futures::Future<Output = ()> + Sized + Unpin,
|
|
||||||
+ F: futures::Future<Output=()> + Sized + Unpin,
|
|
||||||
R: radio::PhyRxTx + Timings,
|
|
||||||
{
|
|
||||||
let rx_fut = radio.rx_continuous(rx_buf.as_mut());
|
|
||||||
@@ -356,7 +356,7 @@ where
|
|
||||||
duration,
|
|
||||||
timeout_fut,
|
|
||||||
)
|
|
||||||
- .await
|
|
||||||
+ .await
|
|
||||||
{
|
|
||||||
RxcWindowResponse::Rx(sz, _, timeout_fut) => {
|
|
||||||
log::debug!("RXC window received {} bytes.", sz);
|
|
||||||
diff --git a/src/async_device/test/mod.rs b/src/async_device/test/mod.rs
|
|
||||||
index 4d8c9b4..e90ba2d 100644
|
|
||||||
--- a/src/async_device/test/mod.rs
|
|
||||||
+++ b/src/async_device/test/mod.rs
|
|
||||||
@@ -18,7 +18,7 @@ mod util;
|
|
||||||
use util::{setup, setup_with_session, setup_with_session_class_c};
|
|
||||||
|
|
||||||
type Device =
|
|
||||||
- crate::async_device::Device<TestRadio, DefaultFactory, TestTimer, rand_core::OsRng, 512, 4>;
|
|
||||||
+crate::async_device::Device<TestRadio, DefaultFactory, TestTimer, rand_core::OsRng, 512, 4>;
|
|
||||||
|
|
||||||
#[tokio::test]
|
|
||||||
async fn test_join_rx1() {
|
|
||||||
diff --git a/src/async_device/test/radio.rs b/src/async_device/test/radio.rs
|
|
||||||
index e0be1d3..827a408 100644
|
|
||||||
--- a/src/async_device/test/radio.rs
|
|
||||||
+++ b/src/async_device/test/radio.rs
|
|
||||||
@@ -1,4 +1,3 @@
|
|
||||||
-use super::*;
|
|
||||||
use crate::async_device::radio::{PhyRxTx, RxConfig, RxStatus};
|
|
||||||
use std::sync::Arc;
|
|
||||||
use tokio::{
|
|
||||||
diff --git a/src/async_device/test/util.rs b/src/async_device/test/util.rs
|
|
||||||
index d289d32..c758271 100644
|
|
||||||
--- a/src/async_device/test/util.rs
|
|
||||||
+++ b/src/async_device/test/util.rs
|
|
||||||
@@ -1,4 +1,4 @@
|
|
||||||
-use super::{get_dev_addr, get_key, radio::*, region, timer::*, Device, SendResponse};
|
|
||||||
+use super::{get_dev_addr, get_key, region, Device, SendResponse};
|
|
||||||
|
|
||||||
use crate::mac::Session;
|
|
||||||
use crate::test_util::handle_class_c_uplink_after_join;
|
|
||||||
diff --git a/src/lib.rs b/src/lib.rs
|
|
||||||
index ad1ddda..539a0ed 100644
|
|
||||||
--- a/src/lib.rs
|
|
||||||
+++ b/src/lib.rs
|
|
||||||
@@ -48,7 +48,7 @@ pub struct Downlink {
|
|
||||||
#[cfg(feature = "defmt")]
|
|
||||||
impl defmt::Format for Downlink {
|
|
||||||
fn format(&self, f: defmt::Formatter) {
|
|
||||||
- defmt::write!(f, "Downlink {{ fport: {}, data: ", self.fport,);
|
|
||||||
+ defmt::write!(f, "Downlink {{ fport: {}, data: ", self.fport, );
|
|
||||||
|
|
||||||
for byte in self.data.iter() {
|
|
||||||
defmt::write!(f, "{:02x}", byte);
|
|
||||||
diff --git a/src/mac/session.rs b/src/mac/session.rs
|
|
||||||
index 6ff62fa..d946a1f 100644
|
|
||||||
--- a/src/mac/session.rs
|
|
||||||
+++ b/src/mac/session.rs
|
|
||||||
@@ -60,7 +60,7 @@ impl Session {
|
|
||||||
decrypt.dev_addr().as_ref()[2],
|
|
||||||
decrypt.dev_addr().as_ref()[3],
|
|
||||||
])
|
|
||||||
- .unwrap(),
|
|
||||||
+ .unwrap(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/nb_device/test/mod.rs b/src/nb_device/test/mod.rs
|
|
||||||
index 51cd67f..0430947 100644
|
|
||||||
--- a/src/nb_device/test/mod.rs
|
|
||||||
+++ b/src/nb_device/test/mod.rs
|
|
||||||
@@ -1,7 +1,5 @@
|
|
||||||
use super::*;
|
|
||||||
mod util;
|
|
||||||
-use crate::test_util::*;
|
|
||||||
-use util::*;
|
|
||||||
|
|
||||||
use crate::nb_device::Event;
|
|
||||||
#[test]
|
|
||||||
diff --git a/src/nb_device/test/util.rs b/src/nb_device/test/util.rs
|
|
||||||
index 6d1e12c..ab676be 100644
|
|
||||||
--- a/src/nb_device/test/util.rs
|
|
||||||
+++ b/src/nb_device/test/util.rs
|
|
||||||
@@ -1,11 +1,9 @@
|
|
||||||
-use super::*;
|
|
||||||
use crate::radio::{RfConfig, RxQuality};
|
|
||||||
|
|
||||||
use crate::nb_device::{
|
|
||||||
radio::{Event, PhyRxTx, Response},
|
|
||||||
Device, Timings,
|
|
||||||
};
|
|
||||||
-use crate::test_util::*;
|
|
||||||
use lorawan::default_crypto;
|
|
||||||
use region::{Configuration, Region};
|
|
||||||
|
|
||||||
diff --git a/src/region/dynamic_channel_plans/as923.rs b/src/region/dynamic_channel_plans/as923.rs
|
|
||||||
index 4a48b67..9fb571d 100644
|
|
||||||
--- a/src/region/dynamic_channel_plans/as923.rs
|
|
||||||
+++ b/src/region/dynamic_channel_plans/as923.rs
|
|
||||||
@@ -12,7 +12,7 @@ pub(crate) type AS923_4 = DynamicChannelPlan<2, 7, AS923Region<917_300_000, 5900
|
|
||||||
pub struct AS923Region<const DEFAULT_RX2: u32, const O: u32>;
|
|
||||||
|
|
||||||
impl<const DEFAULT_RX2: u32, const OFFSET: u32> ChannelRegion<7>
|
|
||||||
- for AS923Region<DEFAULT_RX2, OFFSET>
|
|
||||||
+for AS923Region<DEFAULT_RX2, OFFSET>
|
|
||||||
{
|
|
||||||
fn datarates() -> &'static [Option<Datarate>; 7] {
|
|
||||||
&DATARATES
|
|
||||||
@@ -20,7 +20,7 @@ impl<const DEFAULT_RX2: u32, const OFFSET: u32> ChannelRegion<7>
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<const DEFAULT_RX2: u32, const OFFSET: u32> DynamicChannelRegion<2, 7>
|
|
||||||
- for AS923Region<DEFAULT_RX2, OFFSET>
|
|
||||||
+for AS923Region<DEFAULT_RX2, OFFSET>
|
|
||||||
{
|
|
||||||
fn join_channels() -> [u32; 2] {
|
|
||||||
[JOIN_CHANNELS[0] + OFFSET, JOIN_CHANNELS[1] + OFFSET]
|
|
||||||
diff --git a/src/region/dynamic_channel_plans/mod.rs b/src/region/dynamic_channel_plans/mod.rs
|
diff --git a/src/region/dynamic_channel_plans/mod.rs b/src/region/dynamic_channel_plans/mod.rs
|
||||||
index 00f9a5d..3552dce 100644
|
index 00f9a5d..33f545a 100644
|
||||||
--- a/src/region/dynamic_channel_plans/mod.rs
|
--- a/src/region/dynamic_channel_plans/mod.rs
|
||||||
+++ b/src/region/dynamic_channel_plans/mod.rs
|
+++ b/src/region/dynamic_channel_plans/mod.rs
|
||||||
@@ -46,16 +46,21 @@ pub(crate) struct DynamicChannelPlan<
|
@@ -55,7 +55,12 @@ impl<
|
||||||
}
|
|
||||||
|
|
||||||
impl<
|
|
||||||
- const NUM_JOIN_CHANNELS: usize,
|
|
||||||
- const NUM_DATARATES: usize,
|
|
||||||
- R: DynamicChannelRegion<NUM_JOIN_CHANNELS, NUM_DATARATES>,
|
|
||||||
- > DynamicChannelPlan<NUM_JOIN_CHANNELS, NUM_DATARATES, R>
|
|
||||||
+ const NUM_JOIN_CHANNELS: usize,
|
|
||||||
+ const NUM_DATARATES: usize,
|
|
||||||
+ R: DynamicChannelRegion<NUM_JOIN_CHANNELS, NUM_DATARATES>,
|
|
||||||
+> DynamicChannelPlan<NUM_JOIN_CHANNELS, NUM_DATARATES, R>
|
|
||||||
{
|
|
||||||
fn get_channel(&self, channel: usize) -> Option<u32> {
|
|
||||||
if channel < NUM_JOIN_CHANNELS {
|
if channel < NUM_JOIN_CHANNELS {
|
||||||
Some(R::join_channels()[channel])
|
Some(R::join_channels()[channel])
|
||||||
} else {
|
} else {
|
||||||
@@ -168,50 +16,3 @@ index 00f9a5d..3552dce 100644
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,17 +92,17 @@ impl<
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) trait DynamicChannelRegion<const NUM_JOIN_CHANNELS: usize, const NUM_DATARATES: usize>:
|
|
||||||
- ChannelRegion<NUM_DATARATES>
|
|
||||||
+ChannelRegion<NUM_DATARATES>
|
|
||||||
{
|
|
||||||
fn join_channels() -> [u32; NUM_JOIN_CHANNELS];
|
|
||||||
fn get_default_rx2() -> u32;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<
|
|
||||||
- const NUM_JOIN_CHANNELS: usize,
|
|
||||||
- const NUM_DATARATES: usize,
|
|
||||||
- R: DynamicChannelRegion<NUM_JOIN_CHANNELS, NUM_DATARATES>,
|
|
||||||
- > RegionHandler for DynamicChannelPlan<NUM_JOIN_CHANNELS, NUM_DATARATES, R>
|
|
||||||
+ const NUM_JOIN_CHANNELS: usize,
|
|
||||||
+ const NUM_DATARATES: usize,
|
|
||||||
+ R: DynamicChannelRegion<NUM_JOIN_CHANNELS, NUM_DATARATES>,
|
|
||||||
+> RegionHandler for DynamicChannelPlan<NUM_JOIN_CHANNELS, NUM_DATARATES, R>
|
|
||||||
{
|
|
||||||
fn process_join_accept<T: AsRef<[u8]>, C>(
|
|
||||||
&mut self,
|
|
||||||
diff --git a/src/region/fixed_channel_plans/join_channels.rs b/src/region/fixed_channel_plans/join_channels.rs
|
|
||||||
index 297cce3..d0ee5e1 100644
|
|
||||||
--- a/src/region/fixed_channel_plans/join_channels.rs
|
|
||||||
+++ b/src/region/fixed_channel_plans/join_channels.rs
|
|
||||||
@@ -330,8 +330,7 @@ mod test {
|
|
||||||
buf.clear();
|
|
||||||
buf.extend_from_slice(&rx_buf[..len]).unwrap();
|
|
||||||
let response = mac.handle_rx::<DefaultFactory, 255, 3>(&mut buf, &mut downlinks);
|
|
||||||
- if let Response::JoinSuccess = response {
|
|
||||||
- } else {
|
|
||||||
+ if let Response::JoinSuccess = response {} else {
|
|
||||||
panic!("Did not receive join success");
|
|
||||||
}
|
|
||||||
let (tx_config, _len) = mac
|
|
||||||
@@ -391,8 +390,7 @@ mod test {
|
|
||||||
buf.clear();
|
|
||||||
buf.extend_from_slice(&rx_buf[..len]).unwrap();
|
|
||||||
let response = mac.handle_rx::<DefaultFactory, 255, 3>(&mut buf, &mut downlinks);
|
|
||||||
- if let Response::JoinSuccess = response {
|
|
||||||
- } else {
|
|
||||||
+ if let Response::JoinSuccess = response {} else {
|
|
||||||
panic!("Did not receive JoinSuccess")
|
|
||||||
}
|
|
||||||
for _ in 0..8 {
|
|
||||||
|
|||||||
@@ -76,22 +76,23 @@ where
|
|||||||
let mut wcnt = [0u8; 3];
|
let mut wcnt = [0u8; 3];
|
||||||
wcnt.copy_from_slice(&wcnt_block[0][0..3]);
|
wcnt.copy_from_slice(&wcnt_block[0][0..3]);
|
||||||
|
|
||||||
|
let block_code: u16 = block_code.into();
|
||||||
let maca_block_code: u16 = FelicaLiteSBlock::MACA.clone().into();
|
let maca_block_code: u16 = FelicaLiteSBlock::MACA.clone().into();
|
||||||
|
|
||||||
let mut plain = heapless::Vec::<u8, 24>::new();
|
let mut plain = [0u8; 24];
|
||||||
plain.extend(wcnt);
|
plain[0..3].copy_from_slice(&wcnt);
|
||||||
plain.push(block_code.clone().into() as u8).unwrap();
|
plain[4] = block_code as u8;
|
||||||
plain.push(maca_block_code as u8).unwrap();
|
plain[6] = maca_block_code as u8;
|
||||||
plain.extend(*data);
|
plain[8..24].copy_from_slice(data);
|
||||||
|
|
||||||
let mac = self.compute_write_mac(session, plain.into_array().unwrap());
|
let mac = self.compute_write_mac(session, plain);
|
||||||
|
|
||||||
let mut mac_a = heapless::Vec::<u8, 16>::new();
|
let mut mac_a = [0u8; 16];
|
||||||
mac_a.extend(mac);
|
mac_a[0..8].copy_from_slice(&mac);
|
||||||
mac_a.extend(wcnt);
|
mac_a[8..11].copy_from_slice(&wcnt);
|
||||||
|
|
||||||
let block_list = [block_code.into(), FelicaLiteSBlock::MACA as u16];
|
let block_list = [block_code, FelicaLiteSBlock::MACA as u16];
|
||||||
let block_data = [*data, mac_a.into_array().unwrap()];
|
let block_data = [*data, mac_a];
|
||||||
self.write_block(card, block_list, &block_data)
|
self.write_block(card, block_list, &block_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use embassy_time::{Delay, Timer};
|
|||||||
use esp_hal::gpio;
|
use esp_hal::gpio;
|
||||||
use esp_hal::rng::Trng;
|
use esp_hal::rng::Trng;
|
||||||
use pn532::types::felica::felica_lite_s::auth::{CardKey, CardKeyVersion};
|
use pn532::types::felica::felica_lite_s::auth::{CardKey, CardKeyVersion};
|
||||||
use pn532::types::felica::felica_lite_s::config::{MemoryConfig, RFParameter};
|
use pn532::types::felica::felica_lite_s::config::RFParameter;
|
||||||
use pn532::types::felica::{CardSession, FelicaLiteSBlock};
|
use pn532::types::felica::{CardSession, FelicaLiteSBlock};
|
||||||
use pn532::Pn532;
|
use pn532::Pn532;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user