Skip to content

Commit

Permalink
Handle AppConfigs required from Fira 2.0 spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobwzy committed Jan 22, 2024
1 parent 631139a commit 147376b
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 4 deletions.
44 changes: 42 additions & 2 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,27 @@ pub enum RangeDataNtfConfig {
EnableAoaEdgeTrig = 0x06,
EnableProximityAoaEdgeTrig = 0x07,
}

#[derive(Copy, Clone, FromPrimitive, ToPrimitive, PartialEq)]
#[repr(u8)]
pub enum LinkLayerMode {
Bypass = 0x00,
Assigned = 0x01,
}

#[derive(Copy, Clone, FromPrimitive, ToPrimitive, PartialEq)]
#[repr(u8)]
pub enum DataRepetitionCount {
NoRepetition = 0x00,
Infinite = 0xFF,
}

#[derive(Copy, Clone, FromPrimitive, ToPrimitive, PartialEq)]
#[repr(u8)]
pub enum SessionDataTransferStatusNtfConfig {
Disable = 0x00,
Enable = 0x01,
}
/// cf. [UCI] 8.3 Table 29
#[derive(Clone)]
pub struct AppConfig {
Expand Down Expand Up @@ -282,12 +303,16 @@ pub struct AppConfig {
bprf_phr_data_rate: BprfPhrDataRate,
max_number_of_measurements: u8,
sts_length: StsLength,
uwb_initiation_time: u32,
uwb_initiation_time: u64,
vendor_id: Option<Vec<u8>>,
static_sts_iv: Option<Vec<u8>>,
session_key: Option<Vec<u8>>,
sub_session_key: Option<Vec<u8>>,
sub_session_id: u32,
link_layer_mode: LinkLayerMode,
data_repetition_count: DataRepetitionCount,
session_data_transfer_status_ntf_config: SessionDataTransferStatusNtfConfig,
application_data_endpoint: u8,
}

impl Default for AppConfig {
Expand Down Expand Up @@ -341,6 +366,10 @@ impl Default for AppConfig {
session_key: None,
sub_session_key: None,
sub_session_id: 0,
link_layer_mode: LinkLayerMode::Bypass,
data_repetition_count: DataRepetitionCount::NoRepetition,
session_data_transfer_status_ntf_config: SessionDataTransferStatusNtfConfig::Disable,
application_data_endpoint: 0,
}
}
}
Expand Down Expand Up @@ -545,7 +574,7 @@ impl AppConfig {
self.max_rr_retry = u16::from_le_bytes(value[..].try_into().unwrap())
}
AppConfigTlvType::UwbInitiationTime => {
self.uwb_initiation_time = u32::from_le_bytes(value[..].try_into().unwrap())
self.uwb_initiation_time = u64::from_le_bytes(value[..].try_into().unwrap())
}
AppConfigTlvType::HoppingMode => {
self.hopping_mode = HoppingMode::from_u8(value[0]).unwrap()
Expand All @@ -571,6 +600,17 @@ impl AppConfig {
self.sub_session_id = u32::from_le_bytes(value[..].try_into().unwrap())
}
AppConfigTlvType::SubsessionKey => self.sub_session_key = Some(value.to_vec()),
AppConfigTlvType::LinkLayerMode => {
self.link_layer_mode = LinkLayerMode::from_u8(value[0]).unwrap()
}
AppConfigTlvType::DataRepetitionCount => {
self.data_repetition_count = DataRepetitionCount::from_u8(value[0]).unwrap()
}
AppConfigTlvType::SessionDataTransferStatusNtfConfig => {
self.session_data_transfer_status_ntf_config =
SessionDataTransferStatusNtfConfig::from_u8(value[0]).unwrap()
}
AppConfigTlvType::ApplicationDataEndpoint => self.application_data_endpoint = value[0],
id => {
println!("Ignored AppConfig parameter {:?}", id);
return Err(StatusCode::UciStatusInvalidParam);
Expand Down
94 changes: 94 additions & 0 deletions src/tmp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
SendUciCommand { cmd: SessionSetAppConfig { session_token: 1, config_tlvs: [
AppConfigTlv { cfg_id: RangingRoundUsage, v: [2] },
AppConfigTlv { cfg_id: StsConfig, v: [0] },
AppConfigTlv { cfg_id: MultiNodeMode, v: [1] },
AppConfigTlv { cfg_id: ChannelNumber, v: [9] },
AppConfigTlv { cfg_id: DeviceMacAddress, v: [5, 6] },
AppConfigTlv { cfg_id: SlotDuration, v: [96, 9] },
AppConfigTlv { cfg_id: MacFcsType, v: [0] },
AppConfigTlv { cfg_id: RangingRoundControl, v: [3] },
AppConfigTlv { cfg_id: AoaResultReq, v: [1] },
AppConfigTlv { cfg_id: RngDataNtf, v: [1] },
AppConfigTlv { cfg_id: RngDataNtfProximityNear, v: [0, 0] },
AppConfigTlv { cfg_id: RngDataNtfProximityFar, v: [32, 78] },
AppConfigTlv { cfg_id: DeviceRole, v: [1] },
AppConfigTlv { cfg_id: RframeConfig, v: [3] },
AppConfigTlv { cfg_id: RssiReporting, v: [1] },
AppConfigTlv { cfg_id: PreambleCodeIndex, v: [10] },
AppConfigTlv { cfg_id: SfdId, v: [2] },
AppConfigTlv { cfg_id: PsduDataRate, v: [0] },
AppConfigTlv { cfg_id: PreambleDuration, v: [1] },
AppConfigTlv { cfg_id: RangingTimeStruct, v: [1] },
AppConfigTlv { cfg_id: SlotsPerRr, v: [25] },
AppConfigTlv { cfg_id: PrfMode, v: [0] },
AppConfigTlv { cfg_id: ScheduledMode, v: [1] },
AppConfigTlv { cfg_id: KeyRotation, v: [0] },
AppConfigTlv { cfg_id: KeyRotationRate, v: [0] },
AppConfigTlv { cfg_id: SessionPriority, v: [60] },
AppConfigTlv { cfg_id: MacAddressMode, v: [0] },
AppConfigTlv { cfg_id: NumberOfStsSegments, v: [1] },
AppConfigTlv { cfg_id: MaxRrRetry, v: [0, 0] },
AppConfigTlv { cfg_id: HoppingMode, v: [0] },
AppConfigTlv { cfg_id: BlockStrideLength, v: [0] },
AppConfigTlv { cfg_id: ResultReportConfig, v: [1] },
AppConfigTlv { cfg_id: InBandTerminationAttemptCount, v: [1] },
AppConfigTlv { cfg_id: BprfPhrDataRate, v: [0] },
AppConfigTlv { cfg_id: MaxNumberOfMeasurements, v: [0, 0] },
AppConfigTlv { cfg_id: StsLength, v: [1] },
AppConfigTlv { cfg_id: RangingDuration, v: [200, 0, 0, 0] },
AppConfigTlv { cfg_id: DeviceType, v: [1] },
AppConfigTlv { cfg_id: NoOfControlee, v: [1] },
AppConfigTlv { cfg_id: DstMacAddress, v: [5, 7] },
AppConfigTlv { cfg_id: UwbInitiationTime, v: [0, 0, 0, 0, 0, 0, 0, 0] },
AppConfigTlv { cfg_id: LinkLayerMode, v: [0] },
AppConfigTlv { cfg_id: DataRepetitionCount, v: [0] },
AppConfigTlv { cfg_id: SessionDataTransferStatusNtfConfig, v: [0] },
AppConfigTlv { cfg_id: RfuAppCfgTlvTypeRange3(Private(76)), v: [0] },
AppConfigTlv { cfg_id: VendorId, v: "redacted" },
AppConfigTlv { cfg_id: StaticStsIv, v: "redacted" }] } }

uwb_core::uci::uci_manager: Received cmd: SendUciCommand { cmd: SessionSetAppConfig { session_token: 1, config_tlvs: [
AppConfigTlv { cfg_id: RangingRoundUsage, v: [2] },
AppConfigTlv { cfg_id: StsConfig, v: [0] },
AppConfigTlv { cfg_id: MultiNodeMode, v: [1] },
AppConfigTlv { cfg_id: ChannelNumber, v: [9] },
AppConfigTlv { cfg_id: DeviceMacAddress, v: [5, 6] },
AppConfigTlv { cfg_id: SlotDuration, v: [96, 9] },
AppConfigTlv { cfg_id: MacFcsType, v: [0] },
AppConfigTlv { cfg_id: RangingRoundControl, v: [3] },
AppConfigTlv { cfg_id: AoaResultReq, v: [1] },
AppConfigTlv { cfg_id: RngDataNtf, v: [1] },
AppConfigTlv { cfg_id: RngDataNtfProximityNear, v: [0, 0] },
AppConfigTlv { cfg_id: RngDataNtfProximityFar, v: [32, 78] },
AppConfigTlv { cfg_id: DeviceRole, v: [1] },
AppConfigTlv { cfg_id: RframeConfig, v: [3] },
AppConfigTlv { cfg_id: RssiReporting, v: [1] },
AppConfigTlv { cfg_id: PreambleCodeIndex, v: [10] },
AppConfigTlv { cfg_id: SfdId, v: [2] },
AppConfigTlv { cfg_id: PsduDataRate, v: [0] },
AppConfigTlv { cfg_id: PreambleDuration, v: [1] },
AppConfigTlv { cfg_id: RangingTimeStruct, v: [1] },
AppConfigTlv { cfg_id: SlotsPerRr, v: [25] },
AppConfigTlv { cfg_id: PrfMode, v: [0] },
AppConfigTlv { cfg_id: ScheduledMode, v: [1] },
AppConfigTlv { cfg_id: KeyRotation, v: [0] },
AppConfigTlv { cfg_id: KeyRotationRate, v: [0] },
AppConfigTlv { cfg_id: SessionPriority, v: [60] },
AppConfigTlv { cfg_id: MacAddressMode, v: [0] },
AppConfigTlv { cfg_id: NumberOfStsSegments, v: [1] },
AppConfigTlv { cfg_id: MaxRrRetry, v: [0, 0] },
AppConfigTlv { cfg_id: HoppingMode, v: [0] },
AppConfigTlv { cfg_id: BlockStrideLength, v: [0] },
AppConfigTlv { cfg_id: ResultReportConfig, v: [1] },
AppConfigTlv { cfg_id: InBandTerminationAttemptCount, v: [1] },
AppConfigTlv { cfg_id: BprfPhrDataRate, v: [0] },
AppConfigTlv { cfg_id: MaxNumberOfMeasurements, v: [0, 0] },
AppConfigTlv { cfg_id: StsLength, v: [1] },
AppConfigTlv { cfg_id: RangingDuration, v: [200, 0, 0, 0] },
AppConfigTlv { cfg_id: DeviceType, v: [1] },
AppConfigTlv { cfg_id: NoOfControlee, v: [1] },
AppConfigTlv { cfg_id: DstMacAddress, v: [5, 7] },
AppConfigTlv { cfg_id: UwbInitiationTime, v: [0, 0, 0, 0] },
AppConfigTlv { cfg_id: TxAdaptivePayloadPower, v: [0] },
AppConfigTlv { cfg_id: VendorId, v: "redacted" },
AppConfigTlv { cfg_id: StaticStsIv, v: "redacted" }] } }
18 changes: 16 additions & 2 deletions src/uci_packets.pdl
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ enum AppConfigTlvType : 8 {
RESPONDER_SLOT_INDEX = 0x1E,
PRF_MODE = 0x1F,
CAP_SIZE_RANGE = 0x20,
TX_JITTER_WINDOW_SIZE = 0x21,
SCHEDULED_MODE = 0x22,
KEY_ROTATION = 0x23,
KEY_ROTATION_RATE = 0x24,
Expand Down Expand Up @@ -261,11 +262,24 @@ enum AppConfigTlvType : 8 {
MIN_FRAMES_PER_RR = 0x3A,
MTU_SIZE = 0x3B,
INTER_FRAME_INTERVAL = 0x3C,
RFU_APP_CFG_TLV_TYPE_RANGE_1 = 0x3D..0x44,
DL_TDOA_RANGING_METHOD = 0x3D,
DL_TDOA_TX_TIMESTAMP_CONF = 0x3E,
DL_TDOA_HOP_COUNT = 0x3F,
DL_TDOA_ANCHOR_CFO = 0x40,
DL_TDOA_ANCHOR_LOCATION = 0x41,
DL_TDOA_TX_ACTIVE_RANGING_ROUNDS = 0x42,
DL_TDOA_BLOCK_STRIDING = 0x43,
DL_TDOA_TIME_REFERENCE_ANCHOR = 0x44,
SESSION_KEY = 0x45,
SUBSESSION_KEY = 0x46,
SESSION_DATA_TRANSFER_STATUS_NTF_CONFIG = 0x47,
RFU_APP_CFG_TLV_TYPE_RANGE_2 = 0x48..0x9F,
SESSION_TIME_BASE = 0x48,
DL_TDOA_RESPONDER_TOF = 0x49,
SECURE_RANGING_NEFA_LEVEL = 0x4A,
SECURE_RANGING_CSW_LENGTH = 0x4B,
APPLICATION_DATA_ENDPOINT = 0x4C,
OWR_AOA_MEASUREMENT_NTF_PERIOD = 0x4D,
RFU_APP_CFG_TLV_TYPE_RANGE = 0x4E..0x9F,

VENDOR_SPECIFIC_APP_CFG_TLV_TYPE_RANGE_1 = 0xA0..0xDF {
// CCC specific
Expand Down

0 comments on commit 147376b

Please sign in to comment.