diff options
author | Henri Chataing <henrichataing@google.com> | 2024-02-23 16:42:46 -0800 |
---|---|---|
committer | hchataing <104974782+hchataing@users.noreply.github.com> | 2024-03-27 14:28:24 -0700 |
commit | 0bc8f45c9a0a501287b0b1b6fac8c70e6e30603c (patch) | |
tree | 4963917583e489d02a16942779cbfe6b9f0d7dab | |
parent | da707e73dd6bf617222f765bd3e6f92d50801d30 (diff) | |
download | pica-0bc8f45c9a0a501287b0b1b6fac8c70e6e30603c.tar.gz |
Reorganize definitions in uci_packets.pdl
Instead of deriving packets based on the message type
first then the gid + oid, which prevents proper typing
of the oid; packets are written to derive from the gid
first, then mt + oid.
This way, the oid can have the appropriate enum type
and commands do not have to be written with hardcoded
oids.
-rw-r--r-- | src/device.rs | 225 | ||||
-rw-r--r-- | src/lib.rs | 7 | ||||
-rw-r--r-- | src/session.rs | 6 | ||||
-rw-r--r-- | src/uci_packets.pdl | 598 |
4 files changed, 346 insertions, 490 deletions
diff --git a/src/device.rs b/src/device.rs index c255cc4..390a29a 100644 --- a/src/device.rs +++ b/src/device.rs @@ -122,7 +122,7 @@ impl Device { let tx = self.tx.clone(); tokio::spawn(async move { time::sleep(Duration::from_millis(5)).await; - tx.send(DeviceStatusNtfBuilder { device_state }.build().into()) + tx.send(CoreDeviceStatusNtfBuilder { device_state }.build().into()) .unwrap() }); } @@ -180,13 +180,13 @@ impl Device { // The fira norm specify to send a response, then reset, then // send a notification once the reset is done - fn core_device_reset(&mut self, cmd: DeviceResetCmd) -> DeviceResetRsp { + fn core_device_reset(&mut self, cmd: CoreDeviceResetCmd) -> CoreDeviceResetRsp { let reset_config = cmd.get_reset_config(); log::debug!("[{}] DeviceReset", self.handle); log::debug!(" reset_config={:?}", reset_config); let status = match reset_config { - ResetConfig::UwbsReset => StatusCode::UciStatusOk, + ResetConfig::UwbsReset => uci::Status::Ok, }; *self = Device::new( self.handle, @@ -196,15 +196,15 @@ impl Device { ); self.init(); - DeviceResetRspBuilder { status }.build() + CoreDeviceResetRspBuilder { status }.build() } - fn core_get_device_info(&self, _cmd: GetDeviceInfoCmd) -> GetDeviceInfoRsp { + fn core_get_device_info(&self, _cmd: CoreGetDeviceInfoCmd) -> CoreGetDeviceInfoRsp { // TODO: Implement a fancy build time state machine instead of crash at runtime log::debug!("[{}] GetDeviceInfo", self.handle); assert_eq!(self.state, DeviceState::DeviceStateReady); - GetDeviceInfoRspBuilder { - status: StatusCode::UciStatusOk, + CoreGetDeviceInfoRspBuilder { + status: uci::Status::Ok, uci_version: UCI_VERSION, mac_version: MAC_VERSION, phy_version: PHY_VERSION, @@ -214,7 +214,7 @@ impl Device { .build() } - pub fn core_get_caps_info(&self, _cmd: GetCapsInfoCmd) -> GetCapsInfoRsp { + pub fn core_get_caps_info(&self, _cmd: CoreGetCapsInfoCmd) -> CoreGetCapsInfoRsp { log::debug!("[{}] GetCapsInfo", self.handle); let caps = DEFAULT_CAPS_INFO @@ -225,14 +225,14 @@ impl Device { }) .collect(); - GetCapsInfoRspBuilder { - status: StatusCode::UciStatusOk, + CoreGetCapsInfoRspBuilder { + status: uci::Status::Ok, tlvs: caps, } .build() } - pub fn core_set_config(&mut self, cmd: SetConfigCmd) -> SetConfigRsp { + pub fn core_set_config(&mut self, cmd: CoreSetConfigCmd) -> CoreSetConfigRsp { log::debug!("[{}] SetConfig", self.handle); assert_eq!(self.state, DeviceState::DeviceStateReady); // UCI 6.3 @@ -248,19 +248,19 @@ impl Device { let (status, parameters) = if invalid_config_status.is_empty() { self.config.extend(valid_parameters); - (StatusCode::UciStatusOk, Vec::new()) + (uci::Status::Ok, Vec::new()) } else { - (StatusCode::UciStatusInvalidParam, invalid_config_status) + (uci::Status::InvalidParam, invalid_config_status) }; - SetConfigRspBuilder { + CoreSetConfigRspBuilder { cfg_status: parameters, status, } .build() } - pub fn core_get_config(&self, cmd: GetConfigCmd) -> GetConfigRsp { + pub fn core_get_config(&self, cmd: CoreGetConfigCmd) -> CoreGetConfigRsp { log::debug!("[{}] GetConfig", self.handle); // TODO: do this config shall be set on device reset @@ -292,12 +292,12 @@ impl Device { ); let (status, parameters) = if invalid_parameters.is_empty() { - (StatusCode::UciStatusOk, valid_parameters) + (uci::Status::Ok, valid_parameters) } else { - (StatusCode::UciStatusInvalidParam, invalid_parameters) + (uci::Status::InvalidParam, invalid_parameters) }; - GetConfigRspBuilder { + CoreGetConfigRspBuilder { status, tlvs: parameters, } @@ -313,17 +313,17 @@ impl Device { log::debug!(" session_type={:?}", session_type); let status = if self.sessions.len() >= MAX_SESSION { - StatusCode::UciStatusMaxSessionsExceeded + uci::Status::MaxSessionsExceeded } else { match self.sessions.insert( session_id, Session::new(session_id, session_type, self.handle, self.tx.clone()), ) { - Some(_) => StatusCode::UciStatusSessionDuplicate, + Some(_) => uci::Status::SessionDuplicate, None => { // Should not fail self.session_mut(session_id).unwrap().init(); - StatusCode::UciStatusOk + uci::Status::Ok } } }; @@ -345,9 +345,9 @@ impl Device { } } self.sessions.remove(&session_id); - StatusCode::UciStatusOk + uci::Status::Ok } - None => StatusCode::UciStatusSessionNotExist, + None => uci::Status::SessionNotExist, }; SessionDeinitRspBuilder { status }.build() } @@ -356,7 +356,7 @@ impl Device { log::debug!("[{}] Session get count", self.handle); SessionGetCountRspBuilder { - status: StatusCode::UciStatusOk, + status: uci::Status::Ok, session_count: self.sessions.len() as u8, } .build() @@ -374,7 +374,7 @@ impl Device { let Some(session) = self.sessions.get_mut(&session_handle) else { return SessionSetAppConfigRspBuilder { cfg_status: Vec::new(), - status: StatusCode::UciStatusSessionNotExist, + status: uci::Status::SessionNotExist, } .build(); }; @@ -392,7 +392,7 @@ impl Device { .any(|cfg| IMMUTABLE_PARAMETERS.contains(&cfg.cfg_id)) { return SessionSetAppConfigRspBuilder { - status: StatusCode::UciStatusSessionActive, + status: uci::Status::SessionActive, cfg_status: vec![], } .build(); @@ -402,7 +402,7 @@ impl Device { let (status, invalid_parameters) = if session.state != SessionState::SessionStateInit && session.state != SessionState::SessionStateActive { - (StatusCode::UciStatusRejected, Vec::new()) + (uci::Status::Rejected, Vec::new()) } else { let mut app_config = session.app_config.clone(); let mut invalid_parameters = vec![]; @@ -411,7 +411,7 @@ impl Device { Ok(_) => (), Err(_) => invalid_parameters.push(AppConfigStatus { cfg_id: cfg.cfg_id, - status: uci::StatusCode::UciStatusInvalidParam, + status: uci::Status::InvalidParam, }), } } @@ -440,7 +440,7 @@ impl Device { session_handle ); return SessionSetAppConfigRspBuilder { - status: uci::StatusCode::UciStatusRejected, + status: uci::Status::Rejected, cfg_status: vec![], } .build(); @@ -454,9 +454,9 @@ impl Device { ReasonCode::StateChangeWithSessionManagementCommands, ); } - (StatusCode::UciStatusOk, invalid_parameters) + (uci::Status::Ok, invalid_parameters) } else { - (StatusCode::UciStatusInvalidParam, invalid_parameters) + (uci::Status::InvalidParam, invalid_parameters) } }; @@ -479,7 +479,7 @@ impl Device { let Some(session) = self.sessions.get(&session_handle) else { return SessionGetAppConfigRspBuilder { tlvs: vec![], - status: StatusCode::UciStatusSessionNotExist, + status: uci::Status::SessionNotExist, } .build(); }; @@ -501,9 +501,9 @@ impl Device { } if invalid_parameters.is_empty() { - (StatusCode::UciStatusOk, valid_parameters) + (uci::Status::Ok, valid_parameters) } else { - (StatusCode::UciStatusFailed, Vec::new()) + (uci::Status::Failed, Vec::new()) } }; @@ -522,13 +522,13 @@ impl Device { let Some(session) = self.sessions.get(&session_handle) else { return SessionGetStateRspBuilder { session_state: SessionState::SessionStateInit, - status: StatusCode::UciStatusSessionNotExist, + status: uci::Status::SessionNotExist, } .build(); }; SessionGetStateRspBuilder { - status: StatusCode::UciStatusOk, + status: uci::Status::Ok, session_state: session.state, } .build() @@ -548,7 +548,7 @@ impl Device { let Some(session) = self.sessions.get_mut(&session_handle) else { return SessionUpdateControllerMulticastListRspBuilder { - status: StatusCode::UciStatusSessionNotExist, + status: uci::Status::SessionNotExist, } .build(); }; @@ -559,7 +559,7 @@ impl Device { || session.app_config.multi_node_mode != Some(MultiNodeMode::OneToMany) { return SessionUpdateControllerMulticastListRspBuilder { - status: StatusCode::UciStatusRejected, + status: uci::Status::Rejected, } .build(); } @@ -578,7 +578,7 @@ impl Device { .collect() } else { return SessionUpdateControllerMulticastListRspBuilder { - status: StatusCode::UciStatusSyntaxError, + status: uci::Status::SyntaxError, } .build(); } @@ -596,7 +596,7 @@ impl Device { .collect() } else { return SessionUpdateControllerMulticastListRspBuilder { - status: StatusCode::UciStatusSyntaxError, + status: uci::Status::SyntaxError, } .build(); } @@ -614,14 +614,14 @@ impl Device { .collect() } else { return SessionUpdateControllerMulticastListRspBuilder { - status: StatusCode::UciStatusSyntaxError, + status: uci::Status::SyntaxError, } .build(); } } }; let mut controlee_status = Vec::new(); - let mut status = StatusCode::UciStatusOk; + let mut status = uci::Status::Ok; match action { UpdateMulticastListAction::AddControlee @@ -631,7 +631,7 @@ impl Device { let mut update_status = MulticastUpdateStatusCode::StatusOkMulticastListUpdate; if !dst_addresses.contains(&controlee.short_address) { if dst_addresses.len() == MAX_NUMBER_OF_CONTROLEES { - status = StatusCode::UciStatusMulticastListFull; + status = uci::Status::MulticastListFull; update_status = MulticastUpdateStatusCode::StatusErrorMulticastListFull; } else if (action == UpdateMulticastListAction::AddControleeWithShortSubSessionKey @@ -644,7 +644,7 @@ impl Device { // 0x04, the UWBS shall return SESSION_UPDATE_CONTROLLER_MULTICAST_LIST_NTF // with Status set to STATUS_ERROR_SUB_SESSION_KEY_NOT_APPLICABLE for each // Controlee in the Controlee List. - status = StatusCode::UciStatusFailed; + status = uci::Status::Failed; update_status = MulticastUpdateStatusCode::StatusErrorSubSessionKeyNotApplicable; } else { @@ -668,7 +668,7 @@ impl Device { let attempt_count = session.app_config.in_band_termination_attempt_count; let mut update_status = MulticastUpdateStatusCode::StatusOkMulticastListUpdate; if !dst_addresses.contains(&address) { - status = StatusCode::UciStatusAddressNotFound; + status = uci::Status::AddressNotFound; update_status = MulticastUpdateStatusCode::StatusErrorKeyFetchFail; } else { dst_addresses.retain(|value| *value != address); @@ -732,14 +732,14 @@ impl Device { let Some(session) = self.sessions.get_mut(&session_id) else { return SessionStartRspBuilder { - status: StatusCode::UciStatusSessionNotExist, + status: uci::Status::SessionNotExist, } .build(); }; if session.state != SessionState::SessionStateIdle { return SessionStartRspBuilder { - status: StatusCode::UciStatusSessionNotConfigured, + status: uci::Status::SessionNotConfigured, } .build(); } @@ -769,7 +769,7 @@ impl Device { self.set_state(DeviceState::DeviceStateActive); SessionStartRspBuilder { - status: StatusCode::UciStatusOk, + status: uci::Status::Ok, } .build() } @@ -781,14 +781,14 @@ impl Device { let Some(session) = self.sessions.get_mut(&session_id) else { return SessionStopRspBuilder { - status: StatusCode::UciStatusSessionNotExist, + status: uci::Status::SessionNotExist, } .build(); }; if session.state != SessionState::SessionStateActive { return SessionStopRspBuilder { - status: StatusCode::UciStatusSessionActive, + status: uci::Status::SessionActive, } .build(); } @@ -805,7 +805,7 @@ impl Device { } SessionStopRspBuilder { - status: StatusCode::UciStatusOk, + status: uci::Status::Ok, } .build() } @@ -824,14 +824,14 @@ impl Device { let Some(session) = self.sessions.get(&session_id) else { return SessionGetRangingCountRspBuilder { - status: StatusCode::UciStatusSessionNotExist, + status: uci::Status::SessionNotExist, count: 0, } .build(); }; SessionGetRangingCountRspBuilder { - status: StatusCode::UciStatusOk, + status: uci::Status::Ok, count: session.sequence_number, } .build() @@ -847,7 +847,7 @@ impl Device { self.country_code = country_code; AndroidSetCountryCodeRspBuilder { - status: StatusCode::UciStatusOk, + status: uci::Status::Ok, } .build() } @@ -861,7 +861,7 @@ impl Device { // TODO AndroidGetPowerStatsRspBuilder { stats: PowerStats { - status: StatusCode::UciStatusOk, + status: uci::Status::Ok, idle_time_ms: 0, tx_time_ms: 0, rx_time_ms: 0, @@ -871,7 +871,7 @@ impl Device { .build() } - pub fn data_message_snd(&mut self, data: DataPacket) -> SessionControlNotification { + pub fn data_message_snd(&mut self, data: DataPacket) -> ControlPacket { log::debug!("[{}] data_message_send", self.handle); match data.specialize() { DataPacketChild::DataMessageSnd(data_msg_snd) => { @@ -879,7 +879,7 @@ impl Device { if let Some(session) = self.session_mut(session_token) { session.data_message_snd(data_msg_snd) } else { - DataTransferStatusNtfBuilder { + SessionDataTransferStatusNtfBuilder { session_token, status: DataTransferNtfStatusCode::UciDataTransferStatusErrorRejected, tx_count: 1, // TODO: support for retries? @@ -892,7 +892,7 @@ impl Device { DataPacketChild::DataMessageRcv(data_msg_rcv) => { // This function should not be passed anything besides DataMessageSnd let session_token = data_msg_rcv.get_session_handle(); - DataTransferStatusNtfBuilder { + SessionDataTransferStatusNtfBuilder { session_token, status: DataTransferNtfStatusCode::UciDataTransferStatusInvalidFormat, tx_count: 1, // TODO: support for retries? @@ -907,23 +907,23 @@ impl Device { } } - fn receive_command(&mut self, cmd: UciCommand) -> UciResponse { - use AndroidCommandChild::*; - use CoreCommandChild::*; - use SessionConfigCommandChild::*; - use SessionControlCommandChild::*; - use UciCommandChild::*; + fn receive_command(&mut self, cmd: ControlPacket) -> ControlPacket { + use AndroidPacketChild::*; + use ControlPacketChild::*; + use CorePacketChild::*; + use SessionConfigPacketChild::*; + use SessionControlPacketChild::*; match cmd.specialize() { - CoreCommand(cmd) => match cmd.specialize() { - DeviceResetCmd(cmd) => self.core_device_reset(cmd).into(), - GetDeviceInfoCmd(cmd) => self.core_get_device_info(cmd).into(), - GetCapsInfoCmd(cmd) => self.core_get_caps_info(cmd).into(), - SetConfigCmd(cmd) => self.core_set_config(cmd).into(), - GetConfigCmd(cmd) => self.core_get_config(cmd).into(), - _ => panic!("Unsupported Core command 0x{:02x}", cmd.get_opcode()), + CorePacket(cmd) => match cmd.specialize() { + CoreDeviceResetCmd(cmd) => self.core_device_reset(cmd).into(), + CoreGetDeviceInfoCmd(cmd) => self.core_get_device_info(cmd).into(), + CoreGetCapsInfoCmd(cmd) => self.core_get_caps_info(cmd).into(), + CoreSetConfigCmd(cmd) => self.core_set_config(cmd).into(), + CoreGetConfigCmd(cmd) => self.core_get_config(cmd).into(), + _ => unimplemented!("Unsupported Core oid {:?}", cmd.get_oid()), }, - SessionConfigCommand(cmd) => match cmd.specialize() { + SessionConfigPacket(cmd) => match cmd.specialize() { SessionInitCmd(cmd) => self.session_init(cmd).into(), SessionDeinitCmd(cmd) => self.session_deinit(cmd).into(), SessionGetCountCmd(cmd) => self.session_get_count(cmd).into(), @@ -933,62 +933,47 @@ impl Device { SessionUpdateControllerMulticastListCmd(cmd) => { self.session_update_controller_multicast_list(cmd).into() } - _ => panic!( - "Unsupported Session Config command 0x{:02x}", - cmd.get_opcode() - ), + _ => unimplemented!("Unsupported Session Config oid {:?}", cmd.get_oid()), }, - SessionControlCommand(cmd) => match cmd.specialize() { + SessionControlPacket(cmd) => match cmd.specialize() { SessionStartCmd(cmd) => self.session_start(cmd).into(), SessionStopCmd(cmd) => self.session_stop(cmd).into(), SessionGetRangingCountCmd(cmd) => self.session_get_ranging_count(cmd).into(), - _ => panic!( - "Unsupported Session Control command 0x{:02x}", - cmd.get_opcode() - ), + _ => unimplemented!("Unsupported Session Control oid {:?}", cmd.get_oid()), }, - AndroidCommand(cmd) => match cmd.specialize() { + AndroidPacket(cmd) => match cmd.specialize() { AndroidSetCountryCodeCmd(cmd) => self.android_set_country_code(cmd).into(), AndroidGetPowerStatsCmd(cmd) => self.android_get_power_stats(cmd).into(), - _ => panic!("Unsupported Android command 0x{:02x}", cmd.get_opcode()), + _ => unimplemented!("Unsupported Android oid {:?}", cmd.get_oid()), }, - UciVendor_9_Command(vendor_command) => UciVendor_9_ResponseBuilder { - opcode: vendor_command.get_opcode(), - payload: Some(vec![u8::from(StatusCode::UciStatusRejected)].into()), - } - .build() - .into(), - UciVendor_A_Command(vendor_command) => UciVendor_A_ResponseBuilder { - opcode: vendor_command.get_opcode(), - payload: Some(vec![u8::from(StatusCode::UciStatusRejected)].into()), - } - .build() - .into(), - UciVendor_B_Command(vendor_command) => UciVendor_B_ResponseBuilder { - opcode: vendor_command.get_opcode(), - payload: Some(vec![u8::from(StatusCode::UciStatusRejected)].into()), - } - .build() - .into(), - UciVendor_E_Command(vendor_command) => UciVendor_E_ResponseBuilder { - opcode: vendor_command.get_opcode(), - payload: Some(vec![u8::from(StatusCode::UciStatusRejected)].into()), + ControlPacketChild::Payload(_) + if matches!( + cmd.get_mt(), + uci::MessageType::Response | uci::MessageType::Notification + ) => + { + unreachable!("Unhandled control messsage with type {:?}", cmd.get_mt()); } - .build() - .into(), - UciVendor_F_Command(vendor_command) => UciVendor_F_ResponseBuilder { - opcode: vendor_command.get_opcode(), - payload: Some(vec![u8::from(StatusCode::UciStatusRejected)].into()), + ControlPacketChild::Payload(payload) => { + // [UCI] 4.3.2 Exception Handling for Control Messages + // The UWBS shall respond to an unknown Command (unknown GID + // or OID) with a Response having the same GID and OID field + // values as the Command, followed by a Status field with the + // value of STATUS_UNKNOWN_GID/STATUS_UNKNOWN_OID respectively + // and no additional fields. + log::error!("Unsupported gid {:?}", cmd.get_gid()); + ControlPacketBuilder { + mt: uci::MessageType::Response, + gid: cmd.get_gid(), + payload: Some( + vec![payload[0], payload[1], 0x1, uci::Status::UnknownGid.into()].into(), + ), + } + .build() } - .build() - .into(), - // TODO: Handle properly without panic - _ => UciResponseBuilder { - gid: GroupId::Core, - opcode: 0, - payload: Option::None, + ControlPacketChild::None => { + unreachable!() } - .build(), } } @@ -1017,9 +1002,9 @@ impl Device { let opcode_id = packet[1] & 0x3f; let status = if GroupId::try_from(group_id).is_ok() { - StatusCode::UciStatusUnknownOid + uci::Status::UnknownOid } else { - StatusCode::UciStatusUnknownGid + uci::Status::UnknownGid }; // The PDL generated code cannot be used to generate // responses with invalid group identifiers. @@ -1035,7 +1020,7 @@ impl Device { // Parsing success, ignore non command packets. Ok(cmd) => { - let response = self.receive_command(cmd.try_into().unwrap()); + let response = self.receive_command(cmd); self.send_control(response) } } @@ -24,8 +24,7 @@ use tokio::sync::{broadcast, mpsc, oneshot}; pub mod packets; mod pcapng; -use packets::uci::StatusCode as UciStatusCode; -use packets::uci::*; +use packets::uci::{self, *}; mod device; use device::{Device, MAX_DEVICE, MAX_SESSION}; @@ -162,7 +161,7 @@ fn make_measurement( if let MacAddress::Short(address) = mac_address { ShortAddressTwoWayRangingMeasurement { mac_address: u16::from_le_bytes(*address), - status: UciStatusCode::UciStatusOk, + status: uci::Status::Ok, nlos: 0, // in Line Of Sight distance: local.range, aoa_azimuth: local.azimuth as u16, @@ -469,7 +468,7 @@ impl Pica { pbf: PacketBoundaryFlag::Complete, session_handle: session_id, source_address: device.mac_address.into(), - status: UciStatusCode::UciStatusOk, + status: uci::Status::Ok, } .build() .into(), diff --git a/src/session.rs b/src/session.rs index 4a67593..f3ee408 100644 --- a/src/session.rs +++ b/src/session.rs @@ -130,13 +130,13 @@ impl Session { } } - pub fn data_message_snd(&mut self, data: DataMessageSnd) -> SessionControlNotification { + pub fn data_message_snd(&mut self, data: DataMessageSnd) -> ControlPacket { log::debug!("[{}] data_message_snd", self.device_handle); let session_token = data.get_session_handle(); let uci_sequence_number = data.get_data_sequence_number() as u8; if self.session_type != SessionType::FiraRangingAndInBandDataSession { - return DataTransferStatusNtfBuilder { + return SessionDataTransferStatusNtfBuilder { session_token, status: DataTransferNtfStatusCode::UciDataTransferStatusSessionTypeNotSupported, tx_count: 1, // TODO: support for retries? @@ -150,7 +150,7 @@ impl Session { self.data.extend_from_slice(data.get_application_data()); - DataCreditNtfBuilder { + SessionDataCreditNtfBuilder { credit_availability: CreditAvailability::CreditAvailable, session_token, } diff --git a/src/uci_packets.pdl b/src/uci_packets.pdl index ebb8db2..7d1fc2e 100644 --- a/src/uci_packets.pdl +++ b/src/uci_packets.pdl @@ -15,150 +15,131 @@ little_endian_packets enum PacketBoundaryFlag : 1 { - COMPLETE = 0x00, - NOT_COMPLETE = 0x01, + COMPLETE = 0, + NOT_COMPLETE = 1, +} + +enum MessageType : 3 { + DATA = 0x0, + COMMAND = 0x1, + RESPONSE = 0x2, + NOTIFICATION = 0x3, } enum GroupId : 4 { - CORE = 0x00, - SESSION_CONFIG = 0x01, - SESSION_CONTROL = 0x02, - DATA_CONTROL = 0x03, - TEST = 0x0d, - VENDOR_RESERVED_9 = 0x09, - VENDOR_RESERVED_A = 0x0a, - VENDOR_RESERVED_B = 0x0b, - VENDOR_ANDROID = 0x0c, - VENDOR_RESERVED_E = 0x0e, - VENDOR_RESERVED_F = 0x0f, -} - -enum DataPacketFormat: 4 { + CORE = 0x0, + SESSION_CONFIG = 0x1, + SESSION_CONTROL = 0x2, + DATA_CONTROL = 0x3, + VENDOR_RESERVED_9 = 0x9, + VENDOR_RESERVED_A = 0xa, + VENDOR_RESERVED_B = 0xb, + VENDOR_ANDROID = 0xc, + TEST = 0xd, + VENDOR_RESERVED_E = 0xe, + VENDOR_RESERVED_F = 0xf, +} + +enum DataPacketFormat : 4 { DATA_SND = 0x01, DATA_RCV = 0x02, } -// Define a merged enum across GroupId & DataPacketFormat as they are at the same bits in -// |UciPacketHal|. -enum GroupIdOrDataPacketFormat : 4 { - CORE = 0x00, - SESSION_CONFIG_OR_DATA_SND = 0x01, - SESSION_CONTROL_OR_DATA_RCV = 0x02, - DATA_CONTROL = 0x03, - TEST = 0x0d, - VENDOR_RESERVED_9 = 0x09, - VENDOR_RESERVED_A = 0x0a, - VENDOR_RESERVED_B = 0x0b, - VENDOR_ANDROID = 0x0c, - VENDOR_RESERVED_E = 0x0e, - VENDOR_RESERVED_F = 0x0f, -} - -enum CoreOpCode : 6 { - CORE_DEVICE_RESET = 0x00, - CORE_DEVICE_STATUS_NTF = 0x01, - CORE_DEVICE_INFO = 0x02, - CORE_GET_CAPS_INFO = 0x03, - CORE_SET_CONFIG = 0x04, - CORE_GET_CONFIG = 0x05, - CORE_DEVICE_SUSPEND = 0x06, - CORE_GENERIC_ERROR_NTF = 0x07, - CORE_QUERY_UWBS_TIMESTAMP = 0x08, -} - -enum SessionConfigOpCode : 6 { - SESSION_INIT = 0x00, - SESSION_DEINIT = 0x01, - SESSION_STATUS_NTF = 0x02, - SESSION_SET_APP_CONFIG = 0x03, - SESSION_GET_APP_CONFIG = 0x04, - SESSION_GET_COUNT = 0x05, - SESSION_GET_STATE = 0x06, - SESSION_UPDATE_CONTROLLER_MULTICAST_LIST = 0x07, - SESSION_UPDATE_ACTIVE_ROUNDS_ANCHOR = 0x08, - SESSION_UPDATE_ACTIVE_ROUNDS_DT_TAG = 0x09, - SESSION_SET_INITIATOR_DT_ANCHOR_RR_RDM_LIST = 0x0a, - SESSION_QUERY_DATA_SIZE_IN_RANGING = 0x0b, - SESSION_SET_HUS_CONFIG = 0x0c, -} - -enum SessionControlOpCode : 6 { - SESSION_START = 0x00, - SESSION_STOP = 0x01, - SESSION_RESERVED = 0x02, - SESSION_GET_RANGING_COUNT = 0x03, - SESSION_DATA_CREDIT_NTF = 0x04, - SESSION_DATA_TRANSFER_STATUS_NTF = 0x05, -} - -enum AppDataOpCode : 6 { - APP_DATA_TX = 0x00, - APP_DATA_RX = 0x01, -} - -// Android vendor commands -enum AndroidOpCode : 6 { - ANDROID_GET_POWER_STATS = 0x0, - ANDROID_SET_COUNTRY_CODE = 0x1, - ANDROID_FIRA_RANGE_DIAGNOSTICS = 0x2, -} - -enum StatusCode : 8 { +enum CoreOpcodeId : 6 { + DEVICE_RESET = 0x00, + DEVICE_STATUS = 0x01, + GET_DEVICE_INFO = 0x02, + GET_CAPS_INFO = 0x03, + SET_CONFIG = 0x04, + GET_CONFIG = 0x05, + GENERIC_ERROR = 0x07, + QUERY_UWBS_TIMESTAMP = 0x08, +} + +enum SessionConfigOpcodeId : 6 { + INIT = 0x00, + DEINIT = 0x01, + STATUS = 0x02, + SET_APP_CONFIG = 0x03, + GET_APP_CONFIG = 0x04, + GET_COUNT = 0x05, + GET_STATE = 0x06, + UPDATE_CONTROLLER_MULTICAST_LIST = 0x07, + UPDATE_DT_ANCHOR_RANGING_ROUNDS = 0x08, + UPDATE_DT_TAG_RANGING_ROUNDS = 0x09, + QUERY_DATA_SIZE_IN_RANGING = 0x0b, +} + +enum SessionControlOpcodeId : 6 { + START = 0x00, // INFO_NTF + STOP = 0x01, + GET_RANGING_COUNT = 0x03, + DATA_CREDIT = 0x04, + DATA_TRANSFER_STATUS = 0x05, +} + +enum AndroidOpcodeId : 6 { + GET_POWER_STATS = 0x00, + SET_COUNTRY_CODE = 0x01, + FIRA_RANGE_DIAGNOSTICS = 0x02, +} + +enum Status : 8 { // Generic Status Codes - UCI_STATUS_OK = 0x00, - UCI_STATUS_REJECTED = 0x01, - UCI_STATUS_FAILED = 0x02, - UCI_STATUS_SYNTAX_ERROR = 0x03, - UCI_STATUS_INVALID_PARAM = 0x04, - UCI_STATUS_INVALID_RANGE = 0x05, - UCI_STATUS_INVALID_MSG_SIZE = 0x06, - UCI_STATUS_UNKNOWN_GID = 0x07, - UCI_STATUS_UNKNOWN_OID = 0x08, - UCI_STATUS_READ_ONLY = 0x09, - UCI_STATUS_COMMAND_RETRY = 0x0A, - UCI_STATUS_UNKNOWN = 0x0B, - UCI_STATUS_NOT_APPLICABLE = 0x0C, + OK = 0x00, + REJECTED = 0x01, + FAILED = 0x02, + SYNTAX_ERROR = 0x03, + INVALID_PARAM = 0x04, + INVALID_RANGE = 0x05, + INVALID_MSG_SIZE = 0x06, + UNKNOWN_GID = 0x07, + UNKNOWN_OID = 0x08, + READ_ONLY = 0x09, + COMMAND_RETRY = 0x0A, + UNKNOWN = 0x0B, + NOT_APPLICABLE = 0x0C, RFU_STATUS_CODE_RANGE_1 = 0x0D..0x10, // UWB Session Specific Status Codes - UCI_STATUS_SESSION_NOT_EXIST = 0x11, - UCI_STATUS_SESSION_DUPLICATE = 0x12, - UCI_STATUS_SESSION_ACTIVE = 0x13, - UCI_STATUS_MAX_SESSIONS_EXCEEDED = 0x14, - UCI_STATUS_SESSION_NOT_CONFIGURED = 0x15, - UCI_STATUS_ACTIVE_SESSIONS_ONGOING = 0x16, - UCI_STATUS_MULTICAST_LIST_FULL = 0x17, - UCI_STATUS_ADDRESS_NOT_FOUND = 0x18, - UCI_STATUS_ADDRESS_ALREADY_PRESENT = 0x19, - UCI_STATUS_ERROR_UWB_INITIATION_TIME_TOO_OLD = 0x1A, - UCI_STATUS_OK_NEGATIVE_DISTANCE_REPORT = 0x1B, + SESSION_NOT_EXIST = 0x11, + SESSION_DUPLICATE = 0x12, + SESSION_ACTIVE = 0x13, + MAX_SESSIONS_EXCEEDED = 0x14, + SESSION_NOT_CONFIGURED = 0x15, + ACTIVE_SESSIONS_ONGOING = 0x16, + MULTICAST_LIST_FULL = 0x17, + ADDRESS_NOT_FOUND = 0x18, + ADDRESS_ALREADY_PRESENT = 0x19, + ERROR_UWB_INITIATION_TIME_TOO_OLD = 0x1A, + OK_NEGATIVE_DISTANCE_REPORT = 0x1B, RFU_STATUS_CODE_RANGE_2 = 0x1C..0x1F, // UWB Ranging Session Specific Status Codes - UCI_STATUS_RANGING_TX_FAILED = 0x20, - UCI_STATUS_RANGING_RX_TIMEOUT = 0x21, - UCI_STATUS_RANGING_RX_PHY_DEC_FAILED = 0x22, - UCI_STATUS_RANGING_RX_PHY_TOA_FAILED = 0x23, - UCI_STATUS_RANGING_RX_PHY_STS_FAILED = 0x24, - UCI_STATUS_RANGING_RX_MAC_DEC_FAILED = 0x25, - UCI_STATUS_RANGING_RX_MAC_IE_DEC_FAILED = 0x26, - UCI_STATUS_RANGING_RX_MAC_IE_MISSING = 0x27, - UCI_STATUS_ERROR_ROUND_INDEX_NOT_ACTIVATED = 0x28, - UCI_STATUS_ERROR_NUMBER_OF_ACTIVE_RANGING_ROUNDS_EXCEEDED = 0x29, - UCI_STATUS_ERROR_DL_TDOA_DEVICE_ADDRESS_NOT_MATCHING_IN_REPLY_TIME_LIST = 0x2A, + RANGING_TX_FAILED = 0x20, + RANGING_RX_TIMEOUT = 0x21, + RANGING_RX_PHY_DEC_FAILED = 0x22, + RANGING_RX_PHY_TOA_FAILED = 0x23, + RANGING_RX_PHY_STS_FAILED = 0x24, + RANGING_RX_MAC_DEC_FAILED = 0x25, + RANGING_RX_MAC_IE_DEC_FAILED = 0x26, + RANGING_RX_MAC_IE_MISSING = 0x27, + ERROR_ROUND_INDEX_NOT_ACTIVATED = 0x28, + ERROR_NUMBER_OF_ACTIVE_RANGING_ROUNDS_EXCEEDED = 0x29, + ERROR_DL_TDOA_DEVICE_ADDRESS_NOT_MATCHING_IN_REPLY_TIME_LIST = 0x2A, RFU_STATUS_CODE_RANGE_3 = 0x2B..0x2F, // UWB Data Session Specific Status Codes - UCI_STATUS_DATA_MAX_TX_PSDU_SIZE_EXCEEDED = 0x30, - UCI_STATUS_DATA_RX_CRC_ERROR = 0x31, + DATA_MAX_TX_PSDU_SIZE_EXCEEDED = 0x30, + DATA_RX_CRC_ERROR = 0x31, RFU_STATUS_CODE_RANGE_4 = 0x32..0x4F, // Vendor Specific Status Codes VENDOR_SPECIFIC_STATUS_CODE_RANGE_1 = 0x50..0xFE { - UCI_STATUS_ERROR_CCC_SE_BUSY = 0x50, - UCI_STATUS_ERROR_CCC_LIFECYCLE = 0x51, - UCI_STATUS_ERROR_STOPPED_DUE_TO_OTHER_SESSION_CONFLICT = 0x52, - UCI_STATUS_REGULATION_UWB_OFF = 0x53, + ERROR_CCC_SE_BUSY = 0x50, + ERROR_CCC_LIFECYCLE = 0x51, + ERROR_STOPPED_DUE_TO_OTHER_SESSION_CONFLICT = 0x52, + REGULATION_UWB_OFF = 0x53, }, // For internal usage, we will use 0xFF as default. @@ -640,15 +621,6 @@ enum SessionType: 8 { DEVICE_TEST_MODE = 0xD0, } -enum MessageType: 3 { - DATA = 0x00, - COMMAND = 0x01, - RESPONSE = 0x02, - NOTIFICATION = 0x03, - RESERVED_FOR_TESTING_1 = 0x04, - RESERVED_FOR_TESTING_2 = 0x05, -} - // Used to parse message type packet CommonPacketHeader { _reserved_ : 4, @@ -681,9 +653,6 @@ packet ControlPacket { gid : GroupId, _reserved_ : 1, mt : MessageType, - opcode: 6, - _reserved_: 2, - _reserved_: 16, _payload_, } @@ -706,109 +675,76 @@ packet DataMessageSnd : DataPacket (dpf = DATA_SND, mt = DATA) { packet DataMessageRcv : DataPacket (dpf = DATA_RCV, mt = DATA) { session_handle: 32, - status : StatusCode, + status: Status, source_address: 64, data_sequence_number: 16, _size_(application_data): 16, application_data: 8[] } -// TODO(b/202760099): Handle fragmentation of packets if the size exceed max allowed. -packet UciCommand : ControlPacket (mt = COMMAND) { - _payload_, -} - -packet UciResponse : ControlPacket (mt = RESPONSE) { - _payload_, -} - -packet UciNotification : ControlPacket (mt = NOTIFICATION) { - _payload_, -} - -packet CoreCommand : UciCommand (gid = CORE) { - _body_, -} - -packet CoreResponse : UciResponse (gid = CORE) { - _body_, -} - -packet CoreNotification : UciNotification (gid = CORE) { - _body_, -} - -packet SessionConfigCommand : UciCommand (gid = SESSION_CONFIG) { - _body_, -} - -packet SessionConfigResponse : UciResponse (gid = SESSION_CONFIG) { - _body_, -} - -packet SessionConfigNotification : UciNotification (gid = SESSION_CONFIG) { - _body_, -} - -packet SessionControlCommand : UciCommand (gid = SESSION_CONTROL) { - session_id: 32, - _body_, -} - -packet SessionControlResponse : UciResponse (gid = SESSION_CONTROL) { - _body_, +packet CorePacket : ControlPacket (gid = CORE) { + oid : CoreOpcodeId, + _reserved_ : 2, + _reserved_ : 16, + _payload_, } -packet SessionControlNotification : UciNotification (gid = SESSION_CONTROL) { - _body_, +packet SessionConfigPacket : ControlPacket (gid = SESSION_CONFIG) { + oid : SessionConfigOpcodeId, + _reserved_ : 2, + _reserved_ : 16, + _payload_, } -packet AndroidCommand : UciCommand (gid = VENDOR_ANDROID) { - _body_, +packet SessionControlPacket : ControlPacket (gid = SESSION_CONTROL) { + oid : SessionControlOpcodeId, + _reserved_ : 2, + _reserved_ : 16, + _payload_, } -packet AndroidResponse : UciResponse (gid = VENDOR_ANDROID) { - _body_, +packet AndroidPacket : ControlPacket (gid = VENDOR_ANDROID) { + oid : AndroidOpcodeId, + _reserved_ : 2, + _reserved_ : 16, + _payload_, } -packet AndroidNotification : UciNotification (gid = VENDOR_ANDROID) { - _body_, -} +// ---------------------------- Core group ---------------------------------- // -// TODO: b/202760099: Use the correspnding opcode enum instead of the raw value in the |opcode| field. -packet DeviceResetCmd : CoreCommand (opcode = 0x0) { //CORE_DEVICE_RESET +packet CoreDeviceResetCmd : CorePacket (mt = COMMAND, oid = DEVICE_RESET) { reset_config: ResetConfig, } -test DeviceResetCmd { +test CoreDeviceResetCmd { "\x20\x00\x00\x01\x00\x00\x00\x00", } -packet DeviceResetRsp : CoreResponse (opcode = 0x0) { //CORE_DEVICE_RESET - status: StatusCode, +packet CoreDeviceResetRsp : CorePacket (mt = RESPONSE, oid = DEVICE_RESET) { + status: Status, } -test DeviceResetRsp { +test CoreDeviceResetRsp { "\x40\x00\x00\x01\x00\x00\x00\x00", } -packet DeviceStatusNtf : CoreNotification (opcode = 0x1) { //CORE_DEVICE_STATUS_NTF +packet CoreDeviceStatusNtf : CorePacket (mt = NOTIFICATION, oid = DEVICE_STATUS) { device_state: DeviceState, } -test DeviceStatusNtf { +test CoreDeviceStatusNtf { "\x60\x01\x00\x01\x00\x00\x00\x01", } -packet GetDeviceInfoCmd : CoreCommand (opcode = 0x2) { //CORE_DEVICE_INFO +packet CoreGetDeviceInfoCmd : CorePacket (mt = COMMAND, oid = GET_DEVICE_INFO) { } -test GetDeviceInfoCmd { +test CoreGetDeviceInfoCmd { "\x20\x02\x00\x00\x00\x00\x00", } -packet GetDeviceInfoRsp : CoreResponse (opcode = 0x2) { //CORE_DEVICE_INFO - status: StatusCode, +packet CoreGetDeviceInfoRsp : CorePacket (mt = RESPONSE, oid = GET_DEVICE_INFO) { + status: Status, uci_version: 16, mac_version: 16, phy_version: 16, @@ -817,14 +753,14 @@ packet GetDeviceInfoRsp : CoreResponse (opcode = 0x2) { //CORE_DEVICE_INFO vendor_spec_info: 8[], } -test GetDeviceInfoRsp { +test CoreGetDeviceInfoRsp { "\x40\x02\x00\x0b\x00\x00\x00\x01\x01\x00\x02\x00\x03\x00\x04\x00\x01\x0a", } -packet GetCapsInfoCmd : CoreCommand (opcode = 0x3) { //CORE_GET_CAPS_INFO +packet CoreGetCapsInfoCmd : CorePacket (mt = COMMAND, oid = GET_CAPS_INFO) { } -test GetCapsInfoCmd { +test CoreGetCapsInfoCmd { "\x20\x03\x00\x00\x00\x00\x00", } @@ -835,13 +771,13 @@ struct CapTlv { } -packet GetCapsInfoRsp : CoreResponse (opcode = 0x3) { //CORE_GET_CAPS_INFO - status: StatusCode, +packet CoreGetCapsInfoRsp : CorePacket (mt = RESPONSE, oid = GET_CAPS_INFO) { + status: Status, _count_(tlvs): 8, tlvs: CapTlv[], } -test GetCapsInfoRsp { +test CoreGetCapsInfoRsp { "\x40\x03\x00\x05\x00\x00\x00\x00\x01\x00\x01\x01", } @@ -851,68 +787,68 @@ struct DeviceConfigTlv { v: 8[], } -packet SetConfigCmd : CoreCommand (opcode = 0x4) { //CORE_SET_CONFIG +packet CoreSetConfigCmd : CorePacket (mt = COMMAND, oid = SET_CONFIG) { _count_(tlvs): 8, tlvs: DeviceConfigTlv[], } -test SetConfigCmd { +test CoreSetConfigCmd { "\x20\x04\x00\x03\x00\x00\x00\x01\x01\x00", } struct DeviceConfigStatus { cfg_id: DeviceConfigId, - status: StatusCode, + status: Status, } -packet SetConfigRsp : CoreResponse (opcode = 0x4) { //CORE_SET_CONFIG - status: StatusCode, +packet CoreSetConfigRsp : CorePacket (mt = RESPONSE, oid = SET_CONFIG) { + status: Status, _count_(cfg_status): 8, cfg_status: DeviceConfigStatus[], } -test SetConfigRsp { +test CoreSetConfigRsp { "\x40\x04\x00\x04\x00\x00\x00\x01\x01\x01\x01", "\x40\x04\x00\x04\x00\x00\x00\x01\x01\x01\x0B", } -packet GetConfigCmd : CoreCommand (opcode = 0x5) { //CORE_GET_CONFIG +packet CoreGetConfigCmd : CorePacket (mt = COMMAND, oid = GET_CONFIG) { _count_(cfg_id): 8, cfg_id: 8[], // DeviceConfigId } -test GetConfigCmd { +test CoreGetConfigCmd { "\x20\x05\x00\x02\x00\x00\x00\x01\x01", } -packet GetConfigRsp : CoreResponse (opcode = 0x5) { //CORE_GET_CONFIG - status: StatusCode, +packet CoreGetConfigRsp : CorePacket (mt = RESPONSE, oid = GET_CONFIG) { + status: Status, _count_(tlvs): 8, tlvs: DeviceConfigTlv[] } -test GetConfigRsp { +test CoreGetConfigRsp { "\x40\x05\x00\x05\x00\x00\x00\x01\x01\x00\x01\x01", } -packet GenericError : CoreNotification (opcode = 0x7) { //CORE_GENERIC_ERROR_NTF - status: StatusCode, +packet CoreGenericErrorNtf : CorePacket (mt = NOTIFICATION, oid = GENERIC_ERROR) { + status: Status, } -test GenericError { +test CoreGenericErrorNtf { "\x60\x07\x00\x01\x00\x00\x00\x01", } -packet CoreQueryTimeStampCmd : CoreCommand (opcode = 0x8) { //CORE_QUERY_UWBS_TIMESTAMP +packet CoreQueryTimeStampCmd : CorePacket (mt = COMMAND, oid = QUERY_UWBS_TIMESTAMP) { } test CoreQueryTimeStampCmd { "\x20\x08\x00\\x00", } -packet CoreQueryTimeStampRsp : CoreResponse (opcode = 0x8) { //CORE_QUERY_UWBS_TIMESTAMP - status: StatusCode, +packet CoreQueryTimeStampRsp : CorePacket (mt = RESPONSE, oid = QUERY_UWBS_TIMESTAMP) { + status: Status, timeStamp: 64, } @@ -920,7 +856,9 @@ test CoreQueryTimeStampRsp { "\x40\x08\x00\x09\x00\x00\x00\x01\x01\x00\x01\x01\x01", } -packet SessionInitCmd : SessionConfigCommand (opcode = 0x0) { //SESSION_INIT +// ---------------------- Session Config group ------------------------------ // + +packet SessionInitCmd : SessionConfigPacket (mt = COMMAND, oid = INIT) { session_id: 32, session_type: SessionType, } @@ -931,8 +869,8 @@ test SessionInitCmd { // 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, +packet SessionInitRsp_V2 : SessionConfigPacket (mt = RESPONSE, oid = INIT) { + status: Status, session_handle: 32, } @@ -940,15 +878,15 @@ test SessionInitRsp_V2 { "\x41\x00\x00\x01\x00\x00\x00\x11\x00\x00\x00\x01", } -packet SessionInitRsp : SessionConfigResponse (opcode = 0x0) { //SESSION_INIT - status: StatusCode, +packet SessionInitRsp : SessionConfigPacket (mt = RESPONSE, oid = INIT) { + status: Status, } test SessionInitRsp { "\x41\x00\x00\x01\x00\x00\x00\x11", } -packet SessionDeinitCmd : SessionConfigCommand (opcode = 0x1) { //SESSION_DEINIT +packet SessionDeinitCmd : SessionConfigPacket (mt = COMMAND, oid = DEINIT) { session_token: 32, // Session ID or Session Handle (based on UWBS version) } @@ -956,15 +894,15 @@ test SessionDeinitCmd { "\x21\x01\x00\x04\x00\x00\x00\x01\x02\x03\x04", } -packet SessionDeinitRsp : SessionConfigResponse (opcode = 0x1) { //SESSION_DEINIT - status: StatusCode, +packet SessionDeinitRsp : SessionConfigPacket (mt = RESPONSE, oid = DEINIT) { + status: Status, } test SessionDeinitRsp { "\x41\x01\x00\x01\x00\x00\x00\x00", } -packet SessionStatusNtf : SessionConfigNotification (opcode = 0x2) { //SESSION_STATUS_NTF +packet SessionStatusNtf : SessionConfigPacket (mt = NOTIFICATION, oid = STATUS) { 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 @@ -983,7 +921,7 @@ struct AppConfigTlv { v: 8[], } -packet SessionSetAppConfigCmd : SessionConfigCommand (opcode = 0x3) { //SESSION_SET_APP_CONFIG +packet SessionSetAppConfigCmd : SessionConfigPacket (mt = COMMAND, oid = SET_APP_CONFIG) { session_token: 32, // Session ID or Session Handle (based on UWBS version) _count_(tlvs): 8, tlvs: AppConfigTlv[] @@ -995,11 +933,11 @@ test SessionSetAppConfigCmd { struct AppConfigStatus { cfg_id: AppConfigTlvType, - status: StatusCode, + status: Status, } -packet SessionSetAppConfigRsp : SessionConfigResponse (opcode = 0x3) { //SESSION_SET_APP_CONFIG - status: StatusCode, +packet SessionSetAppConfigRsp : SessionConfigPacket (mt = RESPONSE, oid = SET_APP_CONFIG) { + status: Status, _count_(cfg_status): 8, cfg_status: AppConfigStatus[], } @@ -1008,7 +946,7 @@ test SessionSetAppConfigRsp { "\x41\x03\x00\x04\x00\x00\x00\x01\x01\x01\x00", } -packet SessionGetAppConfigCmd : SessionConfigCommand (opcode = 0x4) { //SESSION_GET_APP_CONFIG +packet SessionGetAppConfigCmd : SessionConfigPacket (mt = COMMAND, oid = GET_APP_CONFIG) { session_token: 32, // Session ID or Session Handle (based on UWBS version) _count_(app_cfg): 8, app_cfg: AppConfigTlvType[], @@ -1018,8 +956,8 @@ test SessionGetAppConfigCmd { "\x21\x04\x00\x05\x00\x00\x00\x01\x02\x03\x04\x00", } -packet SessionGetAppConfigRsp : SessionConfigResponse (opcode = 0x4) { //SESSION_GET_APP_CONFIG - status: StatusCode, +packet SessionGetAppConfigRsp : SessionConfigPacket (mt = RESPONSE, oid = GET_APP_CONFIG) { + status: Status, _count_(tlvs): 8, tlvs: AppConfigTlv[], } @@ -1028,15 +966,15 @@ test SessionGetAppConfigRsp { "\x41\x04\x00\x02\x00\x00\x00\x01\x00", } -packet SessionGetCountCmd : SessionConfigCommand (opcode = 0x5) { //SESSION_GET_COUNT +packet SessionGetCountCmd : SessionConfigPacket (mt = COMMAND, oid = GET_COUNT) { } test SessionGetCountCmd { "\x21\x05\x00\x00\x00\x00\x00", } -packet SessionGetCountRsp : SessionConfigResponse (opcode = 0x5) { //SESSION_GET_COUNT - status: StatusCode, +packet SessionGetCountRsp : SessionConfigPacket (mt = RESPONSE, oid = GET_COUNT) { + status: Status, session_count: 8, } @@ -1044,7 +982,7 @@ test SessionGetCountRsp { "\x41\x05\x00\x02\x00\x00\x00\x00\x01", } -packet SessionGetStateCmd : SessionConfigCommand (opcode = 0x6) { //SESSION_GET_STATE +packet SessionGetStateCmd : SessionConfigPacket (mt = COMMAND, oid = GET_STATE) { session_token: 32, // Session ID or Session Handle (based on UWBS version) } @@ -1052,8 +990,8 @@ test SessionGetStateCmd { "\x21\x06\x00\x04\x00\x00\x00\x00\x01\x02\x03", } -packet SessionGetStateRsp : SessionConfigResponse (opcode = 0x6) { //SESSION_GET_STATE - status: StatusCode, +packet SessionGetStateRsp : SessionConfigPacket (mt = RESPONSE, oid = GET_STATE) { + status: Status, session_state: SessionState, } @@ -1061,7 +999,15 @@ test SessionGetStateRsp { "\x41\x06\x00\x02\x00\x00\x00\x00\x01", } -packet SessionUpdateDtTagRangingRoundsCmd : SessionConfigCommand (opcode = 0x9) { //SESSION_UPDATE_ACTIVE_ROUNDS_DT_TAG +packet SessionUpdateDtAnchorRangingRoundsCmd : SessionConfigPacket (mt = COMMAND, oid = UPDATE_DT_ANCHOR_RANGING_ROUNDS) { + // TODO +} + +packet SessionUpdateDtAnchorRangingRoundsRsp : SessionConfigPacket (mt = RESPONSE, oid = UPDATE_DT_ANCHOR_RANGING_ROUNDS) { + // TODO +} + +packet SessionUpdateDtTagRangingRoundsCmd : SessionConfigPacket (mt = COMMAND, oid = UPDATE_DT_TAG_RANGING_ROUNDS) { session_token: 32, // Session ID or Session Handle (based on UWBS version) _count_(ranging_round_indexes): 8, ranging_round_indexes: 8[], @@ -1071,8 +1017,8 @@ test SessionUpdateDtTagRangingRoundsCmd { "\x21\x09\x00\x0a\x00\x00\x00\x03\x03\x0f\x0c\x05\x08\x00\x00\x00\x00", } -packet SessionUpdateDtTagRangingRoundsRsp : SessionConfigResponse (opcode = 0x9) { //SESSION_UPDATE_ACTIVE_ROUNDS_DT_TAG - status: StatusCode, +packet SessionUpdateDtTagRangingRoundsRsp : SessionConfigPacket (mt = RESPONSE, oid = UPDATE_DT_TAG_RANGING_ROUNDS) { + status: Status, _count_(ranging_round_indexes): 8, ranging_round_indexes: 8[], } @@ -1106,29 +1052,12 @@ enum UpdateMulticastListAction: 8 { ADD_CONTROLEE_WITH_EXTENDED_SUB_SESSION_KEY = 0x03, } -packet SessionUpdateControllerMulticastListCmd : SessionConfigCommand (opcode = 0x7) { //SESSION_UPDATE_CONTROLLER_MULTICAST_LIST +packet SessionUpdateControllerMulticastListCmd : SessionConfigPacket (mt = COMMAND, oid = UPDATE_CONTROLLER_MULTICAST_LIST) { session_token: 32, // Session ID or Session Handle (based on UWBS version) action: UpdateMulticastListAction, _payload_, } -struct PhaseList { - session_token: 32, - start_slot_index: 16, - end_slot_index: 16, -} - -packet SessionSetHybridConfigCmd : SessionConfigCommand (opcode = 0x0c) { //SESSION_SET_HUS_CONFIG - session_token: 32, - number_of_phases: 8, - update_time: 8[8], - phase_list: PhaseList[], -} - -packet SessionSetHybridConfigRsp : SessionConfigResponse (opcode = 0x0c) { //SESSION_SET_HUS_CONFIG - status: StatusCode, -} - struct SessionUpdateControllerMulticastListCmdPayload { _count_(controlees): 8, controlees: Controlee[], @@ -1144,8 +1073,8 @@ struct SessionUpdateControllerMulticastListCmd_2_0_32_Byte_Payload { controlees: Controlee_V2_0_32_Byte_Version[], } -packet SessionUpdateControllerMulticastListRsp : SessionConfigResponse (opcode = 0x7) { //SESSION_UPDATE_CONTROLLER_MULTICAST_LIST - status: StatusCode, +packet SessionUpdateControllerMulticastListRsp : SessionConfigPacket (mt = RESPONSE, oid = UPDATE_CONTROLLER_MULTICAST_LIST) { + status: Status, } test SessionUpdateControllerMulticastListRsp { @@ -1158,7 +1087,7 @@ struct ControleeStatus { status: MulticastUpdateStatusCode, } -packet SessionUpdateControllerMulticastListNtf : SessionConfigNotification (opcode = 0x7) { //SESSION_UPDATE_CONTROLLER_MULTICAST_LIST +packet SessionUpdateControllerMulticastListNtf : SessionConfigPacket (mt = NOTIFICATION, oid = UPDATE_CONTROLLER_MULTICAST_LIST) { session_token: 32, // Session ID or Session Handle (based on UWBS version) remaining_multicast_list_size: 8, _count_(controlee_status): 8, @@ -1169,52 +1098,55 @@ test SessionUpdateControllerMulticastListNtf { "\x61\x07\x00\x06\x00\x00\x00\x00\x01\x02\x03\x04\x00", } -packet DataCreditNtf : SessionControlNotification (opcode = 0x04) { // SESSION_DATA_CREDIT_NTF +// ---------------------- Session Control group ----------------------------- // + +packet SessionDataCreditNtf : SessionControlPacket (mt = NOTIFICATION, oid = DATA_CREDIT) { session_token: 32, // Session ID or Session Handle (based on UWBS version) credit_availability: CreditAvailability, } -test DataCreditNtf { +test SessionDataCreditNtf { "\x62\x04\x00\x05\x00\x00\x00\x00\x00\x00\x01\x01", } -packet DataTransferStatusNtf : SessionControlNotification (opcode = 0x05) { // SESSION_DATA_TRANSFER_STATUS_NTF +packet SessionDataTransferStatusNtf : SessionControlPacket (mt = NOTIFICATION, oid = DATA_TRANSFER_STATUS) { session_token: 32, // Session ID or Session Handle (based on UWBS version) uci_sequence_number: 8, status: DataTransferNtfStatusCode, tx_count: 8, } -test DataTransferStatusNtf { +test SessionDataTransferStatusNtf { "\x62\x05\x00\x06\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00", } -packet SessionQueryMaxDataSizeCmd : SessionConfigCommand (opcode = 0xB) { //QUERY_MAX_DATA_SIZE +packet SessionQueryMaxDataSizeInRangingCmd : SessionConfigPacket (mt = COMMAND, oid = QUERY_DATA_SIZE_IN_RANGING) { session_token: 32, // Session ID or Session Handle (based on UWBS version) } -test SessionQueryMaxDataSizeCmd { +test SessionQueryMaxDataSizeInRangingCmd { "\x21\x0B\x00\x04\x00\x00\x00\x00", } -packet SessionQueryMaxDataSizeRsp : SessionConfigResponse (opcode = 0xB) { //QUER_MAX_DATA_SIZE +packet SessionQueryMaxDataSizeInRangingRsp : SessionConfigPacket (mt = RESPONSE, oid = QUERY_DATA_SIZE_IN_RANGING) { session_token: 32, // Session ID or Session Handle (based on UWBS version) max_data_size: 16, } -test SessionQueryMaxDataSizeRsp { +test SessionQueryMaxDataSizeInRangingRsp { "\x41\x0B\x00\x06\x00\x00\x00\x00\x0E7\0x07", } -packet SessionStartCmd : SessionControlCommand (opcode = 0x0) { //RANGE_START +packet SessionStartCmd : SessionControlPacket (mt = COMMAND, oid = START) { + session_id: 32, } test SessionStartCmd { "\x22\x00\x00\x04\x00\x00\x00\x00\x01\x02\x03", } -packet SessionStartRsp : SessionControlResponse (opcode = 0x0) { //RANGE_START - status: StatusCode, +packet SessionStartRsp : SessionControlPacket (mt = RESPONSE, oid = START) { + status: Status, } test SessionStartRsp { @@ -1223,7 +1155,7 @@ test SessionStartRsp { struct ShortAddressTwoWayRangingMeasurement { mac_address: 16, - status: StatusCode, + status: Status, nlos: 8, distance: 16, aoa_azimuth: 16, @@ -1245,7 +1177,7 @@ struct ShortAddressTwoWayRangingMeasurement { struct ExtendedAddressTwoWayRangingMeasurement { mac_address: 64, - status: StatusCode, + status: Status, nlos: 8, distance: 16, aoa_azimuth: 16, @@ -1263,7 +1195,7 @@ struct ExtendedAddressTwoWayRangingMeasurement { struct ShortAddressOwrAoaRangingMeasurement { mac_address: 16, - status: StatusCode, + status: Status, nlos: 8, frame_sequence_number: 8, block_index: 16, @@ -1275,7 +1207,7 @@ struct ShortAddressOwrAoaRangingMeasurement { struct ExtendedAddressOwrAoaRangingMeasurement { mac_address: 64, - status: StatusCode, + status: Status, nlos: 8, frame_sequence_number: 8, block_index: 16, @@ -1292,7 +1224,7 @@ enum RangingMeasurementType : 8 { OWR_AOA = 0x03, } -packet SessionInfoNtf : SessionControlNotification (opcode = 0x0) { // SESSION_INFO +packet SessionInfoNtf : SessionControlPacket (mt = NOTIFICATION, oid = START) { sequence_number: 32, session_token: 32, // Session ID or Session Handle (based on UWBS version) rcr_indicator: 8, @@ -1364,30 +1296,32 @@ test ExtendedMacOwrAoaSessionInfoNtf { "\x62\x00\x00\x2c\x00\x00\x00\x00\x02\x03\x04\x05\x06\x07\x08\x00\x0a\x01\x01\x01\x03\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x01\xaa\xbb\xcc\xdd\x01\x02\x03\x04\x00\x00\x01\x01\x00\x03\x04\x60\x05\x06\x50", } -packet SessionStopCmd : SessionControlCommand (opcode = 0x1) { // SESSION_STOP +packet SessionStopCmd : SessionControlPacket (mt = COMMAND, oid = STOP) { + session_id: 32, } test SessionStopCmd { "\x22\x01\x00\x04\x00\x00\x00\x00\x02\x03\x04", } -packet SessionStopRsp : SessionControlResponse (opcode = 0x1) { // SESSION_STOP - status: StatusCode, +packet SessionStopRsp : SessionControlPacket (mt = RESPONSE, oid = STOP) { + status: Status, } test SessionStopRsp { "\x42\x01\x00\x01\x00\x00\x00\x00", } -packet SessionGetRangingCountCmd : SessionControlCommand (opcode = 0x3) { // SESSION_GET_RANGING_COUNT +packet SessionGetRangingCountCmd : SessionControlPacket (mt = COMMAND, oid = GET_RANGING_COUNT) { + session_id: 32, } test SessionGetRangingCountCmd { "\x22\x03\x00\x04\x00\x00\x00\x00\x02\x03\x04", } -packet SessionGetRangingCountRsp : SessionControlResponse (opcode = 0x3) { // SESSION_GET_RANGING_COUNT - status: StatusCode, +packet SessionGetRangingCountRsp : SessionControlPacket (mt = RESPONSE, oid = GET_RANGING_COUNT) { + status: Status, count: 32, } @@ -1395,7 +1329,9 @@ test SessionGetRangingCountRsp { "\x42\x03\x00\x05\x00\x00\x00\x00\x02\x03\x04\x05", } -packet AndroidGetPowerStatsCmd: AndroidCommand (opcode = 0x0) { //ANDROID_GET_POWER_STATS +// -------------------------- Android group --------------------------------- // + +packet AndroidGetPowerStatsCmd : AndroidPacket (mt = COMMAND, oid = GET_POWER_STATS) { } test AndroidGetPowerStatsCmd { @@ -1403,14 +1339,14 @@ test AndroidGetPowerStatsCmd { } struct PowerStats { - status: StatusCode, + status: Status, idle_time_ms: 32, tx_time_ms: 32, rx_time_ms: 32, total_wake_count:32, } -packet AndroidGetPowerStatsRsp : AndroidResponse (opcode = 0x0) { //ANDROID_GET_POWER_STATS +packet AndroidGetPowerStatsRsp : AndroidPacket (mt = RESPONSE, oid = GET_POWER_STATS) { stats: PowerStats, } @@ -1418,7 +1354,7 @@ test AndroidGetPowerStatsRsp { "\x4c\x00\x00\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", } -packet AndroidSetCountryCodeCmd: AndroidCommand (opcode = 0x1) { //ANDROID_SET_COUNTRY_CODE +packet AndroidSetCountryCodeCmd: AndroidPacket (mt = COMMAND, oid = SET_COUNTRY_CODE) { country_code : 8[2], } @@ -1427,8 +1363,8 @@ test AndroidSetCountryCodeCmd { "\x2c\x01\x00\x02\x00\x00\x00\x55\x53", } -packet AndroidSetCountryCodeRsp : AndroidResponse (opcode = 0x1) { //ANDROID_SET_COUNTRY_CODE - status: StatusCode, +packet AndroidSetCountryCodeRsp : AndroidPacket (mt = RESPONSE, oid = SET_COUNTRY_CODE) { + status: Status, } test AndroidSetCountryCodeRsp { @@ -1503,7 +1439,7 @@ struct FrameReport { frame_report_tlvs: FrameReportTlv[], } -packet AndroidRangeDiagnosticsNtf : AndroidNotification (opcode = 0x2) { //FIRA_RANGE_DIAGNOSTICS +packet AndroidRangeDiagnosticsNtf : AndroidPacket (mt = NOTIFICATION, oid = FIRA_RANGE_DIAGNOSTICS) { session_token: 32, // Session ID or Session Handle (based on UWBS version) sequence_number: 32, _count_(frame_reports): 8, @@ -1514,67 +1450,3 @@ test AndroidRangeDiagnosticsNtf { "\x6c\x02\x00\x11\x00\x00\x00\x01\x01\x01\x01\x02\x02\x02\x02\x01\x00\x01\x02\x01\x00\x01\x00\x00", "\x6c\x02\x00\x34\x00\x00\x00\x01\x01\x01\x01\x02\x02\x02\x02\x01\x00\x01\x02\x03\x01\x08\x00\x01\x02\x01\x02\x01\x02\x01\x01\x02\x15\x00\x01\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x01\x02\x00\x02\x04\x00\x01\x02\x03\x04\x00\x01\x00\x00", } - -packet UciVendor_9_Command : UciCommand (gid = VENDOR_RESERVED_9) { - _payload_, -} - -packet UciVendor_A_Command : UciCommand (gid = VENDOR_RESERVED_A) { - _payload_, -} - -packet UciVendor_B_Command : UciCommand (gid = VENDOR_RESERVED_B) { - _payload_, -} - -packet UciVendor_E_Command : UciCommand (gid = VENDOR_RESERVED_E) { - _payload_, -} - -packet UciVendor_F_Command : UciCommand (gid = VENDOR_RESERVED_F) { - _payload_, -} - -packet UciVendor_9_Response : UciResponse (gid = VENDOR_RESERVED_9) { - _payload_, -} - -packet UciVendor_A_Response : UciResponse (gid = VENDOR_RESERVED_A) { - _payload_, -} - -packet UciVendor_B_Response : UciResponse (gid = VENDOR_RESERVED_B) { - _payload_, -} - -packet UciVendor_E_Response : UciResponse (gid = VENDOR_RESERVED_E) { - _payload_, -} - -packet UciVendor_F_Response : UciResponse (gid = VENDOR_RESERVED_F) { - _payload_, -} - -packet UciVendor_9_Notification : UciNotification (gid = VENDOR_RESERVED_9) { - _payload_, -} - -packet UciVendor_A_Notification : UciNotification (gid = VENDOR_RESERVED_A) { - _payload_, -} - -packet UciVendor_B_Notification : UciNotification (gid = VENDOR_RESERVED_B) { - _payload_, -} - -packet UciVendor_E_Notification : UciNotification (gid = VENDOR_RESERVED_E) { - _payload_, -} - -packet UciVendor_F_Notification : UciNotification (gid = VENDOR_RESERVED_F) { - _payload_, -} - -packet TestNotification : UciNotification (gid = TEST) { - _payload_, -} |