help getting a BLE end to end application working

I am trying to get an end to end BLE application working. I have an nRF52832 board that is running peripheral_uart. It is advertising and sending a text stream to the connected device. If I run "nRF Toolbox" on my iPhone I can connect to the nRF52832 and see the BLE strings come across every N seconds as setup in my program. I have a nRF9160DK board that I want to be able to see the BLE text strings in the nRF52840 on the nRF9160DK board and send those strings to the nRF910 on the nrf9160DK board.

I am using samples/hci_uart in the nRF52840 and samples/central_uart in the nRF9160.. I have not looked at BLE in a very long time so I may have the wrong programs. Are these the correct projects to create an end to end BLE application?

first I want to connect to my advertising device and see the notifications with the text strings in the nRF52840. is hci_uart the correct program? I have made no changes in this program except to print a message on startup. I can build and flash into the RF52840 (SW10 set to nRF51) but I do not see anything printing on any of the 3 created COM ports and I do not see a connection on my advertising device. It is still advertising and not connected to anything.

second I want to get the strings from the nRF82840. I am running the central_uart in the nRF9160 (SW10 set to nRF91). I do see startup messages as show below but it keeps rebooting with a timeout as shown below

*** Booting nRF Connect SDK v2.5.0 ***
Starting central_uart
Passed register authorization callbacks.
Passed register authorization info callbacks.
ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:338
command opcode 0x0c03 timeout with err -11

*** Booting nRF Connect SDK v2.5.0 ***
Starting central_uart
Passed register authorization callbacks.
Passed register authorization info callbacks.
ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:338
command opcode 0x0c03 timeout with err -11

