Skip to content

Commit 4fa3fad

Browse files
theshtevespeterharperuk
authored andcommitted
Add pico_btstack_mesh CMake library build test
1 parent f08fe38 commit 4fa3fad

File tree

8 files changed

+682
-0
lines changed

8 files changed

+682
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
3+
include(pico_sdk_import.cmake)
4+
project(mesh_node_demo C CXX ASM)
5+
6+
set(PICO_BOARD pico_w)
7+
set(CMAKE_C STANDARD 11)
8+
set(CMAKE_CXX_STANDARD 17)
9+
10+
pico_sdk_init()
11+
12+
add_compile_options(
13+
-Wall
14+
-Wno-format # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
15+
-Wno-unused-function # we have some for the docs that aren't called
16+
-Wno-maybe-uninitialized
17+
-O3
18+
-g
19+
)
20+
21+
add_executable(mesh_node_demo mesh_node_demo.c)
22+
23+
pico_enable_stdio_usb(mesh_node_demo 1) # Enable USB output
24+
pico_enable_stdio_uart(mesh_node_demo 0) # Disable UART output
25+
pico_add_extra_outputs(mesh_node_demo) # Generate map/bin/hex/uf2
26+
27+
target_include_directories(mesh_node_demo
28+
PRIVATE ${CMAKE_CURRENT_LIST_DIR}
29+
)
30+
31+
target_link_libraries(mesh_node_demo
32+
hardware_adc
33+
pico_btstack_cyw43
34+
pico_btstack_mesh
35+
pico_cyw43_arch_lwip_threadsafe_background
36+
pico_stdlib
37+
)
38+
39+
target_link_options(mesh_node_demo
40+
PRIVATE "LINKER:--print-memory-usage"
41+
PRIVATE "LINKER:--verbose"
42+
)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//
2+
// btstack_config.h for Raspberry Pi port
3+
//
4+
// Documentation: https://bluekitchen-gmbh.com/btstack/#how_to/
5+
//
6+
7+
#ifndef BTSTACK_CONFIG_H
8+
#define BTSTACK_CONFIG_H
9+
10+
// Port related features
11+
#define HAVE_ASSERT
12+
#define HAVE_BTSTACK_STDIN
13+
#define HAVE_MALLOC
14+
#define HAVE_POSIX_FILE_IO
15+
#define HAVE_POSIX_TIME
16+
17+
// BTstack features that can be enabled
18+
//#define ENABLE_BLE // Already defined in pico_btstack_ble
19+
#define ENABLE_LE_CENTRAL
20+
#define ENABLE_LE_DATA_LENGTH_EXTENSION
21+
#define ENABLE_LE_PERIPHERAL
22+
#define ENABLE_LE_SECURE_CONNECTIONS
23+
#define ENABLE_LOG_ERROR
24+
#define ENABLE_LOG_INFO
25+
#define ENABLE_PRINTF_HEXDUMP
26+
27+
// Mesh Configuration
28+
//#define ENABLE_MESH // Already defined in pico_btstack_mesh
29+
#define ENABLE_MESH_ADV_BEARER
30+
#define ENABLE_MESH_GATT_BEARER
31+
#define ENABLE_MESH_PB_ADV
32+
#define ENABLE_MESH_PB_GATT
33+
#define ENABLE_MESH_PROVISIONER
34+
#define ENABLE_MESH_PROXY_SERVER
35+
36+
// BTstack configuration. buffers, sizes, ...
37+
#define HCI_ACL_CHUNK_SIZE_ALIGNMENT 4
38+
#define HCI_ACL_PAYLOAD_SIZE (1691 + 4)
39+
#define HCI_INCOMING_PRE_BUFFER_SIZE 14 // sizeof BNEP header, avoid memcpy
40+
#define HCI_OUTGOING_PRE_BUFFER_SIZE 4
41+
42+
#define MAX_NR_MESH_SUBNETS 2
43+
#define MAX_NR_MESH_TRANSPORT_KEYS 16
44+
#define MAX_NR_MESH_VIRTUAL_ADDRESSES 16
45+
46+
// allow for one NetKey update
47+
#define MAX_NR_MESH_NETWORK_KEYS (MAX_NR_MESH_SUBNETS+1)
48+
49+
#define NVM_NUM_DEVICE_DB_ENTRIES 16
50+
#define NVM_NUM_LINK_KEYS 16
51+
52+
#endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef _LWIPOPTS_H
2+
#define _LWIPOPTS_H
3+
4+
// Generally you would define your own explicit list of lwIP options
5+
// (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html)
6+
//
7+
// This example uses a common include to avoid repetition
8+
#include "lwipopts_examples_common.h"
9+
10+
#if !NO_SYS
11+
#define TCPIP_THREAD_STACKSIZE 1024
12+
#define DEFAULT_THREAD_STACKSIZE 1024
13+
#define DEFAULT_RAW_RECVMBOX_SIZE 8
14+
#define TCPIP_MBOX_SIZE 8
15+
#define LWIP_TIMEVAL_PRIVATE 0
16+
17+
// not necessary, can be done either way
18+
#define LWIP_TCPIP_CORE_LOCKING_INPUT 1
19+
#endif
20+
21+
#endif
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#ifndef _LWIPOPTS_EXAMPLE_COMMONH_H
2+
#define _LWIPOPTS_EXAMPLE_COMMONH_H
3+
4+
5+
// Common settings used in most of the pico_w examples
6+
// (see https://www.nongnu.org/lwip/2_1_x/group__lwip__opts.html for details)
7+
8+
// allow override in some examples
9+
#ifndef NO_SYS
10+
#define NO_SYS 1
11+
#endif
12+
// allow override in some examples
13+
#ifndef LWIP_SOCKET
14+
#define LWIP_SOCKET 0
15+
#endif
16+
#if PICO_CYW43_ARCH_POLL
17+
#define MEM_LIBC_MALLOC 1
18+
#else
19+
// MEM_LIBC_MALLOC is incompatible with non polling versions
20+
#define MEM_LIBC_MALLOC 0
21+
#endif
22+
#define MEM_ALIGNMENT 4
23+
#define MEM_SIZE 4000
24+
#define MEMP_NUM_TCP_SEG 32
25+
#define MEMP_NUM_ARP_QUEUE 10
26+
#define PBUF_POOL_SIZE 24
27+
#define LWIP_ARP 1
28+
#define LWIP_ETHERNET 1
29+
#define LWIP_ICMP 1
30+
#define LWIP_RAW 1
31+
#define TCP_WND (8 * TCP_MSS)
32+
#define TCP_MSS 1460
33+
#define TCP_SND_BUF (8 * TCP_MSS)
34+
#define TCP_SND_QUEUELEN ((4 * (TCP_SND_BUF) + (TCP_MSS - 1)) / (TCP_MSS))
35+
#define LWIP_NETIF_STATUS_CALLBACK 1
36+
#define LWIP_NETIF_LINK_CALLBACK 1
37+
#define LWIP_NETIF_HOSTNAME 1
38+
#define LWIP_NETCONN 0
39+
#define MEM_STATS 0
40+
#define SYS_STATS 0
41+
#define MEMP_STATS 0
42+
#define LINK_STATS 0
43+
// #define ETH_PAD_SIZE 2
44+
#define LWIP_CHKSUM_ALGORITHM 3
45+
#define LWIP_DHCP 1
46+
#define LWIP_IPV4 1
47+
#define LWIP_TCP 1
48+
#define LWIP_UDP 1
49+
#define LWIP_DNS 1
50+
#define LWIP_TCP_KEEPALIVE 1
51+
#define LWIP_NETIF_TX_SINGLE_PBUF 1
52+
#define DHCP_DOES_ARP_CHECK 0
53+
#define LWIP_DHCP_DOES_ACD_CHECK 0
54+
55+
#ifndef NDEBUG
56+
#define LWIP_DEBUG 1
57+
#define LWIP_STATS 1
58+
#define LWIP_STATS_DISPLAY 1
59+
#endif
60+
61+
#define ETHARP_DEBUG LWIP_DBG_OFF
62+
#define NETIF_DEBUG LWIP_DBG_OFF
63+
#define PBUF_DEBUG LWIP_DBG_OFF
64+
#define API_LIB_DEBUG LWIP_DBG_OFF
65+
#define API_MSG_DEBUG LWIP_DBG_OFF
66+
#define SOCKETS_DEBUG LWIP_DBG_OFF
67+
#define ICMP_DEBUG LWIP_DBG_OFF
68+
#define INET_DEBUG LWIP_DBG_OFF
69+
#define IP_DEBUG LWIP_DBG_OFF
70+
#define IP_REASS_DEBUG LWIP_DBG_OFF
71+
#define RAW_DEBUG LWIP_DBG_OFF
72+
#define MEM_DEBUG LWIP_DBG_OFF
73+
#define MEMP_DEBUG LWIP_DBG_OFF
74+
#define SYS_DEBUG LWIP_DBG_OFF
75+
#define TCP_DEBUG LWIP_DBG_OFF
76+
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
77+
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
78+
#define TCP_RTO_DEBUG LWIP_DBG_OFF
79+
#define TCP_CWND_DEBUG LWIP_DBG_OFF
80+
#define TCP_WND_DEBUG LWIP_DBG_OFF
81+
#define TCP_FR_DEBUG LWIP_DBG_OFF
82+
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
83+
#define TCP_RST_DEBUG LWIP_DBG_OFF
84+
#define UDP_DEBUG LWIP_DBG_OFF
85+
#define TCPIP_DEBUG LWIP_DBG_OFF
86+
#define PPP_DEBUG LWIP_DBG_OFF
87+
#define SLIP_DEBUG LWIP_DBG_OFF
88+
#define DHCP_DEBUG LWIP_DBG_OFF
89+
90+
#endif /* __LWIPOPTS_H__ */

0 commit comments

Comments
 (0)