diff options
author | Bob Wang <ziyiw@google.com> | 2024-04-27 16:20:02 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-04-27 16:20:02 +0000 |
commit | 8d52ecc2db9eaa1491cd12d023b162fb9dfb695f (patch) | |
tree | 65a5fc4a9a63f3feb33453f425312f34252b4688 | |
parent | 5a41ec14dc170e5cfa432d64f8639b8ce00239c4 (diff) | |
parent | 1cf43330b06eaab61a5cc96336d0ace1129d1b4b (diff) | |
download | uwb-8d52ecc2db9eaa1491cd12d023b162fb9dfb695f.tar.gz |
Merge "Revert "Revert "[uci] Pass in a boolean to indicate if support m..."" into main
-rw-r--r-- | src/rust/uwb_core/src/session/uwb_session.rs | 1 | ||||
-rw-r--r-- | src/rust/uwb_core/src/uci/command.rs | 3 | ||||
-rw-r--r-- | src/rust/uwb_core/src/uci/message.rs | 9 | ||||
-rw-r--r-- | src/rust/uwb_core/src/uci/mock_uci_manager.rs | 1 | ||||
-rw-r--r-- | src/rust/uwb_core/src/uci/notification.rs | 84 | ||||
-rw-r--r-- | src/rust/uwb_core/src/uci/uci_manager.rs | 24 | ||||
-rw-r--r-- | src/rust/uwb_core/src/uci/uci_manager_sync.rs | 11 |
7 files changed, 98 insertions, 35 deletions
diff --git a/src/rust/uwb_core/src/session/uwb_session.rs b/src/rust/uwb_core/src/session/uwb_session.rs index d41b693..7e82e0a 100644 --- a/src/rust/uwb_core/src/session/uwb_session.rs +++ b/src/rust/uwb_core/src/session/uwb_session.rs @@ -312,6 +312,7 @@ impl<T: UciManager> UwbSessionActor<T> { self.session_id, action, Controlees::NoSessionKey(controlees), + false, ) .await?; diff --git a/src/rust/uwb_core/src/uci/command.rs b/src/rust/uwb_core/src/uci/command.rs index b15d387..51cbdcb 100644 --- a/src/rust/uwb_core/src/uci/command.rs +++ b/src/rust/uwb_core/src/uci/command.rs @@ -68,6 +68,7 @@ pub enum UciCommand { session_token: SessionToken, action: UpdateMulticastListAction, controlees: Controlees, + is_multicast_list_ntf_v2_supported: bool, }, SessionUpdateDtTagRangingRounds { session_token: u32, @@ -146,6 +147,7 @@ impl TryFrom<UciCommand> for uwb_uci_packets::UciControlPacket { session_token, action, controlees, + .. } => build_session_update_controller_multicast_list_cmd( session_token, action, @@ -406,6 +408,7 @@ mod tests { session_token: 1, action: UpdateMulticastListAction::AddControlee, controlees: Controlees::NoSessionKey(vec![]), + is_multicast_list_ntf_v2_supported: false, }; packet = uwb_uci_packets::UciControlPacket::try_from(cmd.clone()).unwrap(); assert_eq!( diff --git a/src/rust/uwb_core/src/uci/message.rs b/src/rust/uwb_core/src/uci/message.rs index a4f72e8..b0f4c22 100644 --- a/src/rust/uwb_core/src/uci/message.rs +++ b/src/rust/uwb_core/src/uci/message.rs @@ -28,19 +28,22 @@ pub(super) enum UciMessage { Notification(UciNotification), } -impl TryFrom<(uwb_uci_packets::UciControlPacket, UCIMajorVersion)> for UciMessage { +impl TryFrom<(uwb_uci_packets::UciControlPacket, UCIMajorVersion, bool)> for UciMessage { type Error = Error; fn try_from( - pair: (uwb_uci_packets::UciControlPacket, UCIMajorVersion), + pair: (uwb_uci_packets::UciControlPacket, UCIMajorVersion, bool), ) -> Result<Self, Self::Error> { let packet = pair.0; let uci_fira_major_ver = pair.1; + let is_multicast_list_ntf_v2_supported = pair.2; match packet.specialize() { uwb_uci_packets::UciControlPacketChild::UciResponse(evt) => { Ok(UciMessage::Response(evt.try_into()?)) } uwb_uci_packets::UciControlPacketChild::UciNotification(evt) => { - Ok(UciMessage::Notification((evt, uci_fira_major_ver).try_into()?)) + Ok(UciMessage::Notification( + (evt, uci_fira_major_ver, is_multicast_list_ntf_v2_supported).try_into()?, + )) } _ => { error!("Unknown packet for converting to UciMessage: {:?}", packet); diff --git a/src/rust/uwb_core/src/uci/mock_uci_manager.rs b/src/rust/uwb_core/src/uci/mock_uci_manager.rs index 6dd222f..7ae33ab 100644 --- a/src/rust/uwb_core/src/uci/mock_uci_manager.rs +++ b/src/rust/uwb_core/src/uci/mock_uci_manager.rs @@ -839,6 +839,7 @@ impl UciManager for MockUciManager { session_id: SessionId, action: UpdateMulticastListAction, controlees: Controlees, + _is_multicast_list_ntf_v2_supported: bool, ) -> Result<()> { let mut expected_calls = self.expected_calls.lock().unwrap(); match expected_calls.pop_front() { diff --git a/src/rust/uwb_core/src/uci/notification.rs b/src/rust/uwb_core/src/uci/notification.rs index 41c4002..58e68cd 100644 --- a/src/rust/uwb_core/src/uci/notification.rs +++ b/src/rust/uwb_core/src/uci/notification.rs @@ -342,20 +342,21 @@ impl UciNotification { } } -impl TryFrom<(uwb_uci_packets::UciNotification, UCIMajorVersion)> for UciNotification { +impl TryFrom<(uwb_uci_packets::UciNotification, UCIMajorVersion, bool)> for UciNotification { type Error = Error; fn try_from( - pair: (uwb_uci_packets::UciNotification, UCIMajorVersion), + pair: (uwb_uci_packets::UciNotification, UCIMajorVersion, bool), ) -> std::result::Result<Self, Self::Error> { use uwb_uci_packets::UciNotificationChild; let evt = pair.0; let uci_fira_major_ver = pair.1; + let is_multicast_list_ntf_v2_supported = pair.2; match evt.specialize() { UciNotificationChild::CoreNotification(evt) => Ok(Self::Core(evt.try_into()?)), - UciNotificationChild::SessionConfigNotification(evt) => { - Ok(Self::Session((evt, uci_fira_major_ver).try_into()?)) - } + UciNotificationChild::SessionConfigNotification(evt) => Ok(Self::Session( + (evt, uci_fira_major_ver, is_multicast_list_ntf_v2_supported).try_into()?, + )), UciNotificationChild::SessionControlNotification(evt) => { Ok(Self::Session(evt.try_into()?)) } @@ -391,16 +392,17 @@ impl TryFrom<uwb_uci_packets::CoreNotification> for CoreNotification { } } -impl TryFrom<(uwb_uci_packets::SessionConfigNotification, UCIMajorVersion)> +impl TryFrom<(uwb_uci_packets::SessionConfigNotification, UCIMajorVersion, bool)> for SessionNotification { type Error = Error; fn try_from( - pair: (uwb_uci_packets::SessionConfigNotification, UCIMajorVersion), + pair: (uwb_uci_packets::SessionConfigNotification, UCIMajorVersion, bool), ) -> std::result::Result<Self, Self::Error> { use uwb_uci_packets::SessionConfigNotificationChild; let evt = pair.0; let uci_fira_major_ver = pair.1; + let is_multicast_list_ntf_v2_supported = pair.2; match evt.specialize() { SessionConfigNotificationChild::SessionStatusNtf(evt) => Ok(Self::Status { //no sessionId recieved, assign from sessionIdToToken map in uci_manager @@ -410,7 +412,8 @@ impl TryFrom<(uwb_uci_packets::SessionConfigNotification, UCIMajorVersion)> reason_code: evt.get_reason_code(), }), SessionConfigNotificationChild::SessionUpdateControllerMulticastListNtf(evt) - if uci_fira_major_ver == UCIMajorVersion::V1 => + if uci_fira_major_ver == UCIMajorVersion::V1 + || !is_multicast_list_ntf_v2_supported => { let payload = evt.get_payload(); let multicast_update_list_payload_v1 = @@ -943,9 +946,12 @@ mod tests { let session_notification_packet = uwb_uci_packets::SessionConfigNotification::try_from(session_status_ntf).unwrap(); let uci_fira_major_version = UCIMajorVersion::V1; - let session_notification = - SessionNotification::try_from((session_notification_packet, uci_fira_major_version)) - .unwrap(); + let session_notification = SessionNotification::try_from(( + session_notification_packet, + uci_fira_major_version, + false, + )) + .unwrap(); let uci_notification_from_session_status_ntf = UciNotification::Session(session_notification); assert_eq!( @@ -1029,9 +1035,12 @@ mod tests { ) .unwrap(); let uci_fira_major_version = UCIMajorVersion::V1; - let session_notification = - SessionNotification::try_from((session_notification_packet, uci_fira_major_version)) - .unwrap(); + let session_notification = SessionNotification::try_from(( + session_notification_packet, + uci_fira_major_version, + false, + )) + .unwrap(); let uci_notification_from_session_update_controller_multicast_list_ntf = UciNotification::Session(session_notification); assert_eq!( @@ -1070,8 +1079,11 @@ mod tests { ) .unwrap(); let uci_fira_major_version = UCIMajorVersion::V1; - let session_notification = - SessionNotification::try_from((session_notification_packet, uci_fira_major_version)); + let session_notification = SessionNotification::try_from(( + session_notification_packet, + uci_fira_major_version, + false, + )); assert_eq!(session_notification, Err(Error::BadParameters)); } @@ -1099,8 +1111,11 @@ mod tests { ) .unwrap(); let uci_fira_major_version = UCIMajorVersion::V2; - let session_notification = - SessionNotification::try_from((session_notification_packet, uci_fira_major_version)); + let session_notification = SessionNotification::try_from(( + session_notification_packet, + uci_fira_major_version, + true, + )); assert_eq!(session_notification, Err(Error::BadParameters)); } @@ -1134,9 +1149,12 @@ mod tests { ) .unwrap(); let uci_fira_major_version = UCIMajorVersion::V2; - let session_notification = - SessionNotification::try_from((session_notification_packet, uci_fira_major_version)) - .unwrap(); + let session_notification = SessionNotification::try_from(( + session_notification_packet, + uci_fira_major_version, + true, + )) + .unwrap(); let uci_notification_from_session_update_controller_multicast_list_ntf = UciNotification::Session(session_notification); assert_eq!( @@ -1161,9 +1179,12 @@ mod tests { ) .unwrap(); let uci_fira_major_version = UCIMajorVersion::V1; - let session_notification = - SessionNotification::try_from((session_notification_packet, uci_fira_major_version)) - .unwrap(); + let session_notification = SessionNotification::try_from(( + session_notification_packet, + uci_fira_major_version, + false, + )) + .unwrap(); let uci_notification_from_session_data_transfer_phase_config_ntf = UciNotification::Session(session_notification); assert_eq!( @@ -1323,26 +1344,33 @@ mod tests { let uci_notification_from_vendor_9 = UciNotification::try_from(( vendor_9_empty_notification, uci_fira_major_version.clone(), + false, )) .unwrap(); let uci_notification_from_vendor_A = UciNotification::try_from(( vendor_A_nonempty_notification, uci_fira_major_version.clone(), + false, )) .unwrap(); let uci_notification_from_vendor_B = UciNotification::try_from(( vendor_B_nonempty_notification, uci_fira_major_version.clone(), + false, )) .unwrap(); let uci_notification_from_vendor_E = UciNotification::try_from(( vendor_E_nonempty_notification, uci_fira_major_version.clone(), + false, + )) + .unwrap(); + let uci_notification_from_vendor_F = UciNotification::try_from(( + vendor_F_nonempty_notification, + uci_fira_major_version, + false, )) .unwrap(); - let uci_notification_from_vendor_F = - UciNotification::try_from((vendor_F_nonempty_notification, uci_fira_major_version)) - .unwrap(); assert_eq!( uci_notification_from_vendor_9, UciNotification::Vendor(RawUciMessage { @@ -1391,7 +1419,7 @@ mod tests { uwb_uci_packets::TestNotificationBuilder { opcode: 0x22, payload: None }.build().into(); let uci_fira_major_version = UCIMajorVersion::V1; let test_uci_notification = - UciNotification::try_from((test_notification, uci_fira_major_version)).unwrap(); + UciNotification::try_from((test_notification, uci_fira_major_version, false)).unwrap(); assert_eq!( test_uci_notification, UciNotification::Vendor(RawUciMessage { diff --git a/src/rust/uwb_core/src/uci/uci_manager.rs b/src/rust/uwb_core/src/uci/uci_manager.rs index 2be0b59..065da83 100644 --- a/src/rust/uwb_core/src/uci/uci_manager.rs +++ b/src/rust/uwb_core/src/uci/uci_manager.rs @@ -121,6 +121,7 @@ pub trait UciManager: 'static + Send + Sync + Clone { session_id: SessionId, action: UpdateMulticastListAction, controlees: Controlees, + is_multicast_list_ntf_v2_supported: bool, ) -> Result<()>; // Update ranging rounds for DT Tag @@ -470,6 +471,7 @@ impl UciManager for UciManagerImpl { session_id: SessionId, action: UpdateMulticastListAction, controlees: Controlees, + is_multicast_list_ntf_v2_supported: bool, ) -> Result<()> { let controlees_len = match controlees { Controlees::NoSessionKey(ref controlee_vec) => controlee_vec.len(), @@ -484,6 +486,7 @@ impl UciManager for UciManagerImpl { session_token: self.get_session_token(&session_id).await?, action, controlees, + is_multicast_list_ntf_v2_supported, }; match self.send_cmd(UciManagerCmd::SendUciCommand { cmd }).await { Ok(UciResponse::SessionUpdateControllerMulticastList(resp)) => resp, @@ -787,6 +790,9 @@ struct UciManagerActor<T: UciHal, U: UciLogger> { // DATA_MSG_SEND packets (from Host to UWBS), larger than this should be fragmented into // multiple packets with this as the payload size. max_data_packet_payload_size: usize, + + // The flag that indicate whether multicast list ntf v2 is supported. + is_multicast_list_ntf_v2_supported: bool, } impl<T: UciHal, U: UciLogger> UciManagerActor<T, U> { @@ -824,6 +830,7 @@ impl<T: UciHal, U: UciLogger> UciManagerActor<T, U> { session_id_to_token_map, get_device_info_rsp: None, max_data_packet_payload_size: MAX_DATA_PACKET_PAYLOAD_SIZE, + is_multicast_list_ntf_v2_supported: false, } } @@ -1078,6 +1085,16 @@ impl<T: UciHal, U: UciLogger> UciManagerActor<T, U> { }); } + if let UciCommand::SessionUpdateControllerMulticastList { + session_token: _, + action: _, + controlees: _, + is_multicast_list_ntf_v2_supported, + } = cmd.clone() + { + self.is_multicast_list_ntf_v2_supported = is_multicast_list_ntf_v2_supported; + } + self.uci_cmd_retryer = Some(UciCmdRetryer { cmd, result_sender, retry_count: MAX_RETRY_COUNT }); @@ -1281,6 +1298,7 @@ impl<T: UciHal, U: UciLogger> UciManagerActor<T, U> { packet, UCIMajorVersion::from_u8(uci_fira_major_version) .map_or(UCIMajorVersion::V1, |v| v), + self.is_multicast_list_ntf_v2_supported, ) .try_into() { @@ -2607,6 +2625,7 @@ mod tests { session_token, action, controlees: Controlees::NoSessionKey(vec![controlee_clone]), + is_multicast_list_ntf_v2_supported: false, }; let resp = into_uci_hal_packets( uwb_uci_packets::SessionUpdateControllerMulticastListRspBuilder { @@ -2628,6 +2647,7 @@ mod tests { session_id, action, uwb_uci_packets::Controlees::NoSessionKey(vec![controlee]), + false, ) .await; assert!(result.is_ok()); @@ -2656,6 +2676,7 @@ mod tests { session_token, action, controlees: Controlees::ShortSessionKey(vec![controlee_clone]), + is_multicast_list_ntf_v2_supported: true, }; let resp = into_uci_hal_packets( uwb_uci_packets::SessionUpdateControllerMulticastListRspBuilder { @@ -2676,6 +2697,7 @@ mod tests { session_id, action, uwb_uci_packets::Controlees::ShortSessionKey(vec![controlee]), + true, ) .await; assert!(result.is_ok()); @@ -2705,6 +2727,7 @@ mod tests { session_token, action, controlees: Controlees::LongSessionKey(vec![controlee_clone]), + is_multicast_list_ntf_v2_supported: true, }; let resp = into_uci_hal_packets( uwb_uci_packets::SessionUpdateControllerMulticastListRspBuilder { @@ -2726,6 +2749,7 @@ mod tests { session_id, action, uwb_uci_packets::Controlees::LongSessionKey(vec![controlee]), + true, ) .await; assert!(result.is_ok()); diff --git a/src/rust/uwb_core/src/uci/uci_manager_sync.rs b/src/rust/uwb_core/src/uci/uci_manager_sync.rs index 0375f97..53e47d9 100644 --- a/src/rust/uwb_core/src/uci/uci_manager_sync.rs +++ b/src/rust/uwb_core/src/uci/uci_manager_sync.rs @@ -316,11 +316,14 @@ impl<U: UciManager> UciManagerSync<U> { session_id: SessionId, action: UpdateMulticastListAction, controlees: Controlees, + is_multicast_list_ntf_v2_supported: bool, ) -> Result<()> { - self.runtime_handle.block_on( - self.uci_manager - .session_update_controller_multicast_list(session_id, action, controlees), - ) + self.runtime_handle.block_on(self.uci_manager.session_update_controller_multicast_list( + session_id, + action, + controlees, + is_multicast_list_ntf_v2_supported, + )) } /// Update ranging rounds for DT Tag |