BLE UART

We have an NRF52833 connected to the host board(runs LINUX) through UART can anyone help us with the code that goes in the NRF module that can make it work as a transceiver module(just like BLE adaptor) like sending data received from BLE to UART and data received from the host board to BLE

The final solution we are looking for is as follows: Using python on the host board we should be able to use NRF as a BLE adaptor and connect to BLE devices like sensors and receive data from them. All the connection and scanning and reading data code should be controlled or written in python and NRF should act like a transceiver module 

Can it be done? or are we looking in the wrong direction? 

Parents
  • Hi,

    There are several possible approaches here, which is best depends on your use case.

    1. You can use Bluetooth: HCI UART on the nRF device to run the Bluetooth controller there, and use HCI over UART. On the LInux side, use BlueZ as the Bluetooth host layer. This way the nRF will seem like a generic Bluetooth dongle from Linux and you can use it with standard Bluetooth APIs. This will only work with hosts that support HCI, so Linux, but not Windows or Mac, for instance.

    2. You can also use the Bluetooth shell form zephyr/tests/bluetooth/shell/ on the nRF, and interact with it from a script that sends shell commands and parse the output.

  • Option 1 looks fine as we are using Linux. 

    To implement it: 

    1) for Bluez we can use pybluez - https://github.com/pybluez/pybluez

    2) " HCI UART on the nRF device to run the Bluetooth controller "- Can you suggest an example code to start with? 

  • 1) Flashed HCI_UART sample using below steps 
    -west build -p auto -b nrf52833dk_nrf52833 samples\bluetooth\hci_uart
    -west flash
    2)Connected the board to linux machine and ran the below command 
    -sudo btattach -B /dev/ttyACM0 -S 1000000 -R
    btattach
    3) ran hciconfig 
    output 
    hciconfig
    can see two Bluetooth devices one is of laptop and one is the NRF connected 
    4) ran btmon
    output 
    btmon
    5) After that tried to run hciconfig scan , bluetoothctl scan , hci1 find -l but none of this was able to scan for ble using nrf as dongle 

    why is the device BD address 00:00:00:00 is it a valid address? 

  • Everything is working. thank you so much 
    the error was in my Linux board the UART device is /dev/THS1, not ACM0 replaced it in btattach command and everything is working. I also tested the HCI_USB example which also works.

  • I am glad to hear. Thanks for letting me know.

  • hey strangely we are rerunning the same setup with the same board but nothing is working. What might be the issue 

    Things tested 
    1) UART echo bot sample -> working 

    Current error 

    hciconfig returns

      
     

  • Hi,

    Can you elaborate on what you have done now? I see you write that you are using the same setup but there must be some form of change (deliberate or accidental), as the behavior is not the same.

    If you don't make any progress, perhaps you can show (copy-past from terminal or similar) all exact steps you make and the results of those, so that I can better understand?

Reply
  • Hi,

    Can you elaborate on what you have done now? I see you write that you are using the same setup but there must be some form of change (deliberate or accidental), as the behavior is not the same.

    If you don't make any progress, perhaps you can show (copy-past from terminal or similar) all exact steps you make and the results of those, so that I can better understand?

Children
    1. Flashed the HCI_UART sample onto the nrf52dk 
    2. Connected the RX of the dk to jetson nano TX and TX of the dk to jetson nano RX and GND to GND
    3. Run the command sudo btattach -B /dev/tty/THS1 -s 1000000 -R 
    4. Run hciconfig to see the new controller attached, we get a device buts its address is always 00:00:00:00:00
    5. hciconfig hci0 down gives output - device or resource busy 
    6. hciconfig hci0 reset gives same output device busy 
    7. Btmon output is attached in the screenshots 
    8. run Bluetoothctl 
    9. show or list cmd in bluetoothctl shows no devices. 

    btmon output

  • Hi,

    I am sorry for the delay. I have not been able to look at this yet but will do so during this week.

  • sure waiting for your reply meanwhile we are doing the same setup on the Raspberry pi 3b+ just to verify its not jetson dev kit issue 

  • Hi,

    Can you check that there is no problems with the UART communication between the devices?

    Hi,

    I attempted to do more or less the same as you, and this is what I got (just to have a base-line of a working setup). When I test this on a DK with the HCI UART sample from nrF Connect SDK 2.3.0 and a Linux computer, I get things to work with this approach:

    1. Start "sudo bluetoothctl" in a terminal

    2. In another terminal:

    3. I see this was successful in the bluetoothctl window:

    4. Check status in bluetoothctl with show:

    5. Try to can in bluetoothhctl with "scan on", and I get a lot of devices found.

    6. I also see logs like this in btmon (this shows going from down to up with "sudo hciconfig hci1 up"

    The above shows how this should work normally just to have a base line of what to expect in a working setup.

    In your screenshots I do not see any obvious issues before the last one with bluetoothctl that shows you don't have any controllers (and probably as a consequence of that there is not much in btmon). I don't see any indication of why, though.

    Does this work if you try with your board on a normal Linux desktop computer? Or a DK on the desktop or even a DK with the Jetson?

  • we tried with the hciattach command you have given 

    Our setup -> Nvidia Jetson nano dev kit -- NRF52dk 

    1) hciattach outputs -> Device setup complete

    2) btmon output

    3) hciconfig command shows UART device with address 00:00:00:00:00 but its DOWN
    4)sudo hciconfig hci0 up gives timeout error



    NOTE: as u asked us to test the UART first we tested it with a UART echo bot it worked anything I type on nrf UART can be in the jetson UART serial monitor 
    https://docs.zephyrproject.org/3.1.0/samples/drivers/uart/echo_bot/README.html



    Few questions 

    1) Instead of nrf connect sdk sample we are using the zephyr hci_uart sample is that okay?
    https://docs.zephyrproject.org/2.7.0/samples/bluetooth/hci_uart/README.html

    2) can you confirm after hciattach , hciconfig shows an hci device with MTU 0.0 because we read that MTU should not be 0.0?

    3) if you are loading HCI UART sample how are you using /dev/ttyACM2 (this is for USB devices) are you using FTDI converter ?

    4)we are using /dev/ttyTHS1 as per jetson UART1. can you give us a way to check what device to select for hciattach because dmesg in Linux shows nothing about a new device connected via GPIO pins I think we are attaching the wrong serial device.