From 26368b1c36c0b84d0779d63f189fb7ffa953b97b Mon Sep 17 00:00:00 2001 From: "Mr. Green's Workshop" <76992231+MrGreensWorkshop@users.noreply.github.com> Date: Sat, 11 Mar 2023 06:45:30 +0900 Subject: [PATCH] Splitting BLE and BT Classic dependencies (#332) Co-authored-by: Peter Harper --- pico_w/bt/CMakeLists.txt | 8 +++----- pico_w/bt/config/btstack_config.h | 6 ++++-- pico_w/bt/gatt_counter_with_wifi/CMakeLists.txt | 6 +++--- pico_w/bt/gatt_streamer_server_with_wifi/CMakeLists.txt | 6 +++--- pico_w/bt/pan_lwip_http_server/CMakeLists.txt | 6 +++--- pico_w/bt/picow_bt_example_common.c | 6 ++++-- pico_w/bt/spp_streamer_with_wifi/CMakeLists.txt | 6 +++--- 7 files changed, 23 insertions(+), 21 deletions(-) diff --git a/pico_w/bt/CMakeLists.txt b/pico_w/bt/CMakeLists.txt index 3ea5f33..518f071 100644 --- a/pico_w/bt/CMakeLists.txt +++ b/pico_w/bt/CMakeLists.txt @@ -42,8 +42,6 @@ target_sources(picow_bt_example_common INTERFACE ) target_link_libraries(picow_bt_example_common INTERFACE pico_stdlib - pico_btstack_ble - pico_btstack_classic pico_btstack_cyw43 ) target_include_directories(picow_bt_example_common INTERFACE @@ -301,9 +299,9 @@ endfunction() # Extra parameters indicate extra libraries to link to function(picow_bt_example NAME) picow_bt_example_target_name(${NAME} TARGET_NAME) - picow_bt_example_poll(${NAME} ${TARGET_NAME} picow_bt_example_no_cyw43_lwip_poll ${ARGN}) - picow_bt_example_background(${NAME} ${TARGET_NAME} picow_bt_example_no_cyw43_lwip_background ${ARGN}) - picow_bt_example_freertos(${NAME} ${TARGET_NAME} picow_bt_example_no_cyw43_lwip_freertos ${ARGN}) + picow_bt_example_poll(${NAME} ${TARGET_NAME} picow_bt_example_no_cyw43_lwip_poll pico_btstack_ble pico_btstack_classic ${ARGN}) + picow_bt_example_background(${NAME} ${TARGET_NAME} picow_bt_example_no_cyw43_lwip_background pico_btstack_ble pico_btstack_classic ${ARGN}) + picow_bt_example_freertos(${NAME} ${TARGET_NAME} picow_bt_example_no_cyw43_lwip_freertos pico_btstack_ble pico_btstack_classic ${ARGN}) endfunction() # List of examples from btstack diff --git a/pico_w/bt/config/btstack_config.h b/pico_w/bt/config/btstack_config.h index dfc89f8..7e15253 100644 --- a/pico_w/bt/config/btstack_config.h +++ b/pico_w/bt/config/btstack_config.h @@ -2,9 +2,11 @@ #define _PICO_BTSTACK_BTSTACK_CONFIG_H // BTstack features that can be enabled +#ifdef ENABLE_BLE #define ENABLE_LE_PERIPHERAL #define ENABLE_LE_CENTRAL #define ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE +#endif #define ENABLE_LOG_INFO #define ENABLE_LOG_ERROR #define ENABLE_PRINTF_HEXDUMP @@ -67,11 +69,11 @@ #define HAVE_BTSTACK_STDIN -// To get the audio demos working even with HCI dump at 115200, this truncates long ACL packetws +// To get the audio demos working even with HCI dump at 115200, this truncates long ACL packets //#define HCI_DUMP_STDOUT_MAX_SIZE_ACL 100 #ifdef ENABLE_CLASSIC #define ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE #endif -#endif // MICROPY_INCLUDED_EXTMOD_BTSTACK_BTSTACK_CONFIG_H +#endif // _PICO_BTSTACK_BTSTACK_CONFIG_H diff --git a/pico_w/bt/gatt_counter_with_wifi/CMakeLists.txt b/pico_w/bt/gatt_counter_with_wifi/CMakeLists.txt index 500deca..f8fea0a 100644 --- a/pico_w/bt/gatt_counter_with_wifi/CMakeLists.txt +++ b/pico_w/bt/gatt_counter_with_wifi/CMakeLists.txt @@ -1,6 +1,6 @@ set(NAME gatt_counter) picow_bt_example_target_name(${NAME}_with_wifi TARGET_NAME) -picow_bt_example_poll(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_poll) -picow_bt_example_background(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_background) -picow_bt_example_freertos(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_freertos) +picow_bt_example_poll(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_poll pico_btstack_ble) +picow_bt_example_background(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_background pico_btstack_ble) +picow_bt_example_freertos(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_freertos pico_btstack_ble) diff --git a/pico_w/bt/gatt_streamer_server_with_wifi/CMakeLists.txt b/pico_w/bt/gatt_streamer_server_with_wifi/CMakeLists.txt index d705b54..9599e6f 100644 --- a/pico_w/bt/gatt_streamer_server_with_wifi/CMakeLists.txt +++ b/pico_w/bt/gatt_streamer_server_with_wifi/CMakeLists.txt @@ -1,6 +1,6 @@ set(NAME gatt_streamer_server) picow_bt_example_target_name(${NAME}_with_wifi TARGET_NAME) -picow_bt_example_poll(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_poll) -picow_bt_example_background(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_background) -picow_bt_example_freertos(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_freertos) +picow_bt_example_poll(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_poll pico_btstack_ble) +picow_bt_example_background(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_background pico_btstack_ble) +picow_bt_example_freertos(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_freertos pico_btstack_ble) diff --git a/pico_w/bt/pan_lwip_http_server/CMakeLists.txt b/pico_w/bt/pan_lwip_http_server/CMakeLists.txt index 8904080..82379be 100644 --- a/pico_w/bt/pan_lwip_http_server/CMakeLists.txt +++ b/pico_w/bt/pan_lwip_http_server/CMakeLists.txt @@ -8,6 +8,6 @@ target_include_directories(pan_lwip_dhserver INTERFACE picow_bt_example_target_name(pan_lwip_http_server TARGET_NAME) -picow_bt_example_poll(pan_lwip_http_server ${TARGET_NAME} picow_bt_example_btstack_lwip_poll pan_lwip_dhserver pico_lwip_http) -picow_bt_example_background(pan_lwip_http_server ${TARGET_NAME} picow_bt_example_btstack_lwip_background pan_lwip_dhserver pico_lwip_http) -picow_bt_example_freertos(pan_lwip_http_server ${TARGET_NAME} picow_bt_example_btstack_lwip_freertos pan_lwip_dhserver pico_lwip_http) +picow_bt_example_poll(pan_lwip_http_server ${TARGET_NAME} picow_bt_example_btstack_lwip_poll pan_lwip_dhserver pico_lwip_http pico_btstack_classic) +picow_bt_example_background(pan_lwip_http_server ${TARGET_NAME} picow_bt_example_btstack_lwip_background pan_lwip_dhserver pico_lwip_http pico_btstack_classic) +picow_bt_example_freertos(pan_lwip_http_server ${TARGET_NAME} picow_bt_example_btstack_lwip_freertos pan_lwip_dhserver pico_lwip_http pico_btstack_classic) diff --git a/pico_w/bt/picow_bt_example_common.c b/pico_w/bt/picow_bt_example_common.c index 13393b3..7d93520 100644 --- a/pico_w/bt/picow_bt_example_common.c +++ b/pico_w/bt/picow_bt_example_common.c @@ -4,11 +4,14 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#if TEST_AUDIO #include "btstack_audio.h" +#endif #include "btstack_event.h" #include "hal_led.h" #include "pico/cyw43_arch.h" #include "pico/stdlib.h" +#include "btstack.h" #if defined(WIFI_SSID) && defined(WIFI_PASSWORD) #define TEST_BTWIFI 1 @@ -27,7 +30,6 @@ const btstack_audio_sink_t * btstack_audio_pico_sink_get_instance(void); #endif static btstack_packet_callback_registration_t hci_event_callback_registration; - static int led_state = 0; void hal_led_toggle(void){ @@ -35,7 +37,7 @@ void hal_led_toggle(void){ cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, led_state); } -static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ +static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ UNUSED(size); UNUSED(channel); bd_addr_t local_addr; diff --git a/pico_w/bt/spp_streamer_with_wifi/CMakeLists.txt b/pico_w/bt/spp_streamer_with_wifi/CMakeLists.txt index 02ed945..f30521f 100644 --- a/pico_w/bt/spp_streamer_with_wifi/CMakeLists.txt +++ b/pico_w/bt/spp_streamer_with_wifi/CMakeLists.txt @@ -1,6 +1,6 @@ set(NAME spp_streamer) picow_bt_example_target_name(${NAME}_with_wifi TARGET_NAME) -picow_bt_example_poll(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_poll) -picow_bt_example_background(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_background) -picow_bt_example_freertos(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_freertos) +picow_bt_example_poll(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_poll pico_btstack_classic) +picow_bt_example_background(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_background pico_btstack_classic) +picow_bt_example_freertos(${NAME} ${TARGET_NAME} picow_bt_example_cyw43_lwip_freertos pico_btstack_classic)