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 <string>
17 
18 namespace bt {
19 
20 // Status types used for internal errors generated by the host
21 enum class HostError : uint8_t {
22   // Not found.
23   kNotFound,
24 
25   // Not ready.
26   kNotReady,
27 
28   // The time limit for the operation has expired.
29   kTimedOut,
30 
31   // The operation was initiated with invalid parameters.
32   kInvalidParameters,
33 
34   // The parameters were rejected by the controller or peer.
35   kParametersRejected,
36 
37   // An advertising data blob is too large due to controller constraints.
38   kAdvertisingDataTooLong,
39 
40   // A scan response data blob is too large due to controller constraints.
41   kScanResponseTooLong,
42 
43   // The operation was canceled.
44   kCanceled,
45 
46   // Operation is already in progress.
47   kInProgress,
48 
49   // Operation is not supported by the host.
50   kNotSupported,
51 
52   // Received an invalid packet from the controller.
53   kPacketMalformed,
54 
55   // Link was disconnected during operation.
56   kLinkDisconnected,
57 
58   // Ran out of resources.
59   kOutOfMemory,
60 
61   // Operation security requirements were not met.
62   kInsufficientSecurity,
63 
64   // A transaction did not meet reliability requirements (e.g. an ATT Reliable
65   // Write)
66   kNotReliable,
67 
68   // Generic error code. Use this only if another error code does not accurately
69   // capture the failure condition.
70   kFailed,
71 };
72 
73 // Returns a string representation of HostError.
74 std::string HostErrorToString(HostError error);
75 
76 }  // namespace bt
77