Skip to content

Commit 095fe18

Browse files
authored
Added support for custom app_conf.h (stm32duino#35)
1 parent 1cf1da0 commit 095fe18

File tree

3 files changed

+202
-150
lines changed

3 files changed

+202
-150
lines changed

Diff for: README.md

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ https://github.com/stm32duino/wiki/wiki/STM32duinoBLE#stm32duinoble-with-x-nucle
1616
For more information about ArduinoBLE library please visit the official web page at:
1717
https://github.com/arduino-libraries/ArduinoBLE
1818

19+
# Configuration
20+
STM32Cube_WPAN has several configuration options, which are set in the `app_conf.h`.
21+
This package has a default configuration named `app_conf_default.h`.
22+
The user can include the file `app_conf_custom.h` to customize the ble application. Options wrapped in `#ifndef, #endif` in `app_conf_default.h` can be overwritten. Additional options can be added.
23+
1924
## License
2025

2126
```

Diff for: src/utility/STM32Cube_FW/app_conf.h

+12-150
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,20 @@
1-
/**
2-
******************************************************************************
3-
* File Name : app_conf.h
4-
* Description : Application configuration file for STM32WPAN Middleware.
5-
******************************************************************************
6-
* @attention
7-
*
8-
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
9-
* All rights reserved.</center></h2>
10-
*
11-
* This software component is licensed by ST under Ultimate Liberty license
12-
* SLA0044, the "License"; You may not use this file except in compliance with
13-
* the License. You may obtain a copy of the License at:
14-
* www.st.com/SLA0044
15-
*
16-
******************************************************************************
17-
*/
1+
//-----------------------------
2+
// @file app_conf.h
3+
// @author Kasper Meldgaard
4+
// @brief Wrapper for BLE app configuration based on comment by fpistm
5+
// (https://github.com/stm32duino/STM32duinoBLE/issues/34).
6+
// @date 15-11-2021
7+
// @copyright Copyright (c) 2021
188

19-
/* Define to prevent recursive inclusion -------------------------------------*/
209
#ifndef APP_CONF_H
2110
#define APP_CONF_H
2211

23-
#include "hw.h"
2412
#include "ble_bufsize.h"
13+
#include "hw.h"
2514

26-
27-
/******************************************************************************
28-
* Application Config
29-
******************************************************************************/
30-
31-
/**< generic parameters ******************************************************/
32-
/* HCI related defines */
33-
34-
#define ACI_HAL_SET_TX_POWER_LEVEL 0xFC0F
35-
#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C
36-
#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D
37-
#define MAX_HCI_ACL_PACKET_SIZE (sizeof(TL_PacketHeader_t) + 5 + 251)
38-
#define HCI_RESET 0x0C03
39-
40-
#ifndef BLE_SHARED_MEM_BYTE_ORDER
41-
#define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST
15+
#if __has_include("app_conf_custom.h")
16+
#include "app_conf_custom.h"
4217
#endif
43-
#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128
44-
45-
/**
46-
* Define Tx Power
47-
*/
48-
#define CFG_TX_POWER (0x18) /* -0.15dBm */
49-
50-
/******************************************************************************
51-
* BLE Stack
52-
******************************************************************************/
53-
/**
54-
* Maximum number of simultaneous connections that the device will support.
55-
* Valid values are from 1 to 8
56-
*/
57-
#define CFG_BLE_NUM_LINK 8
58-
59-
/**
60-
* Maximum number of Services that can be stored in the GATT database.
61-
* Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user services
62-
*/
63-
#define CFG_BLE_NUM_GATT_SERVICES 8
64-
65-
/**
66-
* Maximum number of Attributes
67-
* (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the services)
68-
* that can be stored in the GATT database.
69-
* Note that certain characteristics and relative descriptors are added automatically during device initialization
70-
* so this parameters should be 9 plus the number of user Attributes
71-
*/
72-
#define CFG_BLE_NUM_GATT_ATTRIBUTES 68
73-
74-
/**
75-
* Maximum supported ATT_MTU size
76-
*/
77-
#define CFG_BLE_MAX_ATT_MTU (156)
78-
79-
/**
80-
* Size of the storage area for Attribute values
81-
* This value depends on the number of attributes used by application. In particular the sum of the following quantities (in octets) should be made for each attribute:
82-
* - attribute value length
83-
* - 5, if UUID is 16 bit; 19, if UUID is 128 bit
84-
* - 2, if server configuration descriptor is used
85-
* - 2*DTM_NUM_LINK, if client configuration descriptor is used
86-
* - 2, if extended properties is used
87-
* The total amount of memory needed is the sum of the above quantities for each attribute.
88-
*/
89-
#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344)
90-
91-
/**
92-
* Prepare Write List size in terms of number of packet
93-
*/
94-
//#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU)
95-
#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A)
96-
97-
/**
98-
* Number of allocated memory blocks
99-
*/
100-
//#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK))
101-
#define CFG_BLE_MBLOCK_COUNT (0x79)
102-
/**
103-
* Enable or disable the Extended Packet length feature. Valid values are 0 or 1.
104-
*/
105-
#define CFG_BLE_DATA_LENGTH_EXTENSION 1
106-
107-
/**
108-
* Sleep clock accuracy in Slave mode (ppm value)
109-
*/
110-
#define CFG_BLE_SLAVE_SCA 500
111-
112-
/**
113-
* Sleep clock accuracy in Master mode
114-
* 0 : 251 ppm to 500 ppm
115-
* 1 : 151 ppm to 250 ppm
116-
* 2 : 101 ppm to 150 ppm
117-
* 3 : 76 ppm to 100 ppm
118-
* 4 : 51 ppm to 75 ppm
119-
* 5 : 31 ppm to 50 ppm
120-
* 6 : 21 ppm to 30 ppm
121-
* 7 : 0 ppm to 20 ppm
122-
*/
123-
#define CFG_BLE_MASTER_SCA 0
124-
125-
/**
126-
* Source for the 32 kHz slow speed clock
127-
* 1 : internal RO
128-
* 0 : external crystal ( no calibration )
129-
*/
130-
#define CFG_BLE_LSE_SOURCE 0
131-
132-
/**
133-
* Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us)
134-
*/
135-
#define CFG_BLE_HSE_STARTUP_TIME 0x148
136-
137-
/**
138-
* Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us)
139-
*/
140-
#define CFG_BLE_MAX_CONN_EVENT_LENGTH ( 0xFFFFFFFF )
141-
142-
/**
143-
* Viterbi Mode
144-
* 1 : enabled
145-
* 0 : disabled
146-
*/
147-
#define CFG_BLE_VITERBI_MODE 1
148-
149-
/**
150-
* LL Only Mode
151-
* 1 : LL Only
152-
* 0 : LL + Host
153-
*/
154-
#define CFG_BLE_LL_ONLY 1
155-
156-
#endif /* APP_CONF_H */
18+
#include "app_conf_default.h"
15719

158-
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
20+
#endif /* APP_CONF_H */

Diff for: src/utility/STM32Cube_FW/app_conf_default.h

+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/**
2+
******************************************************************************
3+
* File Name : app_conf_default.h
4+
* Description : Default application configuration file for STM32WPAN Middleware.
5+
******************************************************************************
6+
* @attention
7+
*
8+
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
9+
* All rights reserved.</center></h2>
10+
*
11+
* This software component is licensed by ST under Ultimate Liberty license
12+
* SLA0044, the "License"; You may not use this file except in compliance with
13+
* the License. You may obtain a copy of the License at:
14+
* www.st.com/SLA0044
15+
*
16+
******************************************************************************
17+
*/
18+
19+
/* Define to prevent recursive inclusion -------------------------------------*/
20+
#ifndef APP_CONF_DEFAULT_H
21+
#define APP_CONF_DEFAULT_H
22+
23+
/******************************************************************************
24+
* Application Config
25+
******************************************************************************/
26+
27+
/**< generic parameters ******************************************************/
28+
/* HCI related defines */
29+
30+
#define ACI_HAL_SET_TX_POWER_LEVEL 0xFC0F
31+
#define ACI_WRITE_CONFIG_DATA_OPCODE 0xFC0C
32+
#define ACI_READ_CONFIG_DATA_OPCODE 0xFC0D
33+
#define MAX_HCI_ACL_PACKET_SIZE (sizeof(TL_PacketHeader_t) + 5 + 251)
34+
#define HCI_RESET 0x0C03
35+
36+
#ifndef BLE_SHARED_MEM_BYTE_ORDER
37+
#define BLE_SHARED_MEM_BYTE_ORDER MSBFIRST
38+
#endif
39+
#define BLE_MODULE_SHARED_MEM_BUFFER_SIZE 128
40+
41+
/**
42+
* Define Tx Power
43+
*/
44+
#ifndef CFG_TX_POWER
45+
#define CFG_TX_POWER (0x18) /* -0.15dBm */
46+
#endif
47+
48+
/******************************************************************************
49+
* BLE Stack
50+
******************************************************************************/
51+
/**
52+
* Maximum number of simultaneous connections that the device will support.
53+
* Valid values are from 1 to 8
54+
*/
55+
#ifndef CFG_BLE_NUM_LINK
56+
#define CFG_BLE_NUM_LINK 8
57+
#endif
58+
59+
/**
60+
* Maximum number of Services that can be stored in the GATT database.
61+
* Note that the GAP and GATT services are automatically added so this parameter should be 2 plus the number of user
62+
* services
63+
*/
64+
#ifndef CFG_BLE_NUM_GATT_SERVICES
65+
#define CFG_BLE_NUM_GATT_SERVICES 8
66+
#endif
67+
68+
/**
69+
* Maximum number of Attributes
70+
* (i.e. the number of characteristic + the number of characteristic values + the number of descriptors, excluding the
71+
* services) that can be stored in the GATT database. Note that certain characteristics and relative descriptors are
72+
* added automatically during device initialization so this parameters should be 9 plus the number of user Attributes
73+
*/
74+
#ifndef CFG_BLE_NUM_GATT_ATTRIBUTES
75+
#define CFG_BLE_NUM_GATT_ATTRIBUTES 68
76+
#endif
77+
78+
/**
79+
* Maximum supported ATT_MTU size
80+
*/
81+
#ifndef CFG_BLE_MAX_ATT_MTU
82+
#define CFG_BLE_MAX_ATT_MTU (156)
83+
#endif
84+
85+
/**
86+
* Size of the storage area for Attribute values
87+
* This value depends on the number of attributes used by application. In particular the sum of the following
88+
* quantities (in octets) should be made for each attribute:
89+
* - attribute value length
90+
* - 5, if UUID is 16 bit; 19, if UUID is 128 bit
91+
* - 2, if server configuration descriptor is used
92+
* - 2*DTM_NUM_LINK, if client configuration descriptor is used
93+
* - 2, if extended properties is used
94+
* The total amount of memory needed is the sum of the above quantities for each attribute.
95+
*/
96+
#ifndef CFG_BLE_ATT_VALUE_ARRAY_SIZE
97+
#define CFG_BLE_ATT_VALUE_ARRAY_SIZE (1344)
98+
#endif
99+
100+
/**
101+
* Prepare Write List size in terms of number of packet
102+
*/
103+
//#define CFG_BLE_PREPARE_WRITE_LIST_SIZE BLE_PREP_WRITE_X_ATT(CFG_BLE_MAX_ATT_MTU)
104+
#ifndef CFG_BLE_PREPARE_WRITE_LIST_SIZE
105+
#define CFG_BLE_PREPARE_WRITE_LIST_SIZE (0x3A)
106+
#endif
107+
108+
/**
109+
* Number of allocated memory blocks
110+
*/
111+
//#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU,
112+
// CFG_BLE_NUM_LINK))
113+
#ifndef CFG_BLE_MBLOCK_COUNT
114+
#define CFG_BLE_MBLOCK_COUNT (0x79)
115+
#endif
116+
117+
/**
118+
* Enable or disable the Extended Packet length feature. Valid values are 0 or 1.
119+
*/
120+
#ifndef CFG_BLE_DATA_LENGTH_EXTENSION
121+
#define CFG_BLE_DATA_LENGTH_EXTENSION 1
122+
#endif
123+
124+
/**
125+
* Sleep clock accuracy in Slave mode (ppm value)
126+
*/
127+
#ifndef CFG_BLE_SLAVE_SCA
128+
#define CFG_BLE_SLAVE_SCA 500
129+
#endif
130+
131+
/**
132+
* Sleep clock accuracy in Master mode
133+
* 0 : 251 ppm to 500 ppm
134+
* 1 : 151 ppm to 250 ppm
135+
* 2 : 101 ppm to 150 ppm
136+
* 3 : 76 ppm to 100 ppm
137+
* 4 : 51 ppm to 75 ppm
138+
* 5 : 31 ppm to 50 ppm
139+
* 6 : 21 ppm to 30 ppm
140+
* 7 : 0 ppm to 20 ppm
141+
*/
142+
#ifndef CFG_BLE_MASTER_SCA
143+
#define CFG_BLE_MASTER_SCA 0
144+
#endif
145+
146+
/**
147+
* Source for the 32 kHz slow speed clock
148+
* 1 : internal RO
149+
* 0 : external crystal ( no calibration )
150+
*/
151+
#ifndef CFG_BLE_LSE_SOURCE
152+
#define CFG_BLE_LSE_SOURCE 0
153+
#endif
154+
155+
/**
156+
* Start up time of the high speed (16 or 32 MHz) crystal oscillator in units of 625/256 us (~2.44 us)
157+
*/
158+
#ifndef CFG_BLE_HSE_STARTUP_TIME
159+
#define CFG_BLE_HSE_STARTUP_TIME 0x148
160+
#endif
161+
162+
/**
163+
* Maximum duration of the connection event when the device is in Slave mode in units of 625/256 us (~2.44 us)
164+
*/
165+
#ifndef CFG_BLE_MAX_CONN_EVENT_LENGTH
166+
#define CFG_BLE_MAX_CONN_EVENT_LENGTH (0xFFFFFFFF)
167+
#endif
168+
169+
/**
170+
* Viterbi Mode
171+
* 1 : enabled
172+
* 0 : disabled
173+
*/
174+
#define CFG_BLE_VITERBI_MODE 1
175+
176+
/**
177+
* LL Only Mode
178+
* 1 : LL Only
179+
* 0 : LL + Host
180+
*/
181+
#define CFG_BLE_LL_ONLY 1
182+
183+
#endif /* APP_CONF_DEFAULT_H */
184+
185+
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

0 commit comments

Comments
 (0)