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 <lib/fit/function.h> 17 18 #include "pw_bluetooth_sapphire/internal/host/common/error.h" 19 #include "pw_bluetooth_sapphire/internal/host/sm/smp.h" 20 21 namespace bt { 22 namespace sm { 23 24 using Error = Error<bt::sm::ErrorCode>; 25 26 template <typename... V> 27 using Result = fit::result<bt::sm::Error, V...>; 28 29 template <typename... V> 30 using ResultFunction = fit::function<void(bt::sm::Result<V...> result)>; 31 32 template <typename... V> 33 using ResultCallback = fit::callback<void(bt::sm::Result<V...> result)>; 34 35 } // namespace sm 36 37 template <> 38 struct ProtocolErrorTraits<sm::ErrorCode> { 39 static std::string ToString(sm::ErrorCode ecode); 40 41 // is_success() not declared because the reason does not include a "success" 42 // value (Core Spec v5.3, Vol 3, Part H, 3.5.5, Table 3.7). 43 }; 44 45 } // namespace bt 46