diff options
author | Roshan Pius <rpius@google.com> | 2023-04-25 14:28:14 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2023-05-01 10:51:35 -0700 |
commit | f9d9c4a4457183e1fef999aa352f609e0ca9bf4c (patch) | |
tree | 3a4fadda5f83781067980e9923ededfa9de75ddb /src/rust/uwb_uci_packets | |
parent | a4e78d09f69cb8e97ecd5cf02422ce9eddb094c9 (diff) | |
download | uwb-f9d9c4a4457183e1fef999aa352f609e0ca9bf4c.tar.gz |
uwb(uci): Implement CR-461
Switches most session UCI commands from using app provided session id to
a UWBS generated session handle.
Since UWB framework needs to be both 1.0 & 2.0 compatible, introduced a
new `session_token` term to refer to session fields in UCI params that
could either be session_id (FIRA 1.0) or session_handle (FIRA 2.0). The
conversion from `session_id` to `session_handle` is managed inside
uci_manager. JNI layer will continue to use the existing session_id as
identified. However, since we share the same data structures across UCI
core & JNI, there is some leakage of the terminology to the JNI layer.
Bug: 270089497
Test: atest CtsUwbMultiDeviceTestCase_FiraRangingTests
Test: atest libuwb_uci_packets libuwb_core_tests
Change-Id: I93107a1d53b814053dfa1ad5b4425a4aba8509f2
Diffstat (limited to 'src/rust/uwb_uci_packets')
-rw-r--r-- | src/rust/uwb_uci_packets/src/lib.rs | 19 | ||||
-rw-r--r-- | src/rust/uwb_uci_packets/uci_packets.pdl | 49 |
2 files changed, 41 insertions, 27 deletions
diff --git a/src/rust/uwb_uci_packets/src/lib.rs b/src/rust/uwb_uci_packets/src/lib.rs index c5bb3f5..ce63bfb 100644 --- a/src/rust/uwb_uci_packets/src/lib.rs +++ b/src/rust/uwb_uci_packets/src/lib.rs @@ -716,7 +716,7 @@ impl PacketDefrager { #[allow(dead_code)] #[derive(Debug, Clone)] pub struct ParsedDiagnosticNtfPacket { - session_id: u32, + session_token: u32, sequence_number: u32, frame_reports: Vec<ParsedFrameReport>, } @@ -733,7 +733,7 @@ pub struct ParsedFrameReport { } pub fn parse_diagnostics_ntf(evt: AndroidRangeDiagnosticsNtf) -> Result<ParsedDiagnosticNtfPacket> { - let session_id = evt.get_session_id(); + let session_token = evt.get_session_token(); let sequence_number = evt.get_sequence_number(); let mut parsed_frame_reports = Vec::new(); for report in evt.get_frame_reports() { @@ -773,7 +773,7 @@ pub fn parse_diagnostics_ntf(evt: AndroidRangeDiagnosticsNtf) -> Result<ParsedDi }); } Ok(ParsedDiagnosticNtfPacket { - session_id, + session_token, sequence_number, frame_reports: parsed_frame_reports, }) @@ -821,7 +821,7 @@ pub fn write_controlee_2_0_32byte(controlee: &Controlee_V2_0_32_Byte_Version) -> /// This function can build the packet with/without message control, which /// is indicated by action parameter. pub fn build_session_update_controller_multicast_list_cmd( - session_id: u32, + session_token: u32, action: UpdateMulticastListAction, controlees: Controlees, ) -> Result<SessionUpdateControllerMulticastListCmd> { @@ -855,7 +855,7 @@ pub fn build_session_update_controller_multicast_list_cmd( _ => return Err(Error::InvalidPacketError), } Ok(SessionUpdateControllerMulticastListCmdBuilder { - session_id, + session_token, action, payload: Some(controlees_buf.freeze()), } @@ -903,9 +903,12 @@ mod tests { let frame_report = FrameReport { uwb_msg_id: 1, action: 1, antenna_set: 1, frame_report_tlvs: tlvs }; frame_reports.push(frame_report); - let packet = - AndroidRangeDiagnosticsNtfBuilder { session_id: 1, sequence_number: 1, frame_reports } - .build(); + let packet = AndroidRangeDiagnosticsNtfBuilder { + session_token: 1, + sequence_number: 1, + frame_reports, + } + .build(); let mut parsed_packet = parse_diagnostics_ntf(packet).unwrap(); let parsed_frame_report = parsed_packet.frame_reports.pop().unwrap(); assert_eq!(rssi_vec, parsed_frame_report.rssi); diff --git a/src/rust/uwb_uci_packets/uci_packets.pdl b/src/rust/uwb_uci_packets/uci_packets.pdl index 848195a..cf065d8 100644 --- a/src/rust/uwb_uci_packets/uci_packets.pdl +++ b/src/rust/uwb_uci_packets/uci_packets.pdl @@ -517,7 +517,7 @@ packet UciDataPacket { } packet UciDataSnd : UciDataPacket (data_packet_format = DATA_SND, message_type = DATA) { - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) dest_mac_address: 64, dest_fira_component: FiraComponent, uci_sequence_number: 8, @@ -526,7 +526,7 @@ packet UciDataSnd : UciDataPacket (data_packet_format = DATA_SND, message_type = } packet UciDataRcv : UciDataPacket (data_packet_format = DATA_RCV, message_type = DATA) { - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) status: DataRcvStatusCode, uci_sequence_number: 32, source_mac_address: 64, @@ -733,6 +733,17 @@ test SessionInitCmd { "\x21\x00\x00\x05\x00\x00\x00\x01\x02\x03\x04\x01", } +// FIRA version 2 introduces a new version of SESSION_INIT_RSP which +// includes UWBS generated session handle. +packet SessionInitRsp_V2 : SessionConfigResponse (opcode = 0x0) { //SESSION_INIT + status: StatusCode, + session_handle: 32, +} + +test SessionInitRsp_V2 { + "\x41\x00\x00\x01\x00\x00\x00\x11\x00\x00\x00\x01", +} + packet SessionInitRsp : SessionConfigResponse (opcode = 0x0) { //SESSION_INIT status: StatusCode, } @@ -742,7 +753,7 @@ test SessionInitRsp { } packet SessionDeinitCmd : SessionConfigCommand (opcode = 0x1) { //SESSION_DEINIT - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) } test SessionDeinitCmd { @@ -758,7 +769,7 @@ test SessionDeinitRsp { } packet SessionStatusNtf : SessionConfigNotification (opcode = 0x2) { //SESSION_STATUS_NTF - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) session_state: SessionState, // 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. @@ -777,7 +788,7 @@ struct AppConfigTlv { } packet SessionSetAppConfigCmd : SessionConfigCommand (opcode = 0x3) { //SESSION_SET_APP_CONFIG - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) _count_(tlvs): 8, tlvs: AppConfigTlv[] } @@ -802,7 +813,7 @@ test SessionSetAppConfigRsp { } packet SessionGetAppConfigCmd : SessionConfigCommand (opcode = 0x4) { //SESSION_GET_APP_CONFIG - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) _count_(app_cfg): 8, app_cfg: 8[], // AppConfigTlvType (Infra does not allow array of enums) } @@ -838,7 +849,7 @@ test SessionGetCountRsp { } packet SessionGetStateCmd : SessionConfigCommand (opcode = 0x6) { //SESSION_GET_STATE - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) } test SessionGetStateCmd { @@ -855,7 +866,7 @@ test SessionGetStateRsp { } packet SessionUpdateDtTagRangingRoundsCmd : SessionConfigCommand (opcode = 0x9) { //SESSION_UPDATE_ACTIVE_ROUNDS_DT_TAG - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) _count_(ranging_round_indexes): 8, ranging_round_indexes: 8[], } @@ -899,7 +910,7 @@ enum UpdateMulticastListAction: 8 { } packet SessionUpdateControllerMulticastListCmd : SessionConfigCommand (opcode = 0x7) { //SESSION_UPDATE_CONTROLLER_MULTICAST_LIST - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) action: UpdateMulticastListAction, _payload_, } @@ -934,7 +945,7 @@ struct ControleeStatus { } packet SessionUpdateControllerMulticastListNtf : SessionConfigNotification (opcode = 0x7) { //SESSION_UPDATE_CONTROLLER_MULTICAST_LIST - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) remaining_multicast_list_size: 8, _count_(controlee_status): 8, controlee_status: ControleeStatus[], @@ -945,7 +956,7 @@ test SessionUpdateControllerMulticastListNtf { } packet DataCreditNtf : SessionControlNotification (opcode = 0x04) { // SESSION_DATA_CREDIT_NTF - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) credit_availability: CreditAvailability, } @@ -954,7 +965,7 @@ test DataCreditNtf { } packet DataTransferStatusNtf : SessionControlNotification (opcode = 0x05) { // SESSION_DATA_TRANSFER_STATUS_NTF - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) uci_sequence_number: 8, status: DataTransferNtfStatusCode, // TODO(b/269779288): Add the tx_count field for implementing the DATA_REPETITION added in CR490. @@ -965,7 +976,7 @@ test DataTransferStatusNtf { } packet SessionQueryMaxDataSizeCmd : SessionConfigCommand (opcode = 0xB) { //QUERY_MAX_DATA_SIZE - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) } test SessionQueryMaxDataSizeCmd { @@ -973,7 +984,7 @@ test SessionQueryMaxDataSizeCmd { } packet SessionQueryMaxDataSizeRsp : SessionConfigResponse (opcode = 0xB) { //QUER_MAX_DATA_SIZE - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) max_data_size: 16, } @@ -982,7 +993,7 @@ test SessionQueryMaxDataSizeRsp { } packet SessionStartCmd : SessionControlCommand (opcode = 0x0) { //RANGE_START - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) } test SessionStartCmd { @@ -1070,7 +1081,7 @@ enum RangingMeasurementType : 8 { packet SessionInfoNtf : SessionControlNotification (opcode = 0x0) { // SESSION_INFO sequence_number: 32, - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) rcr_indicator: 8, current_ranging_interval: 32, ranging_measurement_type: RangingMeasurementType, @@ -1141,7 +1152,7 @@ test ExtendedMacOwrAoaSessionInfoNtf { } packet SessionStopCmd : SessionControlCommand (opcode = 0x1) { // SESSION_STOP - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) } test SessionStopCmd { @@ -1157,7 +1168,7 @@ test SessionStopRsp { } packet SessionGetRangingCountCmd : SessionControlCommand (opcode = 0x3) { // SESSION_GET_RANGING_COUNT - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) } test SessionGetRangingCountCmd { @@ -1276,7 +1287,7 @@ struct FrameReport { } packet AndroidRangeDiagnosticsNtf : AndroidNotification (opcode = 0x2) { //FIRA_RANGE_DIAGNOSTICS - session_id: 32, + session_token: 32, // Session ID or Session Handle (based on UWBS version) sequence_number: 32, _count_(frame_reports): 8, frame_reports: FrameReport[], |