1 // Copyright 2022 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 #pragma once 15 16 #include <cstdint> 17 18 namespace pw::bluetooth::gatt { 19 20 /// The values correspond with those in Bluetooth 5.2 Vol. 3 Part G Table 3.4, 21 /// and Supplement to the Bluetooth Core Specification v9 Part B Table 1.1, 22 /// but this is for ease of reference only. Clients should *not* rely on these 23 /// values remaining constant. Omitted values from the spec are handled 24 /// internally and will not be returned to clients. 25 enum class Error : uint16_t { 26 // ATT Errors 27 28 /// The attribute indicated by the handle is invalid. It may have been 29 /// removed. 30 /// 31 /// This may be returned by a LocalService method. 32 kInvalidHandle = 0x1, 33 34 /// This attribute is not readable. 35 kReadNotPermitted = 0x2, 36 37 /// This attribute is not writable. 38 kWriteNotPermitted = 0x3, 39 40 /// Indicates that the response received from the server was invalid. 41 kInvalidPdu = 0x4, 42 43 /// This attribute requires authentication, but the client is not 44 /// authenticated. 45 kInsufficientAuthentication = 0x5, 46 47 /// Indicates that the offset used in a read or write request exceeds the 48 /// bounds of the value. 49 kInvalidOffset = 0x7, 50 51 /// This attribute requires authorization, but the client is not authorized. 52 kInsufficientAuthorization = 0x8, 53 54 /// This attribute requires a connection encrypted by a larger encryption key. 55 kInsufficientEncryptionKeySize = 0xC, 56 57 /// Indicates that the value given in a write request would exceed the maximum 58 /// length allowed for the destination characteristic or descriptor. 59 kInvalidAttributeValueLength = 0xD, 60 61 /// A general error occurred that can not be classified as one of the more 62 /// specific errors. 63 kUnlikelyError = 0xE, 64 65 /// This attribute requires encryption, but the connection is not encrypted. 66 kInsufficientEncryption = 0xF, 67 68 /// The server had insufficient resources to complete the task. 69 kInsufficientResources = 0x11, 70 71 /// The value was not allowed. 72 kValueNotAllowed = 0x13, 73 74 // Application Errors 75 76 /// Application Errors. The uses of these are specified at the application 77 /// level. 78 kApplicationError80 = 0x80, 79 kApplicationError81 = 0x81, 80 kApplicationError82 = 0x82, 81 kApplicationError83 = 0x83, 82 kApplicationError84 = 0x84, 83 kApplicationError85 = 0x85, 84 kApplicationError86 = 0x86, 85 kApplicationError87 = 0x87, 86 kApplicationError88 = 0x88, 87 kApplicationError89 = 0x89, 88 kApplicationError8A = 0x8A, 89 kApplicationError8B = 0x8B, 90 kApplicationError8C = 0x8C, 91 kApplicationError8D = 0x8D, 92 kApplicationError8E = 0x8E, 93 kApplicationError8F = 0x8F, 94 kApplicationError90 = 0x90, 95 kApplicationError91 = 0x91, 96 kApplicationError92 = 0x92, 97 kApplicationError93 = 0x93, 98 kApplicationError94 = 0x94, 99 kApplicationError95 = 0x95, 100 kApplicationError96 = 0x96, 101 kApplicationError97 = 0x97, 102 kApplicationError98 = 0x98, 103 kApplicationError99 = 0x99, 104 kApplicationError9A = 0x9A, 105 kApplicationError9B = 0x9B, 106 kApplicationError9C = 0x9C, 107 kApplicationError9D = 0x9D, 108 kApplicationError9E = 0x9E, 109 kApplicationError9F = 0x9F, 110 111 // Common Profile and Service Error Codes 112 113 /// Write request was rejected at the profile or service level. 114 kWriteRequestRejected = 0xFC, 115 116 /// The Client Characteristic Configuration Descriptor was improperly 117 /// configured. 118 kCccDescriptorImproperlyConfigured = 0xFD, 119 120 /// Profile or service procedure already in progress. 121 kProcedureAlreadyInProgress = 0xFE, 122 123 /// A value was out of range at the profile or service level. 124 kOutOfRange = 0xFF, 125 126 // Errors not specified by Bluetooth. 127 128 // One or more of the call parameters are invalid. See the parameter 129 // documentation. 130 kInvalidParameters = 0x101, 131 132 // Generic failure. 133 kFailure = 0x102, 134 }; 135 136 } // namespace pw::bluetooth::gatt 137