Although this library are built by Android build system officially, we can also build and test the library by cargo.
uwb_uci_packets
packageThe uwb_uci_packets
package depends on pdlc and thus simply using
cargo build` will fail. Follow the steps below before using cargo.
source build/make/rbesetup.sh; lunch <target>
m pdlc
to compile the pdlc
Rust binary.After that, we could build or test the package by cargo test --features proto
.
When debugging a certain test case, we could enable the logging and run the single test case.
crate::utils::init_test_logging();
at the beginning of the test caseRUST_LOG=debug cargo test -p uwb_core <test_case_name> -- --nocapture
This section describes the main modules of this library. The modules below are listed in reversed topological order.
The uwb_uci_packets
crate is aimed for encoding and decoding the UCI packets. All the details of the UCI packet format should be encapsulated here. That means, the client of this crate should not be aware of how the UCI messages are constructed to or parsed from raw byte buffers.
The crate is mainly generated from the PDL file. However, in the case where a UCI feature cannot be achieved using PDL alone, a workaround should be created inside this crate to complete this feature (i.e. define structs and implement the parsing methods manually) to encapsulate the details of UCI packet format.
Note that the interface of the workaround should be as close to PDL-generated code as possible.
The params modules defines the parameters types, including UCI, FiRa, and CCC specification.
This module depends on the uwb_uci_packets
crate. To prevent the client of this module directly depending on the uwb_uci_packets
crate, we re-expose all the needed enums and structs at params/uci_packets.rs
.
The uci
module is aimed to provide a rust-idiomatic way that implements the UCI interface, such as:
According to the asynchronous nature of the UCI interface, the UciManager
struct provides asynchronous methods using the actor model. For easier usage, the UciManagerSync
struct works as a thin synchronous wrapper.
This module depends on the params
module.
The session
module implements the ranging session-related logic. We support the FiRa and CCC specification here.
This module depends on the params
and UCI
modules.
The service
module is aimed to provide a “top-shim”, the main entry of this library. Similar to the UciManagerSync
, the UwbService
struct provides a simple synchronous interface to the client of the library. examples/main.rs
is a simple example for using the UwbService
struct.
If we want to provide the UWB across the process or language boundary, then ProtoUwbService
provices a simple wrapper that converts all the arguments and responses to protobuf-encoded byte buffers.
The service
module depends on params
, uci
, and session
modules.