FreeRTOS: BLE
BLE
Return to main page ↑
iot_ble_config_defaults.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS BLE V2.2.0
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
34 #ifndef _IOT_BLE_CONFIG_DEFAULTS_H_
35 #define _IOT_BLE_CONFIG_DEFAULTS_H_
36 
43 #define IOT_BLE_SERVER_UUID { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
44 
55 #ifndef IOT_BLE_DEVICE_INFO_SERVICE_UUID_MASK
56  #define IOT_BLE_DEVICE_INFO_SERVICE_UUID_MASK 0x32, 0xF9, 0x79, 0xE6, 0xB5, 0x83, 0xFB, 0x4E, 0xAF, 0x48, 0x68, 0x11, 0x7F, 0x8A
57 #endif
58 #define IOT_BLE_DEVICE_INFO_SERVICE_BASE_UUID 0x00, 0xFF
59 #define IOT_BLE_DEVICE_INFO_SERVICE_UUID { IOT_BLE_DEVICE_INFO_SERVICE_BASE_UUID, IOT_BLE_DEVICE_INFO_SERVICE_UUID_MASK }
60 
61 
67 #ifndef IOT_BLE_SET_CUSTOM_ADVERTISEMENT_MSG
68  #define IOT_BLE_SET_CUSTOM_ADVERTISEMENT_MSG ( 0 )
69 #endif
70 
71 
77 #ifndef IOT_BLE_ADVERTISING_UUID
78  #define IOT_BLE_ADVERTISING_UUID IOT_BLE_DEVICE_INFO_SERVICE_UUID
79  #define IOT_BLE_ADVERTISING_UUID_SIZE 16
80 #endif
81 
86 #if ( !defined( IOT_BLE_ADVERTISING_CONN_INTERVAL_MIN ) ) || ( !defined( IOT_BLE_ADVERTISING_CONN_INTERVAL_MAX ) )
87  #ifdef IOT_BLE_ADVERTISING_CONN_INTERVAL_MIN
88  #error "IOT_BLE_ADVERTISING_CONN_INTERVAL_MAX need to be defined"
89  #endif
90  #ifdef IOT_BLE_ADVERTISING_CONN_INTERVAL_MAX
91  #error "IOT_BLE_ADVERTISING_CONN_INTERVAL_MIN need to be defined"
92  #endif
93  #define IOT_BLE_ADVERTISING_CONN_INTERVAL_MIN 0x20
94  #define IOT_BLE_ADVERTISING_CONN_INTERVAL_MAX 0x40
95 #endif
96 
98 #ifndef IOT_BLE_ADVERTISING_INTERVAL
99  #define IOT_BLE_ADVERTISING_INTERVAL 300
100 #endif
101 
103 #ifndef IOT_BLE_ENCRYPT_KEY_SIZE_MIN
104  #define IOT_BLE_ENCRYPT_KEY_SIZE_MIN 16
105 #endif
106 
107 
112 #ifndef IOT_BLE_ADVERTISING_APPEARANCE
113  #define IOT_BLE_ADVERTISING_APPEARANCE 0
114 #endif
115 
120 #ifndef IOT_BLE_INPUT_OUTPUT
121  #define IOT_BLE_INPUT_OUTPUT eBTIODisplayYesNo
122 #endif
123 
129 #ifndef IOT_BLE_DEVICE_SHORT_LOCAL_NAME_SIZE
130  #define IOT_BLE_DEVICE_SHORT_LOCAL_NAME_SIZE 4
131 #endif
132 
138 #ifndef IOT_BLE_DEVICE_COMPLETE_LOCAL_NAME
139  #define IOT_BLE_DEVICE_COMPLETE_LOCAL_NAME "BLE"
140 #endif
141 
147 #ifndef IOT_BLE_DEVICE_LOCAL_NAME_MAX_LENGTH
148  #define IOT_BLE_DEVICE_LOCAL_NAME_MAX_LENGTH ( 248 )
149 #endif
150 
158 #ifndef IOT_BLE_PREFERRED_MTU_SIZE
159  #define IOT_BLE_PREFERRED_MTU_SIZE ( 512 )
160 #endif
161 
167 #ifndef IOT_BLE_ENABLE_BONDING
168  #define IOT_BLE_ENABLE_BONDING ( 1 )
169 #endif
170 
176 #ifndef IOT_BLE_ENABLE_SECURE_CONNECTION
177  #define IOT_BLE_ENABLE_SECURE_CONNECTION ( 1 )
178 #endif
179 
180 /* Config if set, requires encryption to access services and characteristics */
181 
185 #ifndef IOT_BLE_ENCRYPTION_REQUIRED
186  #define IOT_BLE_ENCRYPTION_REQUIRED ( 1 )
187 #endif
188 
195 #ifndef IOT_BLE_ENABLE_NUMERIC_COMPARISON
196  #define IOT_BLE_ENABLE_NUMERIC_COMPARISON ( 1 )
197 #endif
198 
202 #ifndef IOT_BLE_NUMERIC_COMPARISON_TIMEOUT_SEC
203  #define IOT_BLE_NUMERIC_COMPARISON_TIMEOUT_SEC ( 30 )
204 #endif
205 
209 #ifndef IOT_BLE_MAX_BONDED_DEVICES
210  #define IOT_BLE_MAX_BONDED_DEVICES ( 5 )
211 #endif
212 
213 #if ( IOT_BLE_ENCRYPTION_REQUIRED == 1 )
214  #if ( IOT_BLE_ENABLE_NUMERIC_COMPARISON == 1 )
215  #define IOT_BLE_CHAR_READ_PERM eBTPermReadEncryptedMitm
216  #define IOT_BLE_CHAR_WRITE_PERM eBTPermWriteEncryptedMitm
217  #else
218  #define IOT_BLE_CHAR_READ_PERM eBTPermReadEncrypted
219  #define IOT_BLE_CHAR_WRITE_PERM eBTPermWriteEncrypted
220  #endif
221 #else
222  #define IOT_BLE_CHAR_READ_PERM eBTPermRead
223  #define IOT_BLE_CHAR_WRITE_PERM eBTPermWrite
224 #endif
225 
230 #ifndef IOT_BLE_ENABLE_FREERTOS_GATT_SERVICES
231  #define IOT_BLE_ENABLE_FREERTOS_GATT_SERVICES ( 1 )
232 #endif
233 
237 #ifndef IOT_BLE_ADD_CUSTOM_SERVICES
238  #define IOT_BLE_ADD_CUSTOM_SERVICES ( 0 )
239 #endif
240 
241 
247 #if ( IOT_BLE_ENABLE_FREERTOS_GATT_SERVICES == 1 )
248  #ifndef IOT_BLE_ENABLE_DEVICE_INFO_SERVICE
249  #define IOT_BLE_ENABLE_DEVICE_INFO_SERVICE ( 1 )
250  #endif
251 #else
252  #define IOT_BLE_ENABLE_DEVICE_INFO_SERVICE ( 0 )
253 #endif
254 
255 
263 #if ( IOT_BLE_ENABLE_FREERTOS_GATT_SERVICES == 1 )
264  #ifndef IOT_BLE_ENABLE_WIFI_PROVISIONING
265  #define IOT_BLE_ENABLE_WIFI_PROVISIONING ( 0 )
266  #endif
267 #else
268  #define IOT_BLE_ENABLE_WIFI_PROVISIONING ( 0 )
269 #endif
270 
277 #if ( IOT_BLE_ENABLE_FREERTOS_GATT_SERVICES == 1 )
278  #ifndef IOT_BLE_ENABLE_MQTT
279  #define IOT_BLE_ENABLE_MQTT ( 1 )
280  #endif
281 #else
282  #define IOT_BLE_ENABLE_MQTT ( 0 )
283 #endif
284 
285 
290 #if ( IOT_BLE_ENABLE_FREERTOS_GATT_SERVICES == 1 )
291  #ifndef IOT_BLE_ENABLE_DATA_TRANSFER_SERVICE
292  #define IOT_BLE_ENABLE_DATA_TRANSFER_SERVICE ( 1 )
293  #endif
294 #else
295  #define IOT_BLE_ENABLE_DATA_TRANSFER_SERVICE ( 0 )
296 #endif
297 
298 
304 #ifndef IOT_BLE_WIFI_PROVISIONIG_MAX_SCAN_NETWORKS
305  #define IOT_BLE_WIFI_PROVISIONIG_MAX_SCAN_NETWORKS ( 10 )
306 #endif
307 
308 
309 /* @brief Controls the number of network that can be saved using WIFI provisioning.
310  *
311  * The number should be set according to amount of flash space available on the device.
312  * The size increase in multiple of sizeof(WIFINetworkProfile_t).
313  */
314 #ifndef IOT_BLE_WIFI_PROVISIONING_MAX_SAVED_NETWORKS
315  #define IOT_BLE_WIFI_PROVISIONING_MAX_SAVED_NETWORKS ( 8 )
316 #endif
317 
321 #ifndef IOT_BLE_MQTT_CREATE_CONNECTION_WAIT_MS
322  #define IOT_BLE_MQTT_CREATE_CONNECTION_WAIT_MS ( 1000 * IOT_BLE_NUMERIC_COMPARISON_TIMEOUT_SEC )
323 #endif
324 
328 #ifndef IOT_BLE_MQTT_CREATE_CONNECTION_RETRY
329  #define IOT_BLE_MQTT_CREATE_CONNECTION_RETRY ( 60 )
330 #endif
331 
332 
333 /*
334  * @brief UUID mask for data transfer services.
335  */
336 #define IOT_BLE_DATA_TRANSFER_SERVICE_UUID_MASK 0xC3, 0x4C, 0x04, 0x48, 0x02, 0xA0, 0xA9, 0x40, 0x2E, 0xD7, 0x6A, 0x16, 0xD7, 0xA9
337 
342 #define IOT_BLE_DATA_TRANSFER_SERVICE_TYPE_MQTT 0x00
343 
348 #define IOT_BLE_DATA_TRANSFER_SERVICE_TYPE_WIFI_PROVISIONING 0x01
349 
353 #ifndef IOT_BLE_DATA_TRANSFER_TX_BUFFER_SIZE
354  #define IOT_BLE_DATA_TRANSFER_TX_BUFFER_SIZE ( 1024 )
355 #endif
356 
361 #ifndef IOT_BLE_DATA_TRANSFER_RX_BUFFER_SIZE
362  #define IOT_BLE_DATA_TRANSFER_RX_BUFFER_SIZE ( 1024 )
363 #endif
364 
365 #ifndef IOT_BLE_NETWORK_INTERFACE_BUFFER_SIZE
366  #define IOT_BLE_NETWORK_INTERFACE_BUFFER_SIZE ( 256U )
367 #endif
368 
372 #ifndef IOT_BLE_DATA_TRANSFER_TIMEOUT_MS
373  #define IOT_BLE_DATA_TRANSFER_TIMEOUT_MS ( 2000 )
374 #endif
375 
376 #define IOT_BLE_MESG_ENCODER ( _IotSerializerCborEncoder )
377 #define IOT_BLE_MESG_DECODER ( _IotSerializerCborDecoder )
378 
382 #ifndef IotBle_MallocDataBuffer
383  #define IotBle_MallocDataBuffer malloc
384 #endif
385 
386 #ifndef IotBle_FreeDataBuffer
387  #define IotBle_FreeDataBuffer free
388 #endif
389 
393 #ifndef IotBle_Assert
394  #include <assert.h>
395  #define IotBle_Assert( expression ) assert( expression )
396 #endif
397 
398 #endif /* _IOT_BLE_CONFIG_DEFAULTS_H_ */