FreeRTOS: BLE
BLE
Return to main page ↑
iot_ble_config_defaults.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS BLE V2.1.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 
65 #ifndef IOT_BLE_SET_CUSTOM_ADVERTISEMENT_MSG
66  #define IOT_BLE_SET_CUSTOM_ADVERTISEMENT_MSG ( 0 )
67 #endif
68 
69 
75 #if ( !defined( IOT_BLE_ADVERTISING_UUID ) ) || ( !defined( IOT_BLE_ADVERTISING_UUID_SIZE ) )
76  #ifdef IOT_BLE_ADVERTISING_UUID
77  #error "IOT_BLE_ADVERTISING_UUID_SIZE need to be defined"
78  #endif
79  #ifdef IOT_BLE_ADVERTISING_UUID_SIZE
80  #error "IOT_BLE_ADVERTISING_UUID need to be defined"
81  #endif
82  #define IOT_BLE_ADVERTISING_UUID IOT_BLE_DEVICE_INFO_SERVICE_UUID
83  #define IOT_BLE_ADVERTISING_UUID_SIZE 16
84 #endif
85 
90 #if ( !defined( IOT_BLE_ADVERTISING_CONN_INTERVAL_MIN ) ) || ( !defined( IOT_BLE_ADVERTISING_CONN_INTERVAL_MAX ) )
91  #ifdef IOT_BLE_ADVERTISING_CONN_INTERVAL_MIN
92  #error "IOT_BLE_ADVERTISING_CONN_INTERVAL_MAX need to be defined"
93  #endif
94  #ifdef IOT_BLE_ADVERTISING_CONN_INTERVAL_MAX
95  #error "IOT_BLE_ADVERTISING_CONN_INTERVAL_MIN need to be defined"
96  #endif
97  #define IOT_BLE_ADVERTISING_CONN_INTERVAL_MIN 0x20
98  #define IOT_BLE_ADVERTISING_CONN_INTERVAL_MAX 0x40
99 #endif
100 
102 #ifndef IOT_BLE_ADVERTISING_INTERVAL
103  #define IOT_BLE_ADVERTISING_INTERVAL 300
104 #endif
105 
107 #ifndef IOT_BLE_ENCRYPT_KEY_SIZE_MIN
108  #define IOT_BLE_ENCRYPT_KEY_SIZE_MIN 16
109 #endif
110 
111 
116 #ifndef IOT_BLE_ADVERTISING_APPEARANCE
117  #define IOT_BLE_ADVERTISING_APPEARANCE 0
118 #endif
119 
124 #ifndef IOT_BLE_INPUT_OUTPUT
125  #define IOT_BLE_INPUT_OUTPUT eBTIODisplayYesNo
126 #endif
127 
133 #ifndef IOT_BLE_DEVICE_SHORT_LOCAL_NAME_SIZE
134  #define IOT_BLE_DEVICE_SHORT_LOCAL_NAME_SIZE 4
135 #endif
136 
142 #ifndef IOT_BLE_DEVICE_COMPLETE_LOCAL_NAME
143  #define IOT_BLE_DEVICE_COMPLETE_LOCAL_NAME "BLE"
144 #endif
145 
151 #ifndef IOT_BLE_DEVICE_LOCAL_NAME_MAX_LENGTH
152  #define IOT_BLE_DEVICE_LOCAL_NAME_MAX_LENGTH ( 248 )
153 #endif
154 
162 #ifndef IOT_BLE_PREFERRED_MTU_SIZE
163  #define IOT_BLE_PREFERRED_MTU_SIZE ( 512 )
164 #endif
165 
171 #ifndef IOT_BLE_ENABLE_BONDING
172  #define IOT_BLE_ENABLE_BONDING ( 1 )
173 #endif
174 
180 #ifndef IOT_BLE_ENABLE_SECURE_CONNECTION
181  #define IOT_BLE_ENABLE_SECURE_CONNECTION ( 1 )
182 #endif
183 
184 /* Config if set, requires encryption to access services and characteristics */
185 
189 #ifndef IOT_BLE_ENCRYPTION_REQUIRED
190  #define IOT_BLE_ENCRYPTION_REQUIRED ( 1 )
191 #endif
192 
199 #ifndef IOT_BLE_ENABLE_NUMERIC_COMPARISON
200  #define IOT_BLE_ENABLE_NUMERIC_COMPARISON ( 1 )
201 #endif
202 
206 #ifndef IOT_BLE_NUMERIC_COMPARISON_TIMEOUT_SEC
207  #define IOT_BLE_NUMERIC_COMPARISON_TIMEOUT_SEC ( 30 )
208 #endif
209 
213 #ifndef IOT_BLE_MAX_BONDED_DEVICES
214  #define IOT_BLE_MAX_BONDED_DEVICES ( 5 )
215 #endif
216 
217 #if ( IOT_BLE_ENCRYPTION_REQUIRED == 1 )
218  #if ( IOT_BLE_ENABLE_NUMERIC_COMPARISON == 1 )
219  #define IOT_BLE_CHAR_READ_PERM eBTPermReadEncryptedMitm
220  #define IOT_BLE_CHAR_WRITE_PERM eBTPermWriteEncryptedMitm
221  #else
222  #define IOT_BLE_CHAR_READ_PERM eBTPermReadEncrypted
223  #define IOT_BLE_CHAR_WRITE_PERM eBTPermWriteEncrypted
224  #endif
225 #else
226  #define IOT_BLE_CHAR_READ_PERM eBTPermRead
227  #define IOT_BLE_CHAR_WRITE_PERM eBTPermWrite
228 #endif
229 
234 #ifndef IOT_BLE_ENABLE_FREERTOS_GATT_SERVICES
235  #define IOT_BLE_ENABLE_FREERTOS_GATT_SERVICES ( 1 )
236 #endif
237 
241 #ifndef IOT_BLE_ADD_CUSTOM_SERVICES
242  #define IOT_BLE_ADD_CUSTOM_SERVICES ( 0 )
243 #endif
244 
245 
251 #if ( IOT_BLE_ENABLE_FREERTOS_GATT_SERVICES == 1 )
252  #ifndef IOT_BLE_ENABLE_DEVICE_INFO_SERVICE
253  #define IOT_BLE_ENABLE_DEVICE_INFO_SERVICE ( 1 )
254  #endif
255 #else
256  #define IOT_BLE_ENABLE_DEVICE_INFO_SERVICE ( 0 )
257 #endif
258 
259 
267 #if ( IOT_BLE_ENABLE_FREERTOS_GATT_SERVICES == 1 )
268  #ifndef IOT_BLE_ENABLE_WIFI_PROVISIONING
269  #define IOT_BLE_ENABLE_WIFI_PROVISIONING ( 0 )
270  #endif
271 #else
272  #define IOT_BLE_ENABLE_WIFI_PROVISIONING ( 0 )
273 #endif
274 
281 #if ( IOT_BLE_ENABLE_FREERTOS_GATT_SERVICES == 1 )
282  #ifndef IOT_BLE_ENABLE_MQTT
283  #define IOT_BLE_ENABLE_MQTT ( 1 )
284  #endif
285 #else
286  #define IOT_BLE_ENABLE_MQTT ( 0 )
287 #endif
288 
289 
294 #if ( IOT_BLE_ENABLE_FREERTOS_GATT_SERVICES == 1 )
295  #ifndef IOT_BLE_ENABLE_DATA_TRANSFER_SERVICE
296  #define IOT_BLE_ENABLE_DATA_TRANSFER_SERVICE ( 1 )
297  #endif
298 #else
299  #define IOT_BLE_ENABLE_DATA_TRANSFER_SERVICE ( 0 )
300 #endif
301 
302 
308 #ifndef IOT_BLE_WIFI_PROVISIONIG_MAX_SCAN_NETWORKS
309  #define IOT_BLE_WIFI_PROVISIONIG_MAX_SCAN_NETWORKS ( 10 )
310 #endif
311 
312 
313 /* @brief Controls the number of network that can be saved using WIFI provisioning.
314  *
315  * The number should be set according to amount of flash space available on the device.
316  * The size increase in multiple of sizeof(WIFINetworkProfile_t).
317  */
318 #ifndef IOT_BLE_WIFI_PROVISIONING_MAX_SAVED_NETWORKS
319  #define IOT_BLE_WIFI_PROVISIONING_MAX_SAVED_NETWORKS ( 8 )
320 #endif
321 
325 #ifndef IOT_BLE_MQTT_CREATE_CONNECTION_WAIT_MS
326  #define IOT_BLE_MQTT_CREATE_CONNECTION_WAIT_MS ( 1000 * IOT_BLE_NUMERIC_COMPARISON_TIMEOUT_SEC )
327 #endif
328 
332 #ifndef IOT_BLE_MQTT_CREATE_CONNECTION_RETRY
333  #define IOT_BLE_MQTT_CREATE_CONNECTION_RETRY ( 60 )
334 #endif
335 
336 
337 /*
338  * @brief UUID mask for data transfer services.
339  */
340 #define IOT_BLE_DATA_TRANSFER_SERVICE_UUID_MASK 0xC3, 0x4C, 0x04, 0x48, 0x02, 0xA0, 0xA9, 0x40, 0x2E, 0xD7, 0x6A, 0x16, 0xD7, 0xA9
341 
346 #define IOT_BLE_DATA_TRANSFER_SERVICE_TYPE_MQTT 0x00
347 
352 #define IOT_BLE_DATA_TRANSFER_SERVICE_TYPE_WIFI_PROVISIONING 0x01
353 
357 #ifndef IOT_BLE_DATA_TRANSFER_TX_BUFFER_SIZE
358  #define IOT_BLE_DATA_TRANSFER_TX_BUFFER_SIZE ( 1024 )
359 #endif
360 
365 #ifndef IOT_BLE_DATA_TRANSFER_RX_BUFFER_SIZE
366  #define IOT_BLE_DATA_TRANSFER_RX_BUFFER_SIZE ( 1024 )
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_ */