This is for an end to end production system so any help you can give to get BLE strings from my nRF52832 to the nRF9160 would be greatly appreciated.

  • Hi Timothy, 

    Hci_uart is not exactly made for central_uart. Hci_uart sample is a BLE controller only application. It should be communicated with a host device (in your case nRF9160). 
    The uart here mean the communication between the controller (nRF52840) and the host (nRF9160) is via UART (H4 HCI protocol). 

    When you test with peripheral_uart sample on nRF52833, both the host and the controller is on the same chip. The uart part here is used by the application (NUS service) and has nothing to do with hci_uart. 

    So, if you want do do NUS service with the nRF9160-nRF52840 you would need 2 Uarts on the nRF52840 one for communicating BLE HCI with nRF9160 and the other one is to receive/send commands via UART on application layer. 


    My suggestion is to get familiar with how you can use BLE on the nRF9160 DK before you move to UART (NUS) application. Please take a look at the lte ble gateway sample

    What you need on the host to make it work with hci_uart on the controller is described in the hci_uart documentation: 


    You will find this configuration in the lte_ble_gateway sample

  • Hung Bui

    I am still very confused and new to Nordic BLE. Can we start with just making a BLE connection to my advertising nRF52832 and seeing the strings sent in the nRf52840 on the nRF9160 DK board. I will take one step at a time. I do not want to send things to the nRF cloud as the sample you suggest does.

    what sample do I need to connect to my advertising device and receive the strings?

  • Hi again, 
    As I mentioned earlier you should do this: 
    My suggestion is to get familiar with how you can use BLE on the nRF9160 DK before you move to UART (NUS) application. Please take a look at the lte ble gateway sample

    The sample may need a Thingy52 to test with, but if you don't I think the first step is to see how the setup is done on the nRF9160 and the nRF52840 to make it scan. 

    You would need to get familiar with the BLE central code in ble.c file. 
    My suggestion is to first try to get familiar with BLE central and peripheral code for nRF52 first (host + controller on the same chip) before you move to the nRF9160+nRF52840 setup.
    Try testing central_uart and peripheral_uart on 2 nRF52s. Study the code there on the central and implement it to the lte_ble_gateway. 

  • Hung Bui

    the lte ble gateway application tells you to load the samples/bluetooth/hci_lpuart application into the nRF9160DK board with SW10 set to nRF52. I did that with the following build configuration:

    1. Board Target - nrf9160dk/nrf52840  Revision - 0.14.0

    2. Base Configuration files - prj.conf   boards/nrf9160dk_nrf52840.conf

    3. Base Devicetree Overlays - boards/nrf9160dk_nrf52840.overlay

    It builds and flashes fine but I see nothing on any of the 3 COM ports created by the nRF9160DK board on power up.

    I then built samples/cellular/lte_ble_gateway  as mentioned with SW10 set to nRF91 using the following:

    1. Board Target - nrf9160dk/nrf9160/ns  Revision - 0.14.0

    2. Base Configuration files - prj.conf   boards/nrf9160dk_nrf9160_ns.conf

    3. Base Devicetree Overlays - boards/nrf9160dk_nrf9160_ns.overlay

    it builds and flashes fine and does print out information but it fails quickly with a timeout. see below.

    so I am using the programs you suggested they are building but I still have the following questions.

    1. how do I get the hci_lpuart to print to the serial terminal?

    2. how do I get the gateway program to connect to LTE?

    3. how do I connect to mynRF52832 that is BLE advertising and receive the strings it is sending every 10 seconds?

    *** Booting nRF Connect SDK v3.0.2-89ba1294ac9b ***
    *** Using Zephyr OS v4.0.99-f791c49f492c ***
    [00:00:00.395,843] <inf> lte_ble_gw: LTE Sensor Gateway sample started
    [00:00:00.396,026] <inf> lte_ble_gw: Initializing Bluetooth..
    [00:00:00.643,463] <inf> lte_ble_gw: Establishing LTE link (this may take some time) ...
    ASSERTION FAIL [success] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:432
    command opcode 0x0c03 timeout
    [00:00:10.406,585] <err> os: r0/a1: 0x00000003 r1/a2: 0x00000000 r2/a3: 0x00000002
    [00:00:10.406,585] <err> os: r3/a4: 0x00000003 r12/ip: 0x20019a60 r14/lr: 0x00010177
    [00:00:10.406,616] <err> os: xpsr: 0x01000000
    [00:00:10.406,616] <err> os: Faulting instruction address (r15/pc): 0x00010184
    [00:00:10.406,646] <err> os: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
    [00:00:10.406,707] <err> os: Current thread: 0x2000f2b8 (unknown)
    [00:00:10.460,998] <err> os: Halting system

  • Hung Bui

    I did use the sample you recommended. (hci_lpuart in the nRF52840 and lte_ble_gateway in the nRF9160).

    hci_lpuart output on COM port LOG_XXX points to NULL but printf works.

    *** Booting nRF Connect SDK v3.0.2-89ba1294ac9b ***
    *** Using Zephyr OS v4.0.99-f791c49f492c ***
    Start hci_lpuart

    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.
    putting RX packet in queue.

    lte_ble_gateway output on COM port

    *** Booting nRF Connect SDK v3.0.2-89ba1294ac9b ***
    *** Using Zephyr OS v4.0.99-f791c49f492c ***
    [00:00:00.371,398] <inf> lte_ble_gw: LTE Sensor Gateway sample started
    [00:00:00.371,582] <inf> lte_ble_gw: Initializing Bluetooth..
    [00:00:00.620,025] <inf> lte_ble_gw: Establishing LTE link (this may take some time) ...
    [00:00:01.108,428] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    [00:00:01.108,459] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
    [00:00:01.108,489] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 137.20634 Build 2617349514
    [00:00:01.117,004] <inf> bt_hci_core: Identity: EE:F0:7B:84:FC:21 (random)
    [00:00:01.117,065] <inf> bt_hci_core: HCI: version 6.0 (0x0e) revision 0x10f3, manufacturer 0x0059
    [00:00:01.117,095] <inf> bt_hci_core: LMP: version 6.0 (0x0e) subver 0x10f3
    [00:00:01.117,095] <inf> lte_ble_gw: Bluetooth ready
    [00:00:01.123,291] <inf> lte_ble_gw: Scanning...
    [00:00:01.127,105] <err> bt_gatt: Unable to import the key for AES CMAC -134
    +CEREG: 2,"9E03","026B8102",7
    +CSCON: 1
    +CEREG: 0
    +CSCON: 0
    [00:10:00.654,968] <inf> lte_lc: Network connection attempt timed out
    ASSERTION FAIL [err == 0] @ CMAKE_SOURCE_DIR/src/main.c:492
    LTE link could not be established.
    [00:10:02.089,935] <err> os: r0/a1: 0x00000004 r1/a2: 0x000001ec r2/a3: 0x00000002
    [00:10:02.089,935] <err> os: r3/a4: 0x00000004 r12/ip: 0x20018aac r14/lr: 0x00009837
    [00:10:02.089,965] <err> os: xpsr: 0x01000000
    [00:10:02.089,965] <err> os: Faulting instruction address (r15/pc): 0x0002dfde
    [00:10:02.089,996] <err> os: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
    [00:10:02.090,057] <err> os: Current thread: 0x2000f230 (unknown)
    [00:10:02.142,913] <err> os: Halting system

    I think the next step is to go to nRF Cloud (I have an account) and set something up. I am very confused how to set things up. How do I connect to my BLE advertising device that  nRF Toolbox can connect to and see the strings it is trying to send? I will continue to go through the documentation but any help to get me started would be appreciated.

Related