summaryrefslogtreecommitdiff
path: root/src/rust/uwb_uci_packets
diff options
context:
space:
mode:
authorShreshta Manu <shreshtabm@google.com>2023-01-05 21:58:58 +0000
committerShreshta Manu <shreshtabm@google.com>2023-01-10 02:51:25 +0000
commit624e3c97ac5682c09ff59b3ca1ed9670f56674d9 (patch)
tree01866f20cd763bd6912d7085a607206fa3d8be37 /src/rust/uwb_uci_packets
parentfdbdffc2927478d18fd6e16ec32229f5cced5ce1 (diff)
downloaduwb-624e3c97ac5682c09ff59b3ca1ed9670f56674d9.tar.gz
[uwb-core] Add support support for custom vendor message type
Vendor uci commands can now send messages with type testing_1 and testing_2 which are reserved for testing. FiRa CR-435. Bug: 261377401 Test: atest libuwb_core_tests, atest libuwb_uci_packet_tests Change-Id: I72cdcec5115e47a01e4e5a5f72af00ae2617eb4d
Diffstat (limited to 'src/rust/uwb_uci_packets')
-rw-r--r--src/rust/uwb_uci_packets/src/lib.rs19
-rw-r--r--src/rust/uwb_uci_packets/uci_packets.pdl2
2 files changed, 20 insertions, 1 deletions
diff --git a/src/rust/uwb_uci_packets/src/lib.rs b/src/rust/uwb_uci_packets/src/lib.rs
index 049d7da..4a77f1d 100644
--- a/src/rust/uwb_uci_packets/src/lib.rs
+++ b/src/rust/uwb_uci_packets/src/lib.rs
@@ -297,11 +297,28 @@ fn get_opcode_from_uci_control_packet(packet: &UciPacketHalPacket) -> u8 {
fn is_uci_control_packet(message_type: MessageType) -> bool {
match message_type {
- MessageType::Command | MessageType::Response | MessageType::Notification => true,
+ MessageType::Command
+ | MessageType::Response
+ | MessageType::Notification
+ | MessageType::ReservedForTesting1
+ | MessageType::ReservedForTesting2 => true,
_ => false,
}
}
+pub fn build_uci_control_packet(
+ message_type: MessageType,
+ group_id: GroupId,
+ opcode: u8,
+ payload: Option<Bytes>,
+) -> Option<UciControlPacketPacket> {
+ if !is_uci_control_packet(message_type) {
+ error!("Only control packets are allowed, MessageType: {}", message_type);
+ return None;
+ }
+ Some(UciControlPacketBuilder { group_id, message_type, opcode, payload }.build())
+}
+
// Ensure that the new packet fragment belong to the same packet.
fn is_same_control_packet(header: &UciControlPacketHeader, packet: &UciPacketHalPacket) -> bool {
is_uci_control_packet(header.message_type)
diff --git a/src/rust/uwb_uci_packets/uci_packets.pdl b/src/rust/uwb_uci_packets/uci_packets.pdl
index 3e9a39f..6c99fa7 100644
--- a/src/rust/uwb_uci_packets/uci_packets.pdl
+++ b/src/rust/uwb_uci_packets/uci_packets.pdl
@@ -340,6 +340,8 @@ enum MessageType: 3 {
COMMAND = 0x01,
RESPONSE = 0x02,
NOTIFICATION = 0x03,
+ RESERVED_FOR_TESTING_1 = 0x04,
+ RESERVED_FOR_TESTING_2 = 0x05,
}
// UCI packet description in compliance with the FIRA UCI spec.