Skip to content

Commit

Permalink
Refactor APP config management
Browse files Browse the repository at this point in the history
- Move enum definitions to uci_packets.pdl
- Move AppConfig declaration to separate module
  for readability
- Sync APP config definitions with UCI 2.0
  • Loading branch information
hchataing committed Mar 4, 2024
1 parent a28b52a commit 6884c0e
Show file tree
Hide file tree
Showing 8 changed files with 1,354 additions and 786 deletions.
484 changes: 456 additions & 28 deletions py/pica/pica/packets/uci.py

Large diffs are not rendered by default.

498 changes: 498 additions & 0 deletions src/app_config.rs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ use session::MAX_SESSION;
mod mac_address;
pub use mac_address::MacAddress;

use crate::session::RangeDataNtfConfig;
mod app_config;
pub use app_config::AppConfig;

pub type UciPacket = Vec<u8>;

Expand Down Expand Up @@ -285,7 +286,7 @@ impl Pica {
let mut uci_reader = packets::uci::Reader::new(uci_rx);
let mut uci_writer = packets::uci::Writer::new(uci_tx);

tokio::try_join!(
let _ = tokio::try_join!(
async {
loop {
// Read UCI packets sent from connected UWB host.
Expand All @@ -311,8 +312,7 @@ impl Pica {
}
}
}
)
.unwrap();
);

pica_tx
.send(PicaCommand::Disconnect(device_handle))
Expand Down Expand Up @@ -343,7 +343,7 @@ impl Pica {
let mut measurements = Vec::new();
let mut peer_device_data_transfer = Vec::new();
session
.get_dst_mac_addresses()
.get_dst_mac_address()
.iter()
.for_each(|mac_address| {
if let Some(other) = self.anchors.get(mac_address) {
Expand Down Expand Up @@ -397,7 +397,7 @@ impl Pica {
)
.unwrap();
}
if session.is_ranging_data_ntf_enabled() != RangeDataNtfConfig::Disable {
if session.is_session_info_ntf_enabled() {
device
.tx
.send(
Expand Down
15 changes: 15 additions & 0 deletions src/mac_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ impl From<MacAddress> for u64 {
}
}

impl From<&MacAddress> for Vec<u8> {
fn from(mac_address: &MacAddress) -> Self {
match mac_address {
MacAddress::Short(addr) => addr.to_vec(),
MacAddress::Extended(addr) => addr.to_vec(),
}
}
}

impl From<MacAddress> for Vec<u8> {
fn from(mac_address: MacAddress) -> Self {
Vec::<u8>::from(&mac_address)
}
}

impl TryFrom<String> for MacAddress {
type Error = Error;
fn try_from(mac_address: String) -> std::result::Result<Self, Error> {
Expand Down
Loading

0 comments on commit 6884c0e

Please sign in to comment.