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.

Parents
  • 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

Reply
  • 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

Children
  • 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.

  • Hi Timothy,

    Have you got any NRF91 sample working? Have you got the connection to the cloud ? Did you provide a compatible SIM card to the board. Please complete our course here if you haven't : https://academy.nordicsemi.com/courses/cellular-iot-fundamentals/

  • The nrf91 sample lte_ble_gateway is working. I have a nRF Cloud account. I have created a LTE device that has the Device ID and PIN from the nRF9160DK board. I do run the program on the nRF9160 and I see 2 messages printed out in red as shown below. I see LED 4 lit that says I a connection to the nRF Cloud. The next step says I should see the device connected in nRF Cloud. I do NOT see that. so I am much closer but still not connecting to my device in the cloud and not connecting to my nRF52832 that is advertising.

    1. what do the 2 messages in Red mean?

    2. how do I make the connection to my device? What am I missing?

    3. how do I connect to my advertising nRF52832 board running hci_lpuart?

    4. how do I receive the strings being sent when there is a connection?

    thank you for your help this is for a production system that needsto send strings from nRF52832 over BLE to the cloud.

    *** Booting nRF Connect SDK v3.0.2-89ba1294ac9b ***
    *** Using Zephyr OS v4.0.99-f791c49f492c ***
    LTE Sensor Gateway sample started Version: 0.1 Date: 10/30/25
    [00:00:00.377,777] <inf> lte_ble_gw: Initializing Bluetooth..
    [00:00:00.626,281] <inf> lte_ble_gw: Establishing LTE link (this may take some time) ...
    [00:00:01.144,561] <inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)
    [00:00:01.144,592] <inf> bt_hci_core: HW Variant: nRF52x (0x0002)
    [00:00:01.144,622] <inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 137.20634 Build 2617349514
    [00:00:01.162,475] <inf> bt_hci_core: Identity: EE:F0:7B:84:FC:21 (random)
    [00:00:01.162,506] <inf> bt_hci_core: HCI: version 6.0 (0x0e) revision 0x10f3, manufacturer 0x0059
    [00:00:01.162,536] <inf> bt_hci_core: LMP: version 6.0 (0x0e) subver 0x10f3
    [00:00:01.162,567] <inf> lte_ble_gw: Bluetooth ready
    [00:00:01.172,576] <err> bt_gatt: Unable to import the key for AES CMAC -134
    [00:00:01.175,781] <inf> lte_ble_gw: Scanning...
    +CEREG: 2,"9E03","026B8102",7
    +CSCON: 1
    +CEREG: 5,"9E03","026B8102",7,,,"11100000","11100000"
    [00:00:08.115,600] <inf> nrf_cloud_info: Device ID: nrf-351901936291081
    [00:00:08.115,997] <inf> nrf_cloud_info: IMEI: 351901936291081
    [00:00:08.116,546] <inf> nrf_cloud_info: Modem FW: mfw_nrf9160_1.3.4
    [00:00:08.116,577] <inf> nrf_cloud_info: Protocol: MQTT
    [00:00:08.116,607] <inf> nrf_cloud_info: Download protocol: HTTPS
    [00:00:08.116,638] <inf> nrf_cloud_info: Sec tag: 16842753
    [00:00:08.116,668] <inf> nrf_cloud_info: Host name: mqtt.nrfcloud.com
    [00:00:15.299,865] <err> nrf_cloud_transport: Failed to save session state: -2
    [00:00:15.300,659] <inf> lte_ble_gw: Initializing GNSS
    [00:00:15.306,152] <inf> lte_ble_gw: GNSS initialized
    [00:00:15.309,204] <inf> lte_ble_gw: Requesting A-GNSS Data
    [00:00:15.309,692] <inf> lte_ble_gw: GNSS started with interval 30 seconds, and timeout 15 seconds
    [00:00:15.309,753] <inf> nrf_cloud_info: Team ID: 45c9165d-a392-4543-96c3-d17ba0aaf166
    +CSCON: 0

  • Hi Timothy, 
    Please verify that the nRF9160 works first. 
    Have you looked at the academy course I provided? 

    Regarding the the first red line please try to find if in your nRF52 project this is set: 

    CONFIG_TFM_PROFILE_TYPE_MINIMAL=y

    Please change it to n

    And also set this: CONFIG_TFM_PROFILE_TYPE_NOT_SET=y

    For the second one, please take a look here: 
    RE: nrf_cloud not connecting in thingy91X

  • Hung Bui

    the nrf91060 is working. It runs and sets LED 4 to say that it  is connected to nRF Cloud.

    in nrf Cloud do I create a LTE device using the nRF9160 IMEI and PIN or do I use the nrf52832 IMEI and PIN. If I need to use the nRF52832 hardware information how do I get that. It is a custom board.

Related