From 1c11e0b13792851a3a63510cff5bb9ea6a0a3fce Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Fri, 20 Dec 2024 22:33:43 -0800 Subject: [PATCH] pico: don't use latest btstack since BLE connections don't finish (?) --- .github/workflows/esp-idf-latest.yaml | 24 +++++------------------- examples/pico_w/CMakeLists.txt | 24 ++++++++++++++---------- examples/pico_w/src/my_platform.c | 4 ++-- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/.github/workflows/esp-idf-latest.yaml b/.github/workflows/esp-idf-latest.yaml index dd6f2b19..4b8eb799 100644 --- a/.github/workflows/esp-idf-latest.yaml +++ b/.github/workflows/esp-idf-latest.yaml @@ -39,10 +39,7 @@ jobs: esp_idf_version: release-v5.3 target: esp32 path: 'examples/esp32' - command: | - rm sdkconfig - idf.py fullclean - idf.py build + command: "idf.py set-target esp32 && idf.py build" - name: Example ESP32-S3 build uses: espressif/esp-idf-ci-action@main @@ -50,10 +47,7 @@ jobs: esp_idf_version: release-v5.3 target: esp32-s3 path: 'examples/esp32' - command: | - rm sdkconfig - idf.py fullclean - idf.py build + command: "idf.py set-target esp32s3 && idf.py build" - name: Example ESP32-C3 build uses: espressif/esp-idf-ci-action@main @@ -61,10 +55,7 @@ jobs: esp_idf_version: release-v5.3 target: esp32-c3 path: 'examples/esp32' - command: | - rm sdkconfig - idf.py fullclean - idf.py build + command: "idf.py set-target esp32c3 && idf.py build" - name: Example ESP32-C6 build uses: espressif/esp-idf-ci-action@main @@ -73,9 +64,7 @@ jobs: target: esp32-c6 path: 'examples/esp32' command: | - rm sdkconfig - idf.py fullclean - idf.py build + command: "idf.py set-target esp32c6 && idf.py build" - name: Example ESP32-H2 build uses: espressif/esp-idf-ci-action@main @@ -83,9 +72,6 @@ jobs: esp_idf_version: release-v5.3 target: esp32-h2 path: 'examples/esp32' - command: | - rm sdkconfig - idf.py fullclean - idf.py build + command: "idf.py set-target esp32h2 && idf.py build" diff --git a/examples/pico_w/CMakeLists.txt b/examples/pico_w/CMakeLists.txt index e06ea248..a1443efe 100644 --- a/examples/pico_w/CMakeLists.txt +++ b/examples/pico_w/CMakeLists.txt @@ -11,10 +11,18 @@ endif() set(BLUEPAD32_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) # To use BTstack from Pico SDK do -#set(BTSTACK_ROOT ${PICO_SDK_PATH}/lib/btstack) -# To use it from Bluepad32 (up-to-date, with custom patches for controllers): -set(BTSTACK_ROOT ${BLUEPAD32_ROOT}/external/btstack) -set(PICO_BTSTACK_PATH ${BTSTACK_ROOT}) +set(BTSTACK_ROOT ${PICO_SDK_PATH}/lib/btstack) + +# If you want to use latest BTstack (included in Bluepad32 repo), +# uncomment the following lines, and comment the one above this one. +#set(BTSTACK_ROOT ${BLUEPAD32_ROOT}/external/btstack) +# Add missing files here. See: +# https://github.com/bluekitchen/btstack/issues/649 +# https://github.com/raspberrypi/pico-sdk/issues/2142 +#set(BTSTACK_MISSING_SOURCES +# ${BTSTACK_ROOT}/src/hci_event_builder.c +#) +#set(PICO_BTSTACK_PATH ${BTSTACK_ROOT}) # initialize the SDK based on PICO_SDK_PATH # note: this must happen before project() @@ -27,12 +35,6 @@ set(CMAKE_CXX_STANDARD 17) # initialize the Raspberry Pi Pico SDK pico_sdk_init() -# Add missing files here. See: -# https://github.com/bluekitchen/btstack/issues/649 -# https://github.com/raspberrypi/pico-sdk/issues/2142 -set(BTSTACK_MISSING_SOURCES - ${BTSTACK_ROOT}/src/hci_event_builder.c -) add_executable(bluepad32_picow_example_app src/main.c @@ -51,6 +53,8 @@ include_directories(bluepad32_picow_example_app src) # Needed when using BTstack from our branch include_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/include) include_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/include) +# Need for certain IDEs, like CLion. Otherwise it won't find btstack +include_directories(${BTSTACK_ROOT}/src) target_link_libraries(bluepad32_picow_example_app PUBLIC pico_stdlib diff --git a/examples/pico_w/src/my_platform.c b/examples/pico_w/src/my_platform.c index 03c43b87..dc30d93d 100644 --- a/examples/pico_w/src/my_platform.c +++ b/examples/pico_w/src/my_platform.c @@ -143,12 +143,12 @@ static void my_platform_on_controller_data(uni_hid_device_t* d, uni_controller_t // Toggle Bluetooth connections if ((gp->buttons & BUTTON_SHOULDER_L) && enabled) { logi("*** Disabling Bluetooth connections\n"); - uni_bt_enable_new_connections_safe(false); + uni_bt_stop_scanning_safe(); enabled = false; } if ((gp->buttons & BUTTON_SHOULDER_R) && !enabled) { logi("*** Enabling Bluetooth connections\n"); - uni_bt_enable_new_connections_safe(true); + uni_bt_start_scanning_and_autoconnect_safe(); enabled = true; } break;