Merge "Migrate pdl to external/rust/crates/pdl-compiler"
diff --git a/src/rust/uwb_core/src/params/uci_packets.rs b/src/rust/uwb_core/src/params/uci_packets.rs
index 4e6be4d..5cd5822 100644
--- a/src/rust/uwb_core/src/params/uci_packets.rs
+++ b/src/rust/uwb_core/src/params/uci_packets.rs
@@ -24,11 +24,10 @@
     Controlee, ControleeStatus, Controlees, CreditAvailability, DataRcvStatusCode,
     DataTransferNtfStatusCode, DeviceConfigId, DeviceConfigStatus, DeviceConfigTlv, DeviceState,
     ExtendedAddressDlTdoaRangingMeasurement, ExtendedAddressOwrAoaRangingMeasurement,
-    ExtendedAddressTwoWayRangingMeasurement, FiraComponent, GroupId, MessageType,
-    MulticastUpdateStatusCode, PowerStats, RangingMeasurementType, ReasonCode, ResetConfig,
-    SessionState, SessionType, ShortAddressDlTdoaRangingMeasurement,
-    ShortAddressOwrAoaRangingMeasurement, ShortAddressTwoWayRangingMeasurement, StatusCode,
-    UpdateMulticastListAction,
+    ExtendedAddressTwoWayRangingMeasurement, GroupId, MessageType, MulticastUpdateStatusCode,
+    PowerStats, RangingMeasurementType, ReasonCode, ResetConfig, SessionState, SessionType,
+    ShortAddressDlTdoaRangingMeasurement, ShortAddressOwrAoaRangingMeasurement,
+    ShortAddressTwoWayRangingMeasurement, StatusCode, UpdateMulticastListAction,
 };
 pub(crate) use uwb_uci_packets::{UciControlPacket, UciDataPacket, UciDataPacketHal};
 
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 9a44af1..21e1ddb 100644
--- a/src/rust/uwb_core/src/uci/mock_uci_manager.rs
+++ b/src/rust/uwb_core/src/uci/mock_uci_manager.rs
@@ -28,10 +28,9 @@
 use crate::error::{Error, Result};
 use crate::params::uci_packets::{
     app_config_tlvs_eq, device_config_tlvs_eq, AppConfigTlv, AppConfigTlvType, CapTlv, Controlees,
-    CoreSetConfigResponse, CountryCode, DeviceConfigId, DeviceConfigTlv, FiraComponent,
-    GetDeviceInfoResponse, PowerStats, RawUciMessage, ResetConfig, SessionId, SessionState,
-    SessionToken, SessionType, SessionUpdateDtTagRangingRoundsResponse, SetAppConfigResponse,
-    UpdateMulticastListAction,
+    CoreSetConfigResponse, CountryCode, DeviceConfigId, DeviceConfigTlv, GetDeviceInfoResponse,
+    PowerStats, RawUciMessage, ResetConfig, SessionId, SessionState, SessionToken, SessionType,
+    SessionUpdateDtTagRangingRoundsResponse, SetAppConfigResponse, UpdateMulticastListAction,
 };
 use crate::uci::notification::{
     CoreNotification, DataRcvNotification, SessionNotification, UciNotification,
@@ -396,15 +395,13 @@
         &mut self,
         expected_session_id: SessionId,
         expected_address: Vec<u8>,
-        expected_dest_end_point: FiraComponent,
-        expected_uci_sequence_num: u8,
+        expected_uci_sequence_num: u16,
         expected_app_payload_data: Vec<u8>,
         out: Result<()>,
     ) {
         self.expected_calls.lock().unwrap().push_back(ExpectedCall::SendDataPacket {
             expected_session_id,
             expected_address,
-            expected_dest_end_point,
             expected_uci_sequence_num,
             expected_app_payload_data,
             out,
@@ -911,8 +908,7 @@
         &self,
         session_id: SessionId,
         address: Vec<u8>,
-        dest_end_point: FiraComponent,
-        uci_sequence_num: u8,
+        uci_sequence_num: u16,
         app_payload_data: Vec<u8>,
     ) -> Result<()> {
         let mut expected_calls = self.expected_calls.lock().unwrap();
@@ -920,13 +916,11 @@
             Some(ExpectedCall::SendDataPacket {
                 expected_session_id,
                 expected_address,
-                expected_dest_end_point,
                 expected_uci_sequence_num,
                 expected_app_payload_data,
                 out,
             }) if expected_session_id == session_id
                 && expected_address == address
-                && expected_dest_end_point == dest_end_point
                 && expected_uci_sequence_num == uci_sequence_num
                 && expected_app_payload_data == app_payload_data =>
             {
@@ -1056,8 +1050,7 @@
     SendDataPacket {
         expected_session_id: SessionId,
         expected_address: Vec<u8>,
-        expected_dest_end_point: FiraComponent,
-        expected_uci_sequence_num: u8,
+        expected_uci_sequence_num: u16,
         expected_app_payload_data: Vec<u8>,
         out: Result<()>,
     },
diff --git a/src/rust/uwb_core/src/uci/notification.rs b/src/rust/uwb_core/src/uci/notification.rs
index 323b751..2158850 100644
--- a/src/rust/uwb_core/src/uci/notification.rs
+++ b/src/rust/uwb_core/src/uci/notification.rs
@@ -22,9 +22,9 @@
 use crate::params::uci_packets::{
     ControleeStatus, CreditAvailability, DataRcvStatusCode, DataTransferNtfStatusCode, DeviceState,
     ExtendedAddressDlTdoaRangingMeasurement, ExtendedAddressOwrAoaRangingMeasurement,
-    ExtendedAddressTwoWayRangingMeasurement, FiraComponent, RangingMeasurementType, RawUciMessage,
-    SessionState, SessionToken, ShortAddressDlTdoaRangingMeasurement,
-    ShortAddressOwrAoaRangingMeasurement, ShortAddressTwoWayRangingMeasurement, StatusCode,
+    ExtendedAddressTwoWayRangingMeasurement, RangingMeasurementType, RawUciMessage, SessionState,
+    SessionToken, ShortAddressDlTdoaRangingMeasurement, ShortAddressOwrAoaRangingMeasurement,
+    ShortAddressTwoWayRangingMeasurement, StatusCode,
 };
 
 /// enum of all UCI notifications with structured fields.
@@ -146,17 +146,11 @@
     pub status: DataRcvStatusCode,
 
     /// The sequence number of the data packet.
-    pub uci_sequence_num: u32,
+    pub uci_sequence_num: u16,
 
     /// MacAddress of the sender of the application data.
     pub source_address: UwbAddress,
 
-    /// Identifier for the source FiraComponent.
-    pub source_fira_component: FiraComponent,
-
-    /// Identifier for the destination FiraComponent.
-    pub dest_fira_component: FiraComponent,
-
     /// Application Payload Data
     pub payload: Vec<u8>,
 }
@@ -170,8 +164,6 @@
                 status: evt.get_status(),
                 uci_sequence_num: evt.get_uci_sequence_number(),
                 source_address: UwbAddress::Extended(evt.get_source_mac_address().to_le_bytes()),
-                source_fira_component: evt.get_source_fira_component(),
-                dest_fira_component: evt.get_dest_fira_component(),
                 payload: evt.get_data().to_vec(),
             }),
             _ => {
diff --git a/src/rust/uwb_core/src/uci/uci_manager.rs b/src/rust/uwb_core/src/uci/uci_manager.rs
index f33a968..f2563eb 100644
--- a/src/rust/uwb_core/src/uci/uci_manager.rs
+++ b/src/rust/uwb_core/src/uci/uci_manager.rs
@@ -25,10 +25,10 @@
 use crate::error::{Error, Result};
 use crate::params::uci_packets::{
     AppConfigTlv, AppConfigTlvType, CapTlv, Controlees, CoreSetConfigResponse, CountryCode,
-    CreditAvailability, DeviceConfigId, DeviceConfigTlv, DeviceState, FiraComponent,
-    GetDeviceInfoResponse, GroupId, MessageType, PowerStats, RawUciMessage, ResetConfig, SessionId,
-    SessionState, SessionToken, SessionType, SessionUpdateDtTagRangingRoundsResponse,
-    SetAppConfigResponse, UciDataPacket, UciDataPacketHal, UpdateMulticastListAction,
+    CreditAvailability, DeviceConfigId, DeviceConfigTlv, DeviceState, GetDeviceInfoResponse,
+    GroupId, MessageType, PowerStats, RawUciMessage, ResetConfig, SessionId, SessionState,
+    SessionToken, SessionType, SessionUpdateDtTagRangingRoundsResponse, SetAppConfigResponse,
+    UciDataPacket, UciDataPacketHal, UpdateMulticastListAction,
 };
 use crate::params::utils::bytes_to_u64;
 use crate::uci::message::UciMessage;
@@ -141,8 +141,7 @@
         &self,
         session_id: SessionId,
         address: Vec<u8>,
-        dest_end_point: FiraComponent,
-        uci_sequence_number: u8,
+        uci_sequence_number: u16,
         app_payload_data: Vec<u8>,
     ) -> Result<()>;
 
@@ -523,8 +522,7 @@
         &self,
         session_id: SessionId,
         dest_mac_address_bytes: Vec<u8>,
-        dest_fira_component: FiraComponent,
-        uci_sequence_number: u8,
+        uci_sequence_number: u16,
         data: Vec<u8>,
     ) -> Result<()> {
         debug!(
@@ -535,7 +533,6 @@
         let data_snd_packet = uwb_uci_packets::UciDataSndBuilder {
             session_token: self.get_session_token(&session_id).await?,
             dest_mac_address,
-            dest_fira_component,
             uci_sequence_number,
             data,
         }
@@ -2620,16 +2617,12 @@
         let session_token = 0x5;
         let uci_sequence_num = 0xa;
         let source_address = UwbAddress::Extended([0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1]);
-        let source_fira_component = FiraComponent::Uwbs;
-        let dest_fira_component = FiraComponent::Host;
         let app_data = vec![0x01, 0x02, 0x03];
         let data_rcv_payload = vec![
             0x05, 0x00, 0x00, 0x00, // SessionToken
             0x00, // DataRcvStatusCode
-            0x0a, 0x00, 0x00, 0x00, // UciSequenceNumber
             0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1, // MacAddress
-            0x00, // Source FiraComponent
-            0x01, // Dest FiraComponent
+            0x0a, 0x00, // UciSequenceNumber
             0x03, 0x00, // AppDataLen
             0x01, 0x02, 0x03, // AppData
         ];
@@ -2641,8 +2634,6 @@
             status: DataRcvStatusCode::UciStatusSuccess,
             uci_sequence_num,
             source_address,
-            source_fira_component,
-            dest_fira_component,
             payload: app_data,
         };
 
@@ -2685,17 +2676,13 @@
         let session_token = 0x5;
         let uci_sequence_num = 0xa;
         let source_address = UwbAddress::Extended([0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1]);
-        let source_fira_component = FiraComponent::Uwbs;
-        let dest_fira_component = FiraComponent::Host;
         let app_data_len = 300;
         let app_data_fragment_1_len = 200;
         let mut data_rcv_payload_fragment_1: Vec<u8> = vec![
             0x05, 0x00, 0x00, 0x00, // SessionToken
             0x00, // DataRcvStatusCode
-            0x0a, 0x00, 0x00, 0x00, // UciSequenceNumber
             0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1, // MacAddress
-            0x00, // Source FiraComponent
-            0x01, // Dest FiraComponent
+            0x0a, 0x00, // UciSequenceNumber
             0x2c, 0x01, // AppData Length (300)
         ];
 
@@ -2718,8 +2705,6 @@
             status: DataRcvStatusCode::UciStatusSuccess,
             uci_sequence_num,
             source_address,
-            source_fira_component,
-            dest_fira_component,
             payload: app_data,
         };
 
