From 38018b963926680c1028b05077d2a21e831ec8c1 Mon Sep 17 00:00:00 2001 From: Josh Conner Date: Thu, 29 Aug 2024 17:01:18 +0000 Subject: [PATCH] pw_bluetooth_sapphire: Clean up EmbossEventPacket::StatusCode() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add some missing definitions and alphabetize the cases in EmbossEventPacket::StatusCode() Test: fx test //src/connectivity/bluetooth/core/bt-host Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1099594 GitOrigin-RevId: 1a3de4a02b36f73d71fe789940c8c81110eaa5b7 Change-Id: I6d03208c31d879c2cf5b1e4bb1dfccac10e982bd Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/230560 Commit-Queue: Ben Lawson Reviewed-by: Josh Conner Lint: Lint 🤖 --- .../host/transport/emboss_control_packets.cc | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/pw_bluetooth_sapphire/host/transport/emboss_control_packets.cc b/pw_bluetooth_sapphire/host/transport/emboss_control_packets.cc index 7d88890979..44b94a3d6c 100644 --- a/pw_bluetooth_sapphire/host/transport/emboss_control_packets.cc +++ b/pw_bluetooth_sapphire/host/transport/emboss_control_packets.cc @@ -70,10 +70,16 @@ hci_spec::EventCode EmbossEventPacket::event_code() const { std::optional EmbossEventPacket::StatusCode() const { switch (event_code()) { + case hci_spec::kAuthenticationCompleteEventCode: + return StatusCodeFromView< + pw::bluetooth::emboss::AuthenticationCompleteEventView>(); + case hci_spec::kChangeConnectionLinkKeyCompleteEventCode: + return StatusCodeFromView< + pw::bluetooth::emboss::ChangeConnectionLinkKeyCompleteEventView>(); case hci_spec::kCommandCompleteEventCode: return StatusCodeFromView< pw::bluetooth::emboss::SimpleCommandCompleteEventView>(); - case hci_spec ::kCommandStatusEventCode: + case hci_spec::kCommandStatusEventCode: return StatusCodeFromView< pw::bluetooth::emboss::CommandStatusEventView>(); case hci_spec::kConnectionCompleteEventCode: @@ -82,16 +88,25 @@ std::optional EmbossEventPacket::StatusCode() case hci_spec::kDisconnectionCompleteEventCode: return StatusCodeFromView< pw::bluetooth::emboss::DisconnectionCompleteEventView>(); - case hci_spec::kReadRemoteVersionInfoCompleteEventCode: + case hci_spec::kEncryptionChangeEventCode: return StatusCodeFromView< - pw::bluetooth::emboss::ReadRemoteVersionInfoCompleteEventView>(); + pw::bluetooth::emboss::EncryptionChangeEventV1View>(); + case hci_spec::kEncryptionKeyRefreshCompleteEventCode: + return StatusCodeFromView< + pw::bluetooth::emboss::EncryptionKeyRefreshCompleteEventView>(); + case hci_spec::kInquiryCompleteEventCode: + return StatusCodeFromView< + pw::bluetooth::emboss::InquiryCompleteEventView>(); + case hci_spec::kReadRemoteExtendedFeaturesCompleteEventCode: + return StatusCodeFromView< + pw::bluetooth::emboss::ReadRemoteExtendedFeaturesCompleteEventView>(); case hci_spec::kReadRemoteSupportedFeaturesCompleteEventCode: return StatusCodeFromView< pw::bluetooth::emboss:: ReadRemoteSupportedFeaturesCompleteEventView>(); - case hci_spec::kReadRemoteExtendedFeaturesCompleteEventCode: + case hci_spec::kReadRemoteVersionInfoCompleteEventCode: return StatusCodeFromView< - pw::bluetooth::emboss::ReadRemoteExtendedFeaturesCompleteEventView>(); + pw::bluetooth::emboss::ReadRemoteVersionInfoCompleteEventView>(); case hci_spec::kRemoteNameRequestCompleteEventCode: { // Tests expect that a kPacketMalformed status is returned for incomplete // events, even if they contain the status field. @@ -102,14 +117,11 @@ std::optional EmbossEventPacket::StatusCode() } return event_view.status().UncheckedRead(); } - case hci_spec::kEncryptionChangeEventCode: - return StatusCodeFromView< - pw::bluetooth::emboss::EncryptionChangeEventV1View>(); - case hci_spec::kEncryptionKeyRefreshCompleteEventCode: - return StatusCodeFromView< - pw::bluetooth::emboss::EncryptionKeyRefreshCompleteEventView>(); case hci_spec::kRoleChangeEventCode: return StatusCodeFromView(); + case hci_spec::kSimplePairingCompleteEventCode: + return StatusCodeFromView< + pw::bluetooth::emboss::SimplePairingCompleteEventView>(); case hci_spec::kSynchronousConnectionCompleteEventCode: return StatusCodeFromView< pw::bluetooth::emboss::SynchronousConnectionCompleteEventView>(); @@ -140,6 +152,10 @@ std::optional EmbossEventPacket::StatusCode() view().subevent_code().Read(); switch (subevent_code) { + case hci_spec::kLECISEstablishedSubeventCode: { + return StatusCodeFromView< + pw::bluetooth::emboss::LECISEstablishedSubeventView>(); + } case hci_spec::kLEConnectionCompleteSubeventCode: { return StatusCodeFromView< pw::bluetooth::emboss::LEConnectionCompleteSubeventView>(); @@ -148,6 +164,11 @@ std::optional EmbossEventPacket::StatusCode() return StatusCodeFromView< pw::bluetooth::emboss::LEConnectionUpdateCompleteSubeventView>(); } + case hci_spec::kLEEnhancedConnectionCompleteSubeventCode: { + return StatusCodeFromView< + pw::bluetooth::emboss:: + LEEnhancedConnectionCompleteSubeventV1View>(); + } case hci_spec::kLEReadRemoteFeaturesCompleteSubeventCode: { return StatusCodeFromView< pw::bluetooth::emboss:: @@ -157,11 +178,6 @@ std::optional EmbossEventPacket::StatusCode() return StatusCodeFromView< pw::bluetooth::emboss::LERequestPeerSCACompleteSubeventView>(); } - case hci_spec::kLEEnhancedConnectionCompleteSubeventCode: { - return StatusCodeFromView< - pw::bluetooth::emboss:: - LEEnhancedConnectionCompleteSubeventV1View>(); - } default: { BT_PANIC("Emboss LE meta subevent (%#.2x) not implemented", subevent_code);