Skip to content
Open
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@ add_subdirectory(usb)
add_subdirectory(watchdog)
add_subdirectory(sha)
add_subdirectory(freertos)
add_subdirectory(bluetooth)
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ These networking examples are only available if Wi-Fi is supported by the board.
App|Description
---|---
[picow_access_point](pico_w/wifi/access_point) | Starts a WiFi access point, and fields DHCP requests.
[picow_access_point_wifi_provisioning](pico_w/wifi/access_point_wifi_provisioning) | Starts a WiFi access point, and allows WiFi credentials to be provisioned through a web page.
[picow_blink](pico_w/wifi/blink) | Blinks the on-board LED (which is connected via the WiFi chip).
[picow_blink_slow_clock](pico_w/wifi/blink) | Blinks the on-board LED (which is connected via the WiFi chip) with a slower system clock to show how to reconfigure communication with the WiFi chip at run time under those circumstances.
[picow_blink_fast_clock](pico_w/wifi/blink) | Blinks the on-board LED (which is connected via the WiFi chip) with a faster system clock to show how to reconfigure communication with the WiFi chip at build time under those circumstances.
Expand Down Expand Up @@ -295,9 +296,13 @@ Some standalone Bluetooth examples (without all the common example build infrast

App|Description
---|---
[picow_ble_temp_sensor](pico_w/bt/standalone) | Reads from the on board temperature sensor and sends notifications via BLE.
[picow_ble_temp_sensor_with_wifi](pico_w/bt/standalone) | Same as above but also connects to Wi-Fi and starts an "iperf" server.
[picow_ble_temp_reader](pico_w/bt/standalone) | Connects to one of the above "sensors" and reads the temperature.
[ble_pointer](bluetooth/ble_pointer) | Bluetooth HID mouse using mpu6050 to detect angle and move cursor.
[doorbell](bluetooth/doorbell) | Detects button press on transmitter Pico and illuminates LED on reciever Pico.
[temp_server](bluetooth/temp_sensor) | Reads from the on board temperature sensor and sends notifications via BLE.
[temp_client](bluetooth/temp_sensor) | Connects to the above temp_server and reads the temperature.
[secure_temp_server](bluetooth/secure_temp_sensor) | Variant of temp_server which allows exploration of LE_secure configurations.
[secure_temp_client](bluetooth/secure_temp_sensor) | Connects to the above secure_temp_server and reads the temperature.
[wifi_provisioner](bluetooth/wifi_provisioner) | Allows WiFi credentials to be provisioned over BLE, either using a mobile app or with the included python script.

### PIO

Expand Down
27 changes: 27 additions & 0 deletions bluetooth/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
if (NOT PICO_CYW43_SUPPORTED)
return()
endif()
if (DEFINED ENV{PICO_BTSTACK_PATH} AND (NOT PICO_BTSTACK_PATH))
set(PICO_BTSTACK_PATH $ENV{PICO_BTSTACK_PATH})
message("Using PICO_BTSTACK_PATH from environment ('${PICO_BTSTACK_PATH}')")
endif ()
set(BTSTACK_TEST_PATH "src/bluetooth.h")
if (NOT PICO_BTSTACK_PATH)
set(PICO_BTSTACK_PATH ${PICO_SDK_PATH}/lib/btstack)
if (PICO_CYW43_SUPPORTED AND NOT EXISTS ${PICO_BTSTACK_PATH}/${BTSTACK_TEST_PATH})
message(WARNING "btstack submodule has not been initialized; Pico Bluetooth support will be unavailable.
hint: try 'git submodule update --init' from your SDK directory (${PICO_SDK_PATH}).")
endif()
elseif (NOT EXISTS ${PICO_BTSTACK_PATH}/${BTSTACK_TEST_PATH})
message(WARNING "PICO_BTSTACK_PATH specified but content not present.")
endif()
if (NOT TARGET pico_btstack_base)
message("Skipping Pico Bluetooth examples as support is not available")
else()
add_subdirectory(btstack_examples)
add_subdirectory(secure_temp_sensor)
add_subdirectory(doorbell)
add_subdirectory(wifi_provisioner)
add_subdirectory(ble_pointer)
add_subdirectory(temp_sensor)
endif()
6 changes: 1 addition & 5 deletions pico_w/bt/README.md → bluetooth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ There's a standalone example in `pico-examples/pico_w/bt/standalone`.
## Debugging

To debug Bluetooth issues you can enable [btstack](https://github.com/bluekitchen/btstack) debug output which also enables packet logging.
Define `WANT_HCI_DUMP=1` in your CMakeLists.txt file. Uncomment this line to enable debug in the btstack examples.

target_compile_definitions(picow_bt_example_common INTERFACE
#WANT_HCI_DUMP=1 # This enables btstack debug
)
Define `WANT_HCI_DUMP=1` in your CMakeLists.txt file.

## Packet logging

Expand Down
33 changes: 33 additions & 0 deletions bluetooth/ble_pointer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Add mpu6050 libary
add_library(mpu6050_i2c_lib INTERFACE)
target_sources(mpu6050_i2c_lib INTERFACE
${CMAKE_CURRENT_LIST_DIR}/mpu6050_i2c_lib.c
)
target_include_directories(mpu6050_i2c_lib INTERFACE
${CMAKE_CURRENT_LIST_DIR}
)
target_link_libraries(mpu6050_i2c_lib INTERFACE
pico_stdlib
hardware_i2c
)

add_executable(ble_pointer
ble_pointer.c
)
target_link_libraries(ble_pointer
pico_stdlib
pico_btstack_ble
pico_btstack_cyw43
pico_cyw43_arch_none
mpu6050_i2c_lib
)
target_include_directories(ble_pointer PRIVATE
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_LIST_DIR}/..
)
target_compile_definitions(ble_pointer PRIVATE
#WANT_HCI_DUMP=1
)
pico_btstack_make_gatt_header(ble_pointer PRIVATE "${CMAKE_CURRENT_LIST_DIR}/ble_pointer.gatt")
pico_add_extra_outputs(ble_pointer)

7 changes: 7 additions & 0 deletions bluetooth/ble_pointer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### BLE pointer

This example is based on BTstack's 'hog_mouse_demo' and demonstrates a Bluetooth HID mouse. Cursor position is controlled by mpu6050 angle measurements, allowing you to point at the screen and move the mouse cursor.

To use this example connect a mpu6050 (which can be found at https://thepihut.com/products/6-dof-sensor-mpu6050) to the pico, with SDA connected to pin 4 and SCL connected to pin 5. Also, connect 2 buttons to pins 15 and 16 and ground for left and right click.

Once powered, you should be able to pair your computer with 'HID Mouse' and use the pointer.
Loading
Loading