@@ -2765,14 +2750,12 @@
         let session_id = 0x5;
         let session_token = 0x5;
         let dest_mac_address = vec![0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1];
-        let dest_fira_component = FiraComponent::Host;
-        let uci_sequence_number = 0xa;
+        let uci_sequence_number: u16 = 0xa;
         let app_data = vec![0x01, 0x02, 0x03];
         let expected_data_snd_payload = vec![
             0x05, 0x00, 0x00, 0x00, // SessionID
             0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1, // MacAddress
-            0x01, // FiraComponent
-            0x0a, // UciSequenceNumber
+            0x0a, 0x00, // UciSequenceNumber
             0x03, 0x00, // AppDataLen
             0x01, 0x02, 0x03, // AppData
         ];
@@ -2790,7 +2773,8 @@
                 ntfs.append(&mut into_uci_hal_packets(
                     uwb_uci_packets::DataTransferStatusNtfBuilder {
                         session_token,
-                        uci_sequence_number,
+                        // TODO(b/282230468): Remove the u16-to-u8 conversion once spec is updated.
+                        uci_sequence_number: uci_sequence_number.try_into().unwrap(),
                         status,
                     },
                 ));
@@ -2804,13 +2788,7 @@
         .await;
 
         let result = uci_manager
-            .send_data_packet(
-                session_id,
-                dest_mac_address,
-                dest_fira_component,
-                uci_sequence_number,
-                app_data,
-            )
+            .send_data_packet(session_id, dest_mac_address, uci_sequence_number, app_data)
             .await;
         assert!(result.is_ok());
         assert!(mock_hal.wait_expected_calls_done().await);
@@ -2830,15 +2808,13 @@
         let session_id = 0x5;
         let session_token = 0x5;
         let dest_mac_address = vec![0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1];
-        let dest_fira_component = FiraComponent::Host;
-        let uci_sequence_number = 0xa;
+        let uci_sequence_number: u16 = 0xa;
         let app_data_len = 300; // Larger than MAX_PAYLOAD_LEN=255, so fragmentation occurs.
         let mut app_data = Vec::new();
         let mut expected_data_snd_payload_fragment_1 = vec![
             0x05, 0x00, 0x00, 0x00, // SessionID
             0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1, // MacAddress
-            0x01, // FiraComponent
-            0x0a, // UciSequenceNumber
+            0x0a, 0x00, // UciSequenceNumber
             0x2c, 0x01, // AppDataLen = 300
         ];
         let mut expected_data_snd_payload_fragment_2 = Vec::new();
@@ -2886,7 +2862,8 @@
                 ntfs.append(&mut into_uci_hal_packets(
                     uwb_uci_packets::DataTransferStatusNtfBuilder {
                         session_token,
-                        uci_sequence_number,
+                        // TODO(b/282230468): Remove the u16-to-u8 conversion once spec is updated.
+                        uci_sequence_number: uci_sequence_number.try_into().unwrap(),
                         status,
                     },
                 ));
@@ -2900,13 +2877,7 @@
         .await;
 
         let result = uci_manager
-            .send_data_packet(
-                session_id,
-                dest_mac_address,
-                dest_fira_component,
-                uci_sequence_number,
-                app_data,
-            )
+            .send_data_packet(session_id, dest_mac_address, uci_sequence_number, app_data)
             .await;
         assert!(result.is_ok());
         assert!(mock_hal.wait_expected_calls_done().await);
@@ -2922,14 +2893,12 @@
         let session_id = 0x5;
         let session_token = 0x5;
         let dest_mac_address = vec![0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1];
-        let dest_fira_component = FiraComponent::Host;
-        let uci_sequence_number = 0xa;
+        let uci_sequence_number: u16 = 0xa;
         let app_data = vec![0x01, 0x02, 0x03];
         let expected_data_snd_payload = vec![
             0x05, 0x00, 0x00, 0x00, // SessionID
             0xa0, 0xb0, 0xc0, 0xd0, 0xa1, 0xb1, 0xc1, 0xd1, // MacAddress
-            0x01, // FiraComponent
-            0x0a, // UciSequenceNumber
+            0x0a, 0x00, // UciSequenceNumber
             0x03, 0x00, // AppDataLen
             0x01, 0x02, 0x03, // AppData
         ];
@@ -2955,7 +2924,8 @@
                 ntfs.append(&mut into_uci_hal_packets(
                     uwb_uci_packets::DataTransferStatusNtfBuilder {
                         session_token,
-                        uci_sequence_number,
+                        // TODO(b/282230468): Remove the u16-to-u8 conversion once spec is updated.
+                        uci_sequence_number: uci_sequence_number.try_into().unwrap(),
                         status,
                     },
                 ));
@@ -2969,13 +2939,7 @@
         .await;
 
         let result = uci_manager
-            .send_data_packet(
-                session_id,
-                dest_mac_address,
-                dest_fira_component,
-                uci_sequence_number,
-                app_data,
-            )
+            .send_data_packet(session_id, dest_mac_address, uci_sequence_number, app_data)
             .await;
         assert!(result.is_ok());
         assert!(mock_hal.wait_expected_calls_done().await);
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 35bd484..4b1cf25 100644
--- a/src/rust/uwb_core/src/uci/uci_manager_sync.rs
+++ b/src/rust/uwb_core/src/uci/uci_manager_sync.rs
@@ -27,9 +27,9 @@
 use crate::error::{Error, Result};
 use crate::params::{
     AppConfigTlv, AppConfigTlvType, CapTlv, CoreSetConfigResponse, CountryCode, DeviceConfigId,
-    DeviceConfigTlv, FiraComponent, GetDeviceInfoResponse, PowerStats, RawUciMessage, ResetConfig,
-    SessionId, SessionState, SessionType, SessionUpdateDtTagRangingRoundsResponse,
-    SetAppConfigResponse, UpdateMulticastListAction,
+    DeviceConfigTlv, GetDeviceInfoResponse, PowerStats, RawUciMessage, ResetConfig, SessionId,
+    SessionState, SessionType, SessionUpdateDtTagRangingRoundsResponse, SetAppConfigResponse,
+    UpdateMulticastListAction,
 };
 #[cfg(any(test, feature = "mock-utils"))]
 use crate::uci::mock_uci_manager::MockUciManager;
@@ -358,20 +358,18 @@
         &self,
         session_id: SessionId,
         address: Vec<u8>,
-        dest_end_point: FiraComponent,
-        uci_sequence_num: u8,
+        uci_sequence_num: u16,
         app_payload_data: Vec<u8>,
     ) -> Result<()> {
         self.runtime_handle.block_on(self.uci_manager.send_data_packet(
             session_id,
             address,
-            dest_end_point,
             uci_sequence_num,
             app_payload_data,
         ))
     }
     /// Get session token for session id.
-    pub fn get_session_token(&self, session_id : SessionId) -> Result<u32> {
+    pub fn get_session_token(&self, session_id: SessionId) -> Result<u32> {
         self.runtime_handle.block_on(self.uci_manager.get_session_token_from_session_id(session_id))
     }
 }
@@ -390,6 +388,7 @@
         hal: H,
         notification_manager_builder: B,
         logger: L,
+        logger_mode: UciLoggerMode,
         runtime_handle: Handle,
     ) -> Result<Self>
     where
@@ -398,8 +397,8 @@
         L: UciLogger,
     {
         // UciManagerImpl::new uses tokio::spawn, so it is called inside the runtime as async fn.
-        let uci_manager = runtime_handle
-            .block_on(async { UciManagerImpl::new(hal, logger, UciLoggerMode::Disabled) });
+        let uci_manager =
+            runtime_handle.block_on(async { UciManagerImpl::new(hal, logger, logger_mode) });
         let mut uci_manager_sync = UciManagerSync { runtime_handle, uci_manager };
         uci_manager_sync.redirect_notification(notification_manager_builder)?;
         Ok(uci_manager_sync)
diff --git a/src/rust/uwb_uci_packets/uci_packets.pdl b/src/rust/uwb_uci_packets/uci_packets.pdl
index 1449358..54de313 100644
--- a/src/rust/uwb_uci_packets/uci_packets.pdl
+++ b/src/rust/uwb_uci_packets/uci_packets.pdl
@@ -174,12 +174,6 @@
     UCI_DATA_TRANSFER_STATUS_ERROR_DATA_TRANSFER_IS_ONGOING = 0x06,
 }
 
-enum FiraComponent : 8 {
-    UWBS = 0x00,
-    HOST = 0x01,
-    SECURE_COMPONENT = 0x02,
-}
-
 enum ResetConfig : 8 {
     UWBS_RESET = 0x00,
 }
@@ -513,8 +507,7 @@
 packet UciDataSnd : UciDataPacket (data_packet_format = DATA_SND, message_type = DATA) {
     session_token: 32, // Session ID or Session Handle (based on UWBS version)
     dest_mac_address: 64,
-    dest_fira_component: FiraComponent,
-    uci_sequence_number: 8,
+    uci_sequence_number: 16,
     _size_(data): 16,
     data: 8[]
 }
@@ -522,10 +515,8 @@
 packet UciDataRcv : UciDataPacket (data_packet_format = DATA_RCV, message_type = DATA) {
     session_token: 32, // Session ID or Session Handle (based on UWBS version)
     status: DataRcvStatusCode,
-    uci_sequence_number: 32,
     source_mac_address: 64,
-    source_fira_component: FiraComponent,
-    dest_fira_component: FiraComponent,
+    uci_sequence_number: 16,
     _size_(data): 16,
     data: 8[]
 }