Skip to content

Commit 7a7664e

Browse files
committed
Add future support for btstack_config_common.h file
See raspberrypi/pico-examples#667
1 parent c74fc2c commit 7a7664e

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

scripts/btstack_config.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#ifndef _PICO_BTSTACK_CONFIG_COMMON_H
2+
#define _PICO_BTSTACK_CONFIG_COMMON_H
3+
4+
#ifndef ENABLE_BLE
5+
#error Please link to pico_btstack_ble
6+
#endif
7+
8+
// BTstack features that can be enabled
9+
#define ENABLE_LE_PERIPHERAL
10+
#define ENABLE_LOG_INFO
11+
#define ENABLE_LOG_ERROR
12+
#define ENABLE_PRINTF_HEXDUMP
13+
14+
// for the client
15+
#if RUNNING_AS_CLIENT
16+
#define ENABLE_LE_CENTRAL
17+
#define MAX_NR_GATT_CLIENTS 1
18+
#else
19+
#define MAX_NR_GATT_CLIENTS 0
20+
#endif
21+
22+
// BTstack configuration. buffers, sizes, ...
23+
#define HCI_OUTGOING_PRE_BUFFER_SIZE 4
24+
#define HCI_ACL_PAYLOAD_SIZE (255 + 4)
25+
#define HCI_ACL_CHUNK_SIZE_ALIGNMENT 4
26+
#define MAX_NR_HCI_CONNECTIONS 1
27+
#define MAX_NR_SM_LOOKUP_ENTRIES 3
28+
#define MAX_NR_WHITELIST_ENTRIES 16
29+
#define MAX_NR_LE_DEVICE_DB_ENTRIES 16
30+
31+
// Limit number of ACL/SCO Buffer to use by stack to avoid cyw43 shared bus overrun
32+
#define MAX_NR_CONTROLLER_ACL_BUFFERS 3
33+
#define MAX_NR_CONTROLLER_SCO_PACKETS 3
34+
35+
// Enable and configure HCI Controller to Host Flow Control to avoid cyw43 shared bus overrun
36+
#define ENABLE_HCI_CONTROLLER_TO_HOST_FLOW_CONTROL
37+
#define HCI_HOST_ACL_PACKET_LEN (255+4)
38+
#define HCI_HOST_ACL_PACKET_NUM 3
39+
#define HCI_HOST_SCO_PACKET_LEN 120
40+
#define HCI_HOST_SCO_PACKET_NUM 3
41+
42+
// Link Key DB and LE Device DB using TLV on top of Flash Sector interface
43+
#define NVM_NUM_DEVICE_DB_ENTRIES 16
44+
#define NVM_NUM_LINK_KEYS 16
45+
46+
// We don't give btstack a malloc, so use a fixed-size ATT DB.
47+
#define MAX_ATT_DB_SIZE 512
48+
49+
// BTstack HAL configuration
50+
#define HAVE_EMBEDDED_TIME_MS
51+
// map btstack_assert onto Pico SDK assert()
52+
#define HAVE_ASSERT
53+
// Some USB dongles take longer to respond to HCI reset (e.g. BCM20702A).
54+
#define HCI_RESET_RESEND_TIMEOUT_MS 1000
55+
#define ENABLE_SOFTWARE_AES128
56+
#define ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS
57+
58+
#endif // _PICO_BTSTACK_CONFIG_COMMON_H

scripts/pico_project.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,16 @@ def copyExampleConfigs(projectPath):
13451345
os.path.join(projectPath, "mbedtls_config_examples_common.h"),
13461346
)
13471347

1348+
btstack_config_path = os.path.join(projectPath, "btstack_config.h")
1349+
if os.path.exists(btstack_config_path):
1350+
with open(btstack_config_path, "r") as f:
1351+
if "btstack_config_common.h" in f.read():
1352+
# Write btstack_config for examples
1353+
shutil.copy(
1354+
os.path.join(sourcefolder, "btstack_config.h"),
1355+
os.path.join(projectPath, "btstack_config_common.h"),
1356+
)
1357+
13481358

13491359
def DoEverything(params):
13501360
if not os.path.exists(params["projectRoot"]):

0 commit comments

Comments
 (0)