Parse all Rx SESSION_STATUS_NTF.ReasonCode(s).
1) The SESSION_STATUS_NTF has a State Change with Reason Code field, which contains a Vendor specific space (0x80-0xFF). Currently packet parsing fails when a value is received in this range (as the value is not present in the PDL ReasonCode enum).
2) Add definitions for the new ReasonCode values defined in the UCI spec.
Test: atest libuwb_core_test libuwb_uci_packet_tests libuwb_uci_jni_rust_tests, new unit test with ReasonCode value in Vendor Specific space passes.
Bug: 270575596
Change-Id: I8a89db728271075683167d7c15cd573ce9913884
diff --git a/src/rust/uwb_core/protos/uwb_service.proto b/src/rust/uwb_core/protos/uwb_service.proto
index 17cc421..0f99fef 100644
--- a/src/rust/uwb_core/protos/uwb_service.proto
+++ b/src/rust/uwb_core/protos/uwb_service.proto
@@ -132,13 +132,44 @@
STATE_CHANGE_WITH_SESSION_MANAGEMENT_COMMANDS = 0;
MAX_RANGING_ROUND_RETRY_COUNT_REACHED = 1;
MAX_NUMBER_OF_MEASUREMENTS_REACHED = 2;
+ SESSION_SUSPENDED_DUE_TO_INBAND_SIGNAL = 3;
+ SESSION_RESUMED_DUE_TO_INBAND_SIGNAL = 4;
+ SESSION_STOPPED_DUE_TO_INBAND_SIGNAL = 5;
ERROR_INVALID_UL_TDOA_RANDOM_WINDOW = 29;
+ ERROR_MIN_RFRAMES_PER_RR_NOT_SUPPORTED = 30;
+ ERROR_TX_DELAY_NOT_SUPPORTED = 31;
ERROR_SLOT_LENGTH_NOT_SUPPORTED = 32;
ERROR_INSUFFICIENT_SLOTS_PER_RR = 33;
ERROR_MAC_ADDRESS_MODE_NOT_SUPPORTED = 34;
- ERROR_INVALID_RANGING_INTERVAL = 35;
+ ERROR_INVALID_RANGING_DURATION = 35;
ERROR_INVALID_STS_CONFIG = 36;
ERROR_INVALID_RFRAME_CONFIG = 37;
+ ERROR_HUS_NOT_ENOUGH_SLOTS = 38;
+ ERROR_HUS_CFP_PHASE_TOO_SHORT = 39;
+ ERROR_HUS_CAP_PHASE_TOO_SHORT = 40;
+ ERROR_HUS_OTHERS = 41;
+ ERROR_STATUS_SESSION_KEY_NOT_FOUND = 42;
+ ERROR_STATUS_SUB_SESSION_KEY_NOT_FOUND = 43;
+ ERROR_INVALID_PREAMBLE_CODE_INDEX = 44;
+ ERROR_INVALID_SFD_ID = 45;
+ ERROR_INVALID_PSDU_DATA_RATE = 46;
+ ERROR_INVALID_PHR_DATA_RATE = 47;
+ ERROR_INVALID_PREAMBLE_DURATION = 48;
+ ERROR_INVALID_STS_LENGTH = 49;
+ ERROR_INVALID_NUM_OF_STS_SEGMENTS = 50;
+ ERROR_INVALID_NUM_OF_CONTROLEES = 51;
+ ERROR_MAX_RANGING_REPLY_TIME_EXCEEDED = 52;
+ ERROR_INVALID_DST_ADDRESS_LIST = 53;
+ ERROR_INVALID_OR_NOT_FOUND_SUB_SESSION_ID = 54;
+ ERROR_INVALID_RESULT_REPORT_CONFIG = 55;
+ ERROR_INVALID_RANGING_ROUND_CONTROL_CONFIG = 56;
+ ERROR_INVALID_RANGING_ROUND_USAGE = 57;
+ ERROR_INVALID_MULTI_NODE_MODE = 58;
+ ERROR_RDS_FETCH_FAILURE = 59;
+ ERROR_REF_UWB_SESSION_DOES_NOT_EXIST = 60;
+ ERROR_REF_UWB_SESSION_RANGING_DURATION_MISMATCH = 61;
+ ERROR_REF_UWB_SESSION_INVALID_OFFSET_TIME = 62;
+ ERROR_REF_UWB_SESSION_LOST = 63;
ERROR_INVALID_CHANNEL_WITH_AOA = 128;
ERROR_STOPPED_DUE_TO_OTHER_SESSION_CONFLICT = 129;
}
diff --git a/src/rust/uwb_core/src/proto/mappings.rs b/src/rust/uwb_core/src/proto/mappings.rs
index b07ad57..328b675 100644
--- a/src/rust/uwb_core/src/proto/mappings.rs
+++ b/src/rust/uwb_core/src/proto/mappings.rs
@@ -174,13 +174,44 @@
STATE_CHANGE_WITH_SESSION_MANAGEMENT_COMMANDS => StateChangeWithSessionManagementCommands,
MAX_RANGING_ROUND_RETRY_COUNT_REACHED => MaxRangingRoundRetryCountReached,
MAX_NUMBER_OF_MEASUREMENTS_REACHED => MaxNumberOfMeasurementsReached,
+ SESSION_SUSPENDED_DUE_TO_INBAND_SIGNAL => SessionSuspendedDueToInbandSignal,
+ SESSION_RESUMED_DUE_TO_INBAND_SIGNAL => SessionResumedDueToInbandSignal,
+ SESSION_STOPPED_DUE_TO_INBAND_SIGNAL => SessionStoppedDueToInbandSignal,
ERROR_INVALID_UL_TDOA_RANDOM_WINDOW => ErrorInvalidUlTdoaRandomWindow,
+ ERROR_MIN_RFRAMES_PER_RR_NOT_SUPPORTED => ErrorMinRframesPerRrNotSupported,
+ ERROR_TX_DELAY_NOT_SUPPORTED => ErrorTxDelayNotSupported,
ERROR_SLOT_LENGTH_NOT_SUPPORTED => ErrorSlotLengthNotSupported,
ERROR_INSUFFICIENT_SLOTS_PER_RR => ErrorInsufficientSlotsPerRr,
ERROR_MAC_ADDRESS_MODE_NOT_SUPPORTED => ErrorMacAddressModeNotSupported,
- ERROR_INVALID_RANGING_INTERVAL => ErrorInvalidRangingInterval,
+ ERROR_INVALID_RANGING_DURATION => ErrorInvalidRangingDuration,
ERROR_INVALID_STS_CONFIG => ErrorInvalidStsConfig,
ERROR_INVALID_RFRAME_CONFIG => ErrorInvalidRframeConfig,
+ ERROR_HUS_NOT_ENOUGH_SLOTS => ErrorHusNotEnoughSlots,
+ ERROR_HUS_CFP_PHASE_TOO_SHORT => ErrorHusCfpPhaseTooShort,
+ ERROR_HUS_CAP_PHASE_TOO_SHORT => ErrorHusCapPhaseTooShort,
+ ERROR_HUS_OTHERS => ErrorHusOthers,
+ ERROR_STATUS_SESSION_KEY_NOT_FOUND => ErrorStatusSessionKeyNotFound,
+ ERROR_STATUS_SUB_SESSION_KEY_NOT_FOUND => ErrorStatusSubSessionKeyNotFound,
+ ERROR_INVALID_PREAMBLE_CODE_INDEX => ErrorInvalidPreambleCodeIndex,
+ ERROR_INVALID_SFD_ID => ErrorInvalidSfdId,
+ ERROR_INVALID_PSDU_DATA_RATE => ErrorInvalidPsduDataRate,
+ ERROR_INVALID_PHR_DATA_RATE => ErrorInvalidPhrDataRate,
+ ERROR_INVALID_PREAMBLE_DURATION => ErrorInvalidPreambleDuration,
+ ERROR_INVALID_STS_LENGTH => ErrorInvalidStsLength,
+ ERROR_INVALID_NUM_OF_STS_SEGMENTS => ErrorInvalidNumOfStsSegments,
+ ERROR_INVALID_NUM_OF_CONTROLEES => ErrorInvalidNumOfControlees,
+ ERROR_MAX_RANGING_REPLY_TIME_EXCEEDED => ErrorMaxRangingReplyTimeExceeded,
+ ERROR_INVALID_DST_ADDRESS_LIST => ErrorInvalidDstAddressList,
+ ERROR_INVALID_OR_NOT_FOUND_SUB_SESSION_ID => ErrorInvalidOrNotFoundSubSessionId,
+ ERROR_INVALID_RESULT_REPORT_CONFIG => ErrorInvalidResultReportConfig,
+ ERROR_INVALID_RANGING_ROUND_CONTROL_CONFIG => ErrorInvalidRangingRoundControlConfig,
+ ERROR_INVALID_RANGING_ROUND_USAGE => ErrorInvalidRangingRoundUsage,
+ ERROR_INVALID_MULTI_NODE_MODE => ErrorInvalidMultiNodeMode,
+ ERROR_RDS_FETCH_FAILURE => ErrorRdsFetchFailure,
+ ERROR_REF_UWB_SESSION_DOES_NOT_EXIST => ErrorRefUwbSessionDoesNotExist,
+ ERROR_REF_UWB_SESSION_RANGING_DURATION_MISMATCH => ErrorRefUwbSessionRangingDurationMismatch,
+ ERROR_REF_UWB_SESSION_INVALID_OFFSET_TIME => ErrorRefUwbSessionInvalidOffsetTime,
+ ERROR_REF_UWB_SESSION_LOST => ErrorRefUwbSessionLost,
ERROR_INVALID_CHANNEL_WITH_AOA => ErrorInvalidChannelWithAoa,
ERROR_STOPPED_DUE_TO_OTHER_SESSION_CONFLICT => ErrorStoppedDueToOtherSessionConflict,
}
diff --git a/src/rust/uwb_core/src/session/session_manager.rs b/src/rust/uwb_core/src/session/session_manager.rs
index c525e07..3b08b52 100644
--- a/src/rust/uwb_core/src/session/session_manager.rs
+++ b/src/rust/uwb_core/src/session/session_manager.rs
@@ -26,6 +26,7 @@
use crate::uci::notification::{SessionNotification as UciSessionNotification, SessionRangeData};
use crate::uci::uci_manager::UciManager;
use crate::utils::clean_mpsc_receiver;
+use num_traits::FromPrimitive;
const MAX_SESSION_COUNT: usize = 5;
@@ -295,6 +296,16 @@
fn handle_uci_notification(&mut self, notf: UciSessionNotification) {
match notf {
UciSessionNotification::Status { session_id, session_state, reason_code } => {
+ let reason_code = match ReasonCode::from_u8(reason_code) {
+ Some(r) => r,
+ None => {
+ error!(
+ "Received unknown reason_code {:?} in UciSessionNotification",
+ reason_code
+ );
+ return;
+ }
+ };
if session_state == SessionState::SessionStateDeinit {
debug!("Session {} is deinitialized", session_id);
let _ = self.active_sessions.remove(&session_id);
@@ -435,6 +446,7 @@
use crate::uci::mock_uci_manager::MockUciManager;
use crate::uci::notification::{RangingMeasurements, UciNotification};
use crate::utils::init_test_logging;
+ use num_traits::ToPrimitive;
pub(crate) fn generate_params() -> AppConfigParams {
FiraAppConfigParamsBuilder::new()
@@ -504,7 +516,7 @@
UciNotification::Session(UciSessionNotification::Status {
session_id,
session_state,
- reason_code: ReasonCode::StateChangeWithSessionManagementCommands,
+ reason_code: ReasonCode::StateChangeWithSessionManagementCommands.to_u8().unwrap(),
})
}
@@ -545,7 +557,7 @@
use crate::params::ccc_started_app_config_params::CccStartedAppConfigParams;
use crate::params::uci_packets::{
AppConfigTlv, AppConfigTlvType, ControleeStatus, Controlees, MulticastUpdateStatusCode,
- SetAppConfigResponse, StatusCode,
+ ReasonCode, SetAppConfigResponse, StatusCode,
};
use crate::params::utils::{u32_to_bytes, u64_to_bytes, u8_to_bytes};
use crate::params::{FiraAppConfigParamsBuilder, KeyRotation};
diff --git a/src/rust/uwb_core/src/uci/notification.rs b/src/rust/uwb_core/src/uci/notification.rs
index 6acc55e..4438f83 100644
--- a/src/rust/uwb_core/src/uci/notification.rs
+++ b/src/rust/uwb_core/src/uci/notification.rs
@@ -24,7 +24,7 @@
ControleeStatus, CreditAvailability, DataRcvStatusCode, DataTransferNtfStatusCode, DeviceState,
ExtendedAddressDlTdoaRangingMeasurement, ExtendedAddressOwrAoaRangingMeasurement,
ExtendedAddressTwoWayRangingMeasurement, FiraComponent, RangingMeasurementType, RawUciMessage,
- ReasonCode, SessionId, SessionState, ShortAddressDlTdoaRangingMeasurement,
+ SessionId, SessionState, ShortAddressDlTdoaRangingMeasurement,
ShortAddressOwrAoaRangingMeasurement, ShortAddressTwoWayRangingMeasurement, StatusCode,
};
@@ -58,7 +58,7 @@
/// uwb_uci_packets::SessionState.
session_state: SessionState,
/// uwb_uci_packets::Reasoncode.
- reason_code: ReasonCode,
+ reason_code: u8,
},
/// SessionUpdateControllerMulticastListNtf equivalent.
UpdateControllerMulticastList {
@@ -727,7 +727,9 @@
let session_status_ntf = uwb_uci_packets::SessionStatusNtfBuilder {
session_id: 0x20,
session_state: uwb_uci_packets::SessionState::SessionStateActive,
- reason_code: uwb_uci_packets::ReasonCode::StateChangeWithSessionManagementCommands,
+ reason_code: uwb_uci_packets::ReasonCode::StateChangeWithSessionManagementCommands
+ .to_u8()
+ .unwrap(),
}
.build();
let session_notification_packet =
@@ -741,7 +743,9 @@
UciNotification::Session(SessionNotification::Status {
session_id: 0x20,
session_state: uwb_uci_packets::SessionState::SessionStateActive,
- reason_code: uwb_uci_packets::ReasonCode::StateChangeWithSessionManagementCommands,
+ reason_code: uwb_uci_packets::ReasonCode::StateChangeWithSessionManagementCommands
+ .to_u8()
+ .unwrap(),
})
);
}
diff --git a/src/rust/uwb_core/src/uci/uci_manager.rs b/src/rust/uwb_core/src/uci/uci_manager.rs
index 709df2f..aa2ac51 100644
--- a/src/rust/uwb_core/src/uci/uci_manager.rs
+++ b/src/rust/uwb_core/src/uci/uci_manager.rs
@@ -1317,7 +1317,9 @@
session_id,
session_state: uwb_uci_packets::SessionState::SessionStateInit,
reason_code:
- uwb_uci_packets::ReasonCode::StateChangeWithSessionManagementCommands,
+ uwb_uci_packets::ReasonCode::StateChangeWithSessionManagementCommands
+ .to_u8()
+ .unwrap(),
});
resp.append(&mut notf);
diff --git a/src/rust/uwb_uci_packets/uci_packets.pdl b/src/rust/uwb_uci_packets/uci_packets.pdl
index 8d807fb..78b9aa1 100644
--- a/src/rust/uwb_uci_packets/uci_packets.pdl
+++ b/src/rust/uwb_uci_packets/uci_packets.pdl
@@ -337,13 +337,46 @@
STATE_CHANGE_WITH_SESSION_MANAGEMENT_COMMANDS = 0x00,
MAX_RANGING_ROUND_RETRY_COUNT_REACHED = 0x01,
MAX_NUMBER_OF_MEASUREMENTS_REACHED = 0x02,
+ SESSION_SUSPENDED_DUE_TO_INBAND_SIGNAL = 0x03,
+ SESSION_RESUMED_DUE_TO_INBAND_SIGNAL = 0x04,
+ SESSION_STOPPED_DUE_TO_INBAND_SIGNAL = 0x05,
ERROR_INVALID_UL_TDOA_RANDOM_WINDOW = 0x1D,
+ ERROR_MIN_RFRAMES_PER_RR_NOT_SUPPORTED = 0x1E,
+ ERROR_TX_DELAY_NOT_SUPPORTED = 0x1F,
ERROR_SLOT_LENGTH_NOT_SUPPORTED = 0x20,
ERROR_INSUFFICIENT_SLOTS_PER_RR = 0x21,
ERROR_MAC_ADDRESS_MODE_NOT_SUPPORTED = 0x22,
- ERROR_INVALID_RANGING_INTERVAL = 0x23,
+ ERROR_INVALID_RANGING_DURATION = 0x23,
ERROR_INVALID_STS_CONFIG = 0x24,
ERROR_INVALID_RFRAME_CONFIG = 0x25,
+ ERROR_HUS_NOT_ENOUGH_SLOTS = 0x26,
+ ERROR_HUS_CFP_PHASE_TOO_SHORT = 0x27,
+ ERROR_HUS_CAP_PHASE_TOO_SHORT = 0x28,
+ ERROR_HUS_OTHERS = 0x29,
+ ERROR_STATUS_SESSION_KEY_NOT_FOUND = 0x2A,
+ ERROR_STATUS_SUB_SESSION_KEY_NOT_FOUND = 0x2B,
+ ERROR_INVALID_PREAMBLE_CODE_INDEX = 0x2C,
+ ERROR_INVALID_SFD_ID = 0x2D,
+ ERROR_INVALID_PSDU_DATA_RATE = 0x2E,
+ ERROR_INVALID_PHR_DATA_RATE = 0x2F,
+ ERROR_INVALID_PREAMBLE_DURATION = 0x30,
+ ERROR_INVALID_STS_LENGTH = 0x31,
+ ERROR_INVALID_NUM_OF_STS_SEGMENTS = 0x32,
+ ERROR_INVALID_NUM_OF_CONTROLEES = 0x33,
+ ERROR_MAX_RANGING_REPLY_TIME_EXCEEDED = 0x34,
+ ERROR_INVALID_DST_ADDRESS_LIST = 0x35,
+ ERROR_INVALID_OR_NOT_FOUND_SUB_SESSION_ID = 0x36,
+ ERROR_INVALID_RESULT_REPORT_CONFIG = 0x37,
+ ERROR_INVALID_RANGING_ROUND_CONTROL_CONFIG = 0x38,
+ ERROR_INVALID_RANGING_ROUND_USAGE = 0x39,
+ ERROR_INVALID_MULTI_NODE_MODE = 0x3A,
+ ERROR_RDS_FETCH_FAILURE = 0x3B,
+ ERROR_REF_UWB_SESSION_DOES_NOT_EXIST = 0x3C,
+ ERROR_REF_UWB_SESSION_RANGING_DURATION_MISMATCH = 0x3D,
+ ERROR_REF_UWB_SESSION_INVALID_OFFSET_TIME = 0x3E,
+ ERROR_REF_UWB_SESSION_LOST = 0x3F,
+ // TODO(b/272775225): Add a range for the vendor specific space, after PDL supports
+ // this feature (requested in b/267339120).
ERROR_INVALID_CHANNEL_WITH_AOA = 0x80,
ERROR_STOPPED_DUE_TO_OTHER_SESSION_CONFLICT = 0x81,
}
@@ -688,11 +721,14 @@
packet SessionStatusNtf : SessionConfigNotification (opcode = 0x2) { //SESSION_STATUS_NTF
session_id: 32,
session_state: SessionState,
- reason_code: ReasonCode,
+ // TODO(b/272775225): Switch back to the enum type ReasonCode, once PDL supports defining a
+ // range inside an enum (for the vendor-specific space), in b/267339120.
+ reason_code: 8,
}
test SessionStatusNtf {
"\x61\x02\x00\x06\x00\x00\x00\x01\x02\x03\x04\x02\x21",
+ "\x61\x02\x00\x06\x00\x00\x00\x01\x02\x03\x04\x01\x82", // Vendor Specific Reason Code
}
struct AppConfigTlv {