I am trying to use the BluePy Scanner on a Raspberry Pi 3 B+ with a nRF52840-Dongle programmed as a Bluetooth: HCI-uart.
I am able to get the Bluepy Scanner code to work with the onboard BLE, but I am so far unable to get it to communicate with the Bluetooth HCI dongle that is attached to the UART0 (/dev/ttyS0). I have connected UART0_TXD (GPIO14), UART0_RXD (GPIO15), UART0_CTS (GPIO16), and UART0_RTS (GPIO17).
How can I attach and use a nRF52840-Dongle, programmed with the HCI_uart example, with a Raspberry Pi 3 B+?
Following are my nrf52840dongle_nrf52840.overlay and proj.conf files for the HCI_uart.
nrf52840dongle_nrf52840.overlay
/* SPDX-License-Identifier: Apache-2.0 */ &uart0 { compatible = "nordic,nrf-uart"; current-speed = <1000000>; status = "okay"; tx-pin = <45>; rx-pin = <42>; rts-pin = <47>; cts-pin = <29>; hw-flow-control; };
proj.conf
CONFIG_CONSOLE=n
CONFIG_STDOUT_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_BT=y
CONFIG_BT_HCI_RAW=y
CONFIG_BT_HCI_RAW_H4=y
CONFIG_BT_HCI_RAW_H4_ENABLE=y
CONFIG_GPIO=y
CONFIG_UART_0_NRF_FLOW_CONTROL=y
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=512
CONFIG_BT_MAX_CONN=16
CONFIG_BT_TINYCRYPT_ECC=n
CONFIG_BT_CTLR_DTM_HCI=y
CONFIG_BT_CTLR_ASSERT_HANDLER=y
I following DT overlays in on my Raspberry Pi, uart_ctsrts and krnbt_baudrate=1000000.
From the command line I try
btattach -B /dev/ttyS0 -P bcm -S 1000000 -R &
and I get the following message.
Attaching Primary controller to /dev/ttyS0
Switched line discipline from 0 to 15
Device index 1 attached
Failed to open HCI user channel
No controller attached
hciconfig status returns the following for the onboard BLE
hci0: Type: Primary Bus: UART
BD Address: B8:27:EB:EE:6C:BD ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING
RX bytes:13508 acl:0 sco:0 events:562 errors:0
TX bytes:2402 acl:0 sco:0 commands:124 errors:0
However, when I use the HCI_USB example I see the hci1 entry for the dongle. I realize that the USB will auto mount, unlike ttyS0, this is just to evidence that the dongle is functional.