Skip to content

Simplify standaline BT examples #667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 2 additions & 68 deletions pico_w/bt/standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,68 +1,2 @@
# Standalone example that reads from the on board temperature sensor and sends notifications via BLE
# Flashes slowly each second to show it's running
add_executable(picow_ble_temp_sensor
server.c server_common.c
)
target_link_libraries(picow_ble_temp_sensor
pico_stdlib
pico_btstack_ble
pico_btstack_cyw43
pico_cyw43_arch_none
hardware_adc
)
target_include_directories(picow_ble_temp_sensor PRIVATE
${CMAKE_CURRENT_LIST_DIR} # For btstack config
)
pico_btstack_make_gatt_header(picow_ble_temp_sensor PRIVATE "${CMAKE_CURRENT_LIST_DIR}/temp_sensor.gatt")

pico_add_extra_outputs(picow_ble_temp_sensor)
example_auto_set_url(picow_ble_temp_sensor)

# Standalone example that connects to picow_ble_temp_sensor and reads the temperature
# Flahes once quickly each second when it's running but not connected to another device
# Flashes twice quickly each second when connected to another device and reading it's temperature
add_executable(picow_ble_temp_reader
client.c
)
target_link_libraries(picow_ble_temp_reader
pico_stdlib
pico_btstack_ble
pico_btstack_cyw43
pico_cyw43_arch_none
hardware_adc
)
target_include_directories(picow_ble_temp_reader PRIVATE
${CMAKE_CURRENT_LIST_DIR} # For btstack config
)
target_compile_definitions(picow_ble_temp_reader PRIVATE
RUNNING_AS_CLIENT=1
)

pico_add_extra_outputs(picow_ble_temp_reader)
example_auto_set_url(picow_ble_temp_reader)

if (WIFI_SSID AND WIFI_PASSWORD)
# Another version of the sensor example, but this time also runs iperf over wifi
add_executable(picow_ble_temp_sensor_with_wifi
server_with_wifi.c server_common.c
)
target_link_libraries(picow_ble_temp_sensor_with_wifi
pico_stdlib
pico_btstack_ble
pico_btstack_cyw43
pico_cyw43_arch_lwip_threadsafe_background
pico_lwip_iperf
hardware_adc
)
target_include_directories(picow_ble_temp_sensor_with_wifi PRIVATE
${CMAKE_CURRENT_LIST_DIR} # For btstack config
)
target_compile_definitions(picow_ble_temp_sensor_with_wifi PRIVATE
WIFI_SSID=\"${WIFI_SSID}\"
WIFI_PASSWORD=\"${WIFI_PASSWORD}\"
)
pico_btstack_make_gatt_header(picow_ble_temp_sensor_with_wifi PRIVATE "${CMAKE_CURRENT_LIST_DIR}/temp_sensor.gatt")

pico_add_extra_outputs(picow_ble_temp_sensor_with_wifi)
example_auto_set_url(picow_ble_temp_sensor_with_wifi)
endif()
add_subdirectory(client)
add_subdirectory(server)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _PICO_BTSTACK_BTSTACK_CONFIG_H
#define _PICO_BTSTACK_BTSTACK_CONFIG_H
#ifndef _PICO_BTSTACK_CONFIG_COMMON_H
#define _PICO_BTSTACK_CONFIG_COMMON_H

#ifndef ENABLE_BLE
#error Please link to pico_btstack_ble
Expand Down
23 changes: 23 additions & 0 deletions pico_w/bt/standalone/client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Standalone example that connects to picow_ble_temp_sensor and reads the temperature
# Flahes once quickly each second when it's running but not connected to another device
# Flashes twice quickly each second when connected to another device and reading it's temperature
add_executable(picow_ble_temp_reader
client.c
)
target_link_libraries(picow_ble_temp_reader
pico_stdlib
pico_btstack_ble
pico_btstack_cyw43
pico_cyw43_arch_none
hardware_adc
)
target_include_directories(picow_ble_temp_reader PRIVATE
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/.. # For our common btstack config
)
target_compile_definitions(picow_ble_temp_reader PRIVATE
RUNNING_AS_CLIENT=1
)

pico_add_extra_outputs(picow_ble_temp_reader)
example_auto_set_url(picow_ble_temp_reader)
6 changes: 6 additions & 0 deletions pico_w/bt/standalone/client/btstack_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _PICO_BTSTACK_CONFIG_H
#define _PICO_BTSTACK_CONFIG_H

#include "btstack_config_common.h"

#endif
File renamed without changes.
105 changes: 0 additions & 105 deletions pico_w/bt/standalone/server.c

This file was deleted.

20 changes: 20 additions & 0 deletions pico_w/bt/standalone/server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Standalone example that reads from the on board temperature sensor and sends notifications via BLE
# Flashes slowly each second to show it's running
add_executable(picow_ble_temp_sensor
server.c
)
target_link_libraries(picow_ble_temp_sensor
pico_stdlib
pico_btstack_ble
pico_btstack_cyw43
pico_cyw43_arch_none
hardware_adc
)
target_include_directories(picow_ble_temp_sensor PRIVATE
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/.. # For our common btstack config
)
pico_btstack_make_gatt_header(picow_ble_temp_sensor PRIVATE "${CMAKE_CURRENT_LIST_DIR}/temp_sensor.gatt")

pico_add_extra_outputs(picow_ble_temp_sensor)
example_auto_set_url(picow_ble_temp_sensor)
6 changes: 6 additions & 0 deletions pico_w/bt/standalone/server/btstack_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef _PICO_BTSTACK_CONFIG_H
#define _PICO_BTSTACK_CONFIG_H

#include "btstack_config_common.h"

#endif
Loading