如何设置和运行 Raspberry Pi Pico W 蓝牙示例?

问题描述 投票:0回答:2

我正在尝试在 pico-sdk 中运行 spp_counter.c 示例。当我运行 make 时,我收到此错误:

fatal error: btstack.h: No such file or directory
58 | #include "btstack.h"

代码来自存储库。 CMakeLists.txt:

cmake_minimum_required(VERSION 3.13)

# initialize the SDK based on PICO_SDK_PATH
# Include build functions from Pico SDK
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)

project(my_project)

# initialize the Raspberry Pi Pico SDK
set(PICO_BOARD pico_w)

pico_sdk_init()

# rest of your project
add_executable(test
    test.c
)

# Add pico_stdlib library which aggregates commonly used features
target_link_libraries(test pico_stdlib)

# create map/bin/hex/uf2 file in addition to ELF.
pico_add_extra_outputs(test)

我不确定我错过了什么。

c bluetooth microcontroller raspberry-pi-pico
2个回答
1
投票

我遇到了同样的问题,直到我看到独立示例。必须包含一个

btstack_config.h
,并且还需要链接一些库,请查看 CMakeLists.txt 以了解需要添加到自己的 CMakeLists 文件中的内容。所有示例都在同一个文件中,但核心蓝牙库用于链接到所有可执行文件,因此很容易发现它们。

target_link_libraries(picow_ble_temp_sensor # executable
    pico_stdlib # standard lib, pretty much always linked
    pico_btstack_ble # Needed for ble
    pico_btstack_cyw43 # Needed for ble
    pico_cyw43_arch_none # Needed for pico_w
    hardware_adc # don't think it's needed (but haven't tested)
    )
target_include_directories(picow_ble_temp_sensor PRIVATE
    ${CMAKE_CURRENT_LIST_DIR} # For btstack config (copy their file)
    )

确保您也更新了子模块

update git submodule update --init


0
投票

提示:尝试从您的 SDK 目录中执行“git submodule update --init”

© www.soinside.com 2019 - 2024. All rights reserved.