Skip to content

Commit 8b35888

Browse files
Simplify standaline BT examples (#667)
* Simplify standaline BT examples Move client and server to their own folder Get rid of the wifi stuff * Change to btstack_config headers Add missing "static" to methods in server
1 parent 2c8fd3a commit 8b35888

File tree

12 files changed

+164
-323
lines changed

12 files changed

+164
-323
lines changed

pico_w/bt/standalone/CMakeLists.txt

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,2 @@
1-
# Standalone example that reads from the on board temperature sensor and sends notifications via BLE
2-
# Flashes slowly each second to show it's running
3-
add_executable(picow_ble_temp_sensor
4-
server.c server_common.c
5-
)
6-
target_link_libraries(picow_ble_temp_sensor
7-
pico_stdlib
8-
pico_btstack_ble
9-
pico_btstack_cyw43
10-
pico_cyw43_arch_none
11-
hardware_adc
12-
)
13-
target_include_directories(picow_ble_temp_sensor PRIVATE
14-
${CMAKE_CURRENT_LIST_DIR} # For btstack config
15-
)
16-
pico_btstack_make_gatt_header(picow_ble_temp_sensor PRIVATE "${CMAKE_CURRENT_LIST_DIR}/temp_sensor.gatt")
17-
18-
pico_add_extra_outputs(picow_ble_temp_sensor)
19-
example_auto_set_url(picow_ble_temp_sensor)
20-
21-
# Standalone example that connects to picow_ble_temp_sensor and reads the temperature
22-
# Flahes once quickly each second when it's running but not connected to another device
23-
# Flashes twice quickly each second when connected to another device and reading it's temperature
24-
add_executable(picow_ble_temp_reader
25-
client.c
26-
)
27-
target_link_libraries(picow_ble_temp_reader
28-
pico_stdlib
29-
pico_btstack_ble
30-
pico_btstack_cyw43
31-
pico_cyw43_arch_none
32-
hardware_adc
33-
)
34-
target_include_directories(picow_ble_temp_reader PRIVATE
35-
${CMAKE_CURRENT_LIST_DIR} # For btstack config
36-
)
37-
target_compile_definitions(picow_ble_temp_reader PRIVATE
38-
RUNNING_AS_CLIENT=1
39-
)
40-
41-
pico_add_extra_outputs(picow_ble_temp_reader)
42-
example_auto_set_url(picow_ble_temp_reader)
43-
44-
if (WIFI_SSID AND WIFI_PASSWORD)
45-
# Another version of the sensor example, but this time also runs iperf over wifi
46-
add_executable(picow_ble_temp_sensor_with_wifi
47-
server_with_wifi.c server_common.c
48-
)
49-
target_link_libraries(picow_ble_temp_sensor_with_wifi
50-
pico_stdlib
51-
pico_btstack_ble
52-
pico_btstack_cyw43
53-
pico_cyw43_arch_lwip_threadsafe_background
54-
pico_lwip_iperf
55-
hardware_adc
56-
)
57-
target_include_directories(picow_ble_temp_sensor_with_wifi PRIVATE
58-
${CMAKE_CURRENT_LIST_DIR} # For btstack config
59-
)
60-
target_compile_definitions(picow_ble_temp_sensor_with_wifi PRIVATE
61-
WIFI_SSID=\"${WIFI_SSID}\"
62-
WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
63-
)
64-
pico_btstack_make_gatt_header(picow_ble_temp_sensor_with_wifi PRIVATE "${CMAKE_CURRENT_LIST_DIR}/temp_sensor.gatt")
65-
66-
pico_add_extra_outputs(picow_ble_temp_sensor_with_wifi)
67-
example_auto_set_url(picow_ble_temp_sensor_with_wifi)
68-
endif()
1+
add_subdirectory(client)
2+
add_subdirectory(server)

pico_w/bt/standalone/btstack_config.h renamed to pico_w/bt/standalone/btstack_config_common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef _PICO_BTSTACK_BTSTACK_CONFIG_H
2-
#define _PICO_BTSTACK_BTSTACK_CONFIG_H
1+
#ifndef _PICO_BTSTACK_CONFIG_COMMON_H
2+
#define _PICO_BTSTACK_CONFIG_COMMON_H
33

44
#ifndef ENABLE_BLE
55
#error Please link to pico_btstack_ble
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Standalone example that connects to picow_ble_temp_sensor and reads the temperature
2+
# Flahes once quickly each second when it's running but not connected to another device
3+
# Flashes twice quickly each second when connected to another device and reading it's temperature
4+
add_executable(picow_ble_temp_reader
5+
client.c
6+
)
7+
target_link_libraries(picow_ble_temp_reader
8+
pico_stdlib
9+
pico_btstack_ble
10+
pico_btstack_cyw43
11+
pico_cyw43_arch_none
12+
hardware_adc
13+
)
14+
target_include_directories(picow_ble_temp_reader PRIVATE
15+
${CMAKE_CURRENT_LIST_DIR}
16+
${CMAKE_CURRENT_LIST_DIR}/.. # For our common btstack config
17+
)
18+
target_compile_definitions(picow_ble_temp_reader PRIVATE
19+
RUNNING_AS_CLIENT=1
20+
)
21+
22+
pico_add_extra_outputs(picow_ble_temp_reader)
23+
example_auto_set_url(picow_ble_temp_reader)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef _PICO_BTSTACK_CONFIG_H
2+
#define _PICO_BTSTACK_CONFIG_H
3+
4+
#include "btstack_config_common.h"
5+
6+
#endif
File renamed without changes.

pico_w/bt/standalone/server.c

Lines changed: 0 additions & 105 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Standalone example that reads from the on board temperature sensor and sends notifications via BLE
2+
# Flashes slowly each second to show it's running
3+
add_executable(picow_ble_temp_sensor
4+
server.c
5+
)
6+
target_link_libraries(picow_ble_temp_sensor
7+
pico_stdlib
8+
pico_btstack_ble
9+
pico_btstack_cyw43
10+
pico_cyw43_arch_none
11+
hardware_adc
12+
)
13+
target_include_directories(picow_ble_temp_sensor PRIVATE
14+
${CMAKE_CURRENT_LIST_DIR}
15+
${CMAKE_CURRENT_LIST_DIR}/.. # For our common btstack config
16+
)
17+
pico_btstack_make_gatt_header(picow_ble_temp_sensor PRIVATE "${CMAKE_CURRENT_LIST_DIR}/temp_sensor.gatt")
18+
19+
pico_add_extra_outputs(picow_ble_temp_sensor)
20+
example_auto_set_url(picow_ble_temp_sensor)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef _PICO_BTSTACK_CONFIG_H
2+
#define _PICO_BTSTACK_CONFIG_H
3+
4+
#include "btstack_config_common.h"
5+
6+
#endif

0 commit comments

Comments
 (0)