1 // Copyright 2023 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 15 #pragma once 16 #include <pw_bluetooth/hci_common.emb.h> 17 18 #include "pw_bluetooth_sapphire/internal/host/common/error.h" 19 #include "pw_bluetooth_sapphire/internal/host/hci-spec/constants.h" 20 21 namespace bt { 22 namespace hci { 23 24 using Error = Error<pw::bluetooth::emboss::StatusCode>; 25 26 template <typename... V> 27 using Result = fit::result<bt::hci::Error, V...>; 28 29 template <typename... V> 30 using ResultFunction = fit::function<void(bt::hci::Result<V...> result)>; 31 32 template <typename... V> 33 using ResultCallback = fit::callback<void(bt::hci::Result<V...> result)>; 34 35 } // namespace hci 36 37 // Specializations for pw::bluetooth::emboss::StatusCode. 38 template <> 39 struct ProtocolErrorTraits<pw::bluetooth::emboss::StatusCode> { 40 static std::string ToString(pw::bluetooth::emboss::StatusCode ecode); 41 42 static constexpr bool is_success(pw::bluetooth::emboss::StatusCode ecode) { 43 return ecode == pw::bluetooth::emboss::StatusCode::SUCCESS; 44 } 45 }; 46 47 } // namespace bt 48