Skip to content

Commit

Permalink
pw_bluetooth_sapphire: Clean up EmbossEventPacket::StatusCode()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Josh Conner <[email protected]>
Lint: Lint 🤖 <[email protected]>
  • Loading branch information
josh-conner authored and CQ Bot Account committed Aug 29, 2024
1 parent 43c30e7 commit 38018b9
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions pw_bluetooth_sapphire/host/transport/emboss_control_packets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,16 @@ hci_spec::EventCode EmbossEventPacket::event_code() const {
std::optional<pw::bluetooth::emboss::StatusCode> 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:
Expand All @@ -82,16 +88,25 @@ std::optional<pw::bluetooth::emboss::StatusCode> 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.
Expand All @@ -102,14 +117,11 @@ std::optional<pw::bluetooth::emboss::StatusCode> 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<pw::bluetooth::emboss::RoleChangeEventView>();
case hci_spec::kSimplePairingCompleteEventCode:
return StatusCodeFromView<
pw::bluetooth::emboss::SimplePairingCompleteEventView>();
case hci_spec::kSynchronousConnectionCompleteEventCode:
return StatusCodeFromView<
pw::bluetooth::emboss::SynchronousConnectionCompleteEventView>();
Expand Down Expand Up @@ -140,6 +152,10 @@ std::optional<pw::bluetooth::emboss::StatusCode> EmbossEventPacket::StatusCode()
view<pw::bluetooth::emboss::LEMetaEventView>().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>();
Expand All @@ -148,6 +164,11 @@ std::optional<pw::bluetooth::emboss::StatusCode> 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::
Expand All @@ -157,11 +178,6 @@ std::optional<pw::bluetooth::emboss::StatusCode> 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);
Expand Down

0 comments on commit 38018b9

Please sign in to comment.