3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2014-2018 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 default compile-time configuration constants
22 * for the CHIP BleLayer, a Bluetooth Low Energy communications
25 * Package integrators that wish to override these values should
26 * either use preprocessor definitions or create a project-
27 * specific BleProjectConfig.h header and then assert
28 * HAVE_BLEPROJECTCONFIG_H via the package configuration tool
29 * via --with-chip-ble-project-includes=DIR where DIR is the
30 * directory that contains the header.
32 * NOTE WELL: On some platforms, this header is included by C-language programs.
38 #if CHIP_HAVE_CONFIG_H
39 #include <ble/BleBuildConfig.h>
42 #include <system/SystemConfig.h>
44 /* Include a project-specific configuration file, if defined.
46 * An application or module that incorporates chip can define a project configuration
47 * file to override standard BLE Layer configuration with application-specific values.
48 * The project config file is typically located outside the Openchip source tree,
49 * alongside the source code for the application.
51 #ifdef BLE_PROJECT_CONFIG_INCLUDE
52 #include BLE_PROJECT_CONFIG_INCLUDE
55 /* Include a platform-specific configuration file, if defined.
57 * A platform configuration file contains overrides to standard BLE Layer configuration
58 * that are specific to the platform or OS on which chip is running. It is typically
59 * provided as apart of an adaptation layer that adapts Openchip to the target
60 * environment. This adaptation layer may be included in the Openchip source tree
61 * itself or implemented externally.
63 #ifdef BLE_PLATFORM_CONFIG_INCLUDE
64 #include BLE_PLATFORM_CONFIG_INCLUDE
71 * @def BLE_LAYER_NUM_BLE_ENDPOINTS
74 * This defines the number of BLEEndPoint objects allocated for use by the
75 * BleLayer subsystem. Value should be defined as the minimum of (max number
76 * of simultaneous BLE connections the system supports, max number of
77 * simultaneous BLE connections the application will establish).
79 #ifndef BLE_LAYER_NUM_BLE_ENDPOINTS
80 #define BLE_LAYER_NUM_BLE_ENDPOINTS 1
81 #endif // BLE_LAYER_NUM_BLE_ENDPOINTS
83 #if (BLE_LAYER_NUM_BLE_ENDPOINTS < 1)
84 #error "BLE_LAYER_NUM_BLE_ENDPOINTS must be greater than 0. configure options may be used to disable chip over BLE."
88 * @def BLE_CONNECTION_OBJECT
91 * This defines the type of BLE_CONNECTION_OBJECT parameters passed between
92 * BLE platform code and the BleLayer subsystem.
94 * This type must support operator == such that BLE_CONNECTION_OBJECT instances
95 * which refer to the same BLE connection are considered equivalent.
97 * Most platforms should be able to retain this type's default definition as
98 * (void *), and pass [pointers to] connection handles generated by their
99 * platform interface where BLE_CONNECTION_OBJECT arguments are required by
100 * BleLayer input functions.
103 #ifndef BLE_CONNECTION_OBJECT
104 #define BLE_CONNECTION_OBJECT void*
105 #endif // BLE_CONNECTION_OBJECT
108 * @def BLE_CONFIG_BLUEZ_MTU_FEATURE
111 * This define if BLUEZ MTU FEATURE is enabled or not
113 #ifndef BLE_CONFIG_BLUEZ_MTU_FEATURE
114 #define BLE_CONFIG_BLUEZ_MTU_FEATURE 0
115 #endif // BLE_CONFIG_BLUEZ_MTU_FEATURE
118 * @def BLE_CONNECTION_UNINITIALIZED
121 * This defines the value of an uninitialized BLE_CONNECTION_OBJECT.
124 #ifndef BLE_CONNECTION_UNINITIALIZED
125 #define BLE_CONNECTION_UNINITIALIZED NULL
126 #endif // BLE_CONNECTION_UNINITIALIZED
129 * @def BLE_READ_REQUEST_CONTEXT
132 * This defines the type of BLE_READ_REQUEST_CONTEXT parameters passed between
133 * BLE platform code and the BleLayer subsystem.
135 * BLE_READ_REQUEST_CONTEXT objects are handed to BleLayer when a read request
136 * is received by the BLE platform. BleLayer hands these objects back to the
137 * appropriate platform delegate function when sending the read response.
140 #ifndef BLE_READ_REQUEST_CONTEXT
141 #define BLE_READ_REQUEST_CONTEXT void*
142 #endif // BLE_READ_REQUEST_CONTEXT
145 * @def BLE_MAX_RECEIVE_WINDOW_SIZE
148 * This is the maximum allowed size of a BLE end point's receive window, defined as the number of fragments the
149 * end point may reliably receive without BTP-layer acknowledgement. This value should be no larger than the floor
150 * of ONE-HALF the total number of slots or buffers reserved for GATT operations at any point along a platform's
151 * BLE pipeline. The BLE layer reserves all of these buffers for its own use - one half for incoming GATT writes or
152 * indications, and the other half for incoming GATT confirmations.
154 * This value must be greater than 1, or race condition avoidance logic will prevent send the on remote device. This
155 * logic prevents any send with no piggybacked ack when the receiver's window has only 1 slot open. Without this
156 * logic, simultaneous data transmissions could fill both receiver's windows, leaving no room for the acks required
157 * to re-open them. Both senders would wedge, and the BTP connection would stall.
159 * This value must also exceed (BLE_CONFIG_IMMEDIATE_ACK_WINDOW_THRESHOLD + 1), or ***immediate*** stand-alone
160 * acks will forever be sent without delay in response to one another as each peer's window size dips below
161 * BLE_CONFIG_IMMEDIATE_ACK_WINDOW_THRESHOLD with receipt of any single message fragment.
163 * Default value of 3 is absolute minimum for stable performance, and an attempt to ensure safe window sizes on new
167 #ifndef BLE_MAX_RECEIVE_WINDOW_SIZE
168 #define BLE_MAX_RECEIVE_WINDOW_SIZE 3
171 #if (BLE_MAX_RECEIVE_WINDOW_SIZE < 3)
172 #error "BLE_MAX_RECEIVE_WINDOW_SIZE must be greater than 2 for BLE transport protocol stability."
176 * @def BLE_CONFIG_ERROR_TYPE
179 * This defines the data type used to represent errors for the
180 * BleLayer subsystem.
183 #ifndef BLE_CONFIG_ERROR_TYPE
185 #define BLE_CONFIG_ERROR_TYPE int32_t
186 #endif // BLE_CONFIG_ERROR_TYPE
189 * @def BLE_CONFIG_NO_ERROR
192 * This defines the BleLayer error code for no error or success.
195 #ifndef BLE_CONFIG_NO_ERROR
196 #define BLE_CONFIG_NO_ERROR 0
197 #endif // BLE_CONFIG_NO_ERROR
200 * @def BLE_CONFIG_ERROR_MIN
203 * This defines the base or minimum BleLayer error number range.
206 #ifndef BLE_CONFIG_ERROR_MIN
207 #define BLE_CONFIG_ERROR_MIN 6000
208 #endif // BLE_CONFIG_ERROR_MIN
211 * @def BLE_CONFIG_ERROR_MAX
214 * This defines the top or maximum BleLayer error number range.
217 #ifndef BLE_CONFIG_ERROR_MAX
218 #define BLE_CONFIG_ERROR_MAX 6999
219 #endif // BLE_CONFIG_ERROR_MAX
222 * @def _BLE_CONFIG_ERROR
225 * This defines a mapping function for BleLayer errors that allows
226 * mapping such errors into a platform- or system-specific range.
229 #ifndef _BLE_CONFIG_ERROR
230 #define _BLE_CONFIG_ERROR(e) (BLE_ERROR_MIN + (e))
231 #endif // _BLE_CONFIG_ERROR
235 #include <core/CHIPConfig.h>