3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2015-2017 Nest Labs, Inc.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 * This file defines constants for the CHIP BleLayer subsystem.
23 * Error types, ranges, and mappings overrides may be made by
24 * defining the appropriate BLE_CONFIG_* or _BLE_CONFIG_*
27 * NOTE WELL: On some platforms, this header is included by C-language programs.
33 #include "BleConfig.h"
41 * This defines the BleLayer error code for success or no
42 * error. This value may be configured via #BLE_CONFIG_NO_ERROR.
45 #define BLE_NO_ERROR BLE_CONFIG_NO_ERROR
51 * This defines the base or minimum value of the BleLayer error number
52 * range. This value may be configured via #BLE_CONFIG_ERROR_MIN.
55 #define BLE_ERROR_MIN BLE_CONFIG_ERROR_MIN
61 * This defines the top or maximum value of the BleLayer error number
62 * range. This value may be configured via #BLE_CONFIG_ERROR_MAX.
65 #define BLE_ERROR_MAX BLE_CONFIG_ERROR_MAX
71 * This defines a mapping function for BleLayer errors that allows
72 * mapping such errors into a platform- or system-specific
73 * range. This function may be configured via
76 * @param[in] e The BleLayer error to map.
78 * @return The mapped BleLayer error.
81 #define _BLE_ERROR(e) _BLE_CONFIG_ERROR(e)
86 * The basic type for all BleLayer errors.
88 * This is defined to a platform- or system-specific type.
91 typedef BLE_CONFIG_ERROR_TYPE BLE_ERROR;
94 * @name Error Definitions
100 * @def BLE_ERROR_BAD_ARGS
103 * An invalid argument or arguments were supplied.
106 #define BLE_ERROR_BAD_ARGS _BLE_ERROR(0)
109 * @def BLE_ERROR_INCORRECT_STATE
112 * An unexpected state was encountered.
115 #define BLE_ERROR_INCORRECT_STATE _BLE_ERROR(1)
118 * @def BLE_ERROR_NO_ENDPOINTS
121 * No BLE endpoint is available.
124 #define BLE_ERROR_NO_ENDPOINTS _BLE_ERROR(2)
127 * @def BLE_ERROR_NO_CONNECTION_RECEIVED_CALLBACK
130 * No callback was registered to receive a BLE Transport Protocol (BTP)
134 #define BLE_ERROR_NO_CONNECTION_RECEIVED_CALLBACK _BLE_ERROR(3)
137 * @def BLE_ERROR_CENTRAL_UNSUBSCRIBED
140 * A BLE central device unsubscribed from a peripheral device's BLE
141 * Transport Protocol (BTP) transmit characteristic.
144 #define BLE_ERROR_CENTRAL_UNSUBSCRIBED _BLE_ERROR(4)
147 * @def BLE_ERROR_GATT_SUBSCRIBE_FAILED
150 * A BLE central device failed to subscribe to a peripheral device's BLE
151 * Transport Protocol (BTP) transmit characteristic.
154 #define BLE_ERROR_GATT_SUBSCRIBE_FAILED _BLE_ERROR(5)
157 * @def BLE_ERROR_GATT_UNSUBSCRIBE_FAILED
160 * A BLE central device failed to unsubscribe from a peripheral device's
161 * BLE Transport Protocol (BTP) transmit characteristic.
164 #define BLE_ERROR_GATT_UNSUBSCRIBE_FAILED _BLE_ERROR(6)
167 * @def BLE_ERROR_GATT_WRITE_FAILED
170 * A General Attribute Profile (GATT) write operation failed.
173 #define BLE_ERROR_GATT_WRITE_FAILED _BLE_ERROR(7)
176 * @def BLE_ERROR_GATT_INDICATE_FAILED
179 * A General Attribute Profile (GATT) indicate operation failed.
182 #define BLE_ERROR_GATT_INDICATE_FAILED _BLE_ERROR(8)
185 * @def BLE_ERROR_NOT_IMPLEMENTED
188 * A requested function or feature is not implemented.
191 #define BLE_ERROR_NOT_IMPLEMENTED _BLE_ERROR(9)
194 * Unused _BLE_ERROR(10)
198 * @def BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT
201 * A BLE Transport Protocol (BTP) error was encountered.
204 #define BLE_ERROR_CHIPOBLE_PROTOCOL_ABORT _BLE_ERROR(11)
207 * @def BLE_ERROR_REMOTE_DEVICE_DISCONNECTED
210 * A remote BLE connection peer disconnected, either actively or due to the
211 * expiration of a BLE connection supervision timeout.
214 #define BLE_ERROR_REMOTE_DEVICE_DISCONNECTED _BLE_ERROR(12)
217 * @def BLE_ERROR_APP_CLOSED_CONNECTION
220 * The local application closed a BLE connection, and has informed BleLayer.
223 #define BLE_ERROR_APP_CLOSED_CONNECTION _BLE_ERROR(13)
226 * @def BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG
229 * More outbound message data is pending than available buffer space
230 * available to copy it.
233 #define BLE_ERROR_OUTBOUND_MESSAGE_TOO_BIG _BLE_ERROR(14)
236 * @def BLE_ERROR_NOT_CHIP_DEVICE
239 * A BLE peripheral device did not expose the General Attribute Profile
240 * (GATT) service required by the Bluetooth Transport Protocol (BTP).
243 #define BLE_ERROR_NOT_CHIP_DEVICE _BLE_ERROR(15)
246 * @def BLE_ERROR_INCOMPATIBLE_PROTOCOL_VERSIONS
249 * A remote device does not offer a compatible version of the Bluetooth
250 * Transport Protocol (BTP).
253 #define BLE_ERROR_INCOMPATIBLE_PROTOCOL_VERSIONS _BLE_ERROR(16)
256 * @def BLE_ERROR_NO_MEMORY
259 * A request for memory could not be fulfilled.
262 #define BLE_ERROR_NO_MEMORY _BLE_ERROR(17)
265 * @def BLE_ERROR_MESSAGE_INCOMPLETE
268 * A received Bluetooth Transport Protocol (BTP) message was incomplete.
271 #define BLE_ERROR_MESSAGE_INCOMPLETE _BLE_ERROR(18)
274 * @def BLE_ERROR_INVALID_FRAGMENT_SIZE
277 * A remote device selected in invalid Bluetooth Transport Protocol (BTP)
281 #define BLE_ERROR_INVALID_FRAGMENT_SIZE _BLE_ERROR(19)
284 * @def BLE_ERROR_START_TIMER_FAILED
287 * A timer failed to start within BleLayer.
290 #define BLE_ERROR_START_TIMER_FAILED _BLE_ERROR(20)
293 * @def BLE_ERROR_CONNECT_TIMED_OUT
296 * A remote BLE peripheral device's Bluetooth Transport Protocol (BTP)
297 * connect handshake response timed out.
300 #define BLE_ERROR_CONNECT_TIMED_OUT _BLE_ERROR(21)
303 * @def BLE_ERROR_RECEIVE_TIMED_OUT
306 * A remote BLE central device's Bluetooth Transport Protocol (BTP) connect
307 * handshake timed out.
310 #define BLE_ERROR_RECEIVE_TIMED_OUT _BLE_ERROR(22)
313 * @def BLE_ERROR_INVALID_MESSAGE
316 * An invalid Bluetooth Transport Protocol (BTP) message was received.
319 #define BLE_ERROR_INVALID_MESSAGE _BLE_ERROR(23)
322 * @def BLE_ERROR_FRAGMENT_ACK_TIMED_OUT
325 * Receipt of an expected Bluetooth Transport Protocol (BTP) fragment
326 * acknowledgement timed out.
329 #define BLE_ERROR_FRAGMENT_ACK_TIMED_OUT _BLE_ERROR(24)
332 * @def BLE_ERROR_KEEP_ALIVE_TIMED_OUT
335 * Receipt of an expected Bluetooth Transport Protocol (BTP) keep-alive
336 * fragment timed out.
339 #define BLE_ERROR_KEEP_ALIVE_TIMED_OUT _BLE_ERROR(25)
342 * @def BLE_ERROR_NO_CONNECT_COMPLETE_CALLBACK
345 * No callback was registered to handle Bluetooth Transport Protocol (BTP)
346 * connect completion.
349 #define BLE_ERROR_NO_CONNECT_COMPLETE_CALLBACK _BLE_ERROR(26)
352 * @def BLE_ERROR_INVALID_ACK
355 * A Bluetooth Transport Protcol (BTP) fragment acknowledgement was invalid.
358 #define BLE_ERROR_INVALID_ACK _BLE_ERROR(27)
361 * @def BLE_ERROR_REASSEMBLER_MISSING_DATA
364 * A Bluetooth Transport Protocol (BTP) end-of-message fragment was
365 * received, but the total size of the received fragments is less than
366 * the indicated size of the original fragmented message.
369 #define BLE_ERROR_REASSEMBLER_MISSING_DATA _BLE_ERROR(28)
372 * @def BLE_ERROR_INVALID_BTP_HEADER_FLAGS
375 * A set of Bluetooth Transport Protocol (BTP) header flags is invalid.
378 #define BLE_ERROR_INVALID_BTP_HEADER_FLAGS _BLE_ERROR(29)
381 * @def BLE_ERROR_INVALID_BTP_SEQUENCE_NUMBER
384 * A Bluetooth Transport Protocol (BTP) fragment sequence number is invalid.
387 #define BLE_ERROR_INVALID_BTP_SEQUENCE_NUMBER _BLE_ERROR(30)
390 * @def BLE_ERROR_REASSEMBLER_INCORRECT_STATE
393 * The Bluetooth Transport Protocol (BTP) message reassembly engine
394 * encountered an unexpected state.
397 #define BLE_ERROR_REASSEMBLER_INCORRECT_STATE _BLE_ERROR(31)
400 * @def BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG
403 * More inbound message data is pending than available buffer space
404 * available to copy it.
407 #define BLE_ERROR_RECEIVED_MESSAGE_TOO_BIG _BLE_ERROR(32)
409 // !!!!! IMPORTANT !!!!! If you add new Ble errors, please update the translation
410 // of error codes to strings in BleError.cpp, and add them to unittest
411 // in test-apps/TestErrorStr.cpp
422 extern void RegisterLayerErrorFormatter();
423 extern bool FormatLayerError(char * buf, uint16_t bufSize, int32_t err);
425 } /* namespace Ble */
426 } /* namespace chip */