This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52833 peripheral_uart zephyr example only works with "prj_minimal.conf", and not "prj.conf"

Hi,

I have built and flashed the "peripheral_uart" example on the nrf52833dk_nrf52833 from nrfconnect sdk v1.5.0. When I build using the prj_minimal.conf file, everything works as expected; I can send data through the J-Link UART and it appears as a notification in the nrfconnect app on my iOS device (iPhone SE). I can also perform writes to the RX characteristic and then it is sent to the UART.

However, when I build with the prj.conf file, it doesn't appear to work. I can connect to the device, but when I try to subscribe to the notification TX characteristic, the iOS app says "writing is not permitted", and if I try to send UART data, I can see the message "peripheral_uart: Failed to send data over BLE connection" in the RTT logs.

[00:00:02.824,951] [0m<inf> fs_nvs: 6 Sectors of 4096 bytes[0m
[00:00:02.824,981] [0m<inf> fs_nvs: alloc wra: 0, fd8[0m
[00:00:02.824,981] [0m<inf> fs_nvs: data wra: 0, 19[0m
[00:00:02.825,195] [0m<inf> sdc_hci_driver: SoftDevice Controller build revision: 
                                         e5 c7 9c d9 91 00 1d 66  ea fb 6e 7b 98 2f 42 0d |.......f ..n{./B.
                                         f1 60 93 c8                                      |.`..             [0m
[00:00:02.829,284] [0m<inf> bt_hci_core: No ID address. App must call settings_load()[0m
[00:00:02.829,315] [0m<inf> peripheral_uart: Bluetooth initialized[0m
[00:00:07.445,739] [0m<inf> peripheral_uart: Connected 6E:9E:F9:93:3E:97 (random)[0m
[00:00:07.934,997] [1;33m<wrn> bt_l2cap: Ignoring data for unknown CID 0x003a[0m
[00:17:52.777,465] [1;33m<wrn> peripheral_uart: Failed to send data over BLE connection[0m
[00:17:53.791,168] [1;33m<wrn> peripheral_uart: Failed to send data over BLE connection[0m
[00:17:56.850,860] [1;33m<wrn> peripheral_uart: Failed to send data over BLE connection[0m

Looking at the code, I think this has something to do with bonding/pairing, but the iOS app doesn't seem to ask to pair when I connect to the device.

Could you please help me understand what I am doing wrong here?

Thanks.

Parents Reply Children
  • I'm not able to reproduce this, I did the following:

    • Opened NCS v1.5.0
    • Navigated to the folder nrf/samples/bluetooth/peripheral_uart
    • Connected the nRF52833 DK and ran the following commands:
      • BOARD=nrf52833dk_nrf52833 west build -d build33
      • BOARD=nrf52833dk_nrf52833 west flash -d build33
    • Opened Termite and selected the COM port connected to the DK
      • COM port can be found by running nrfjprog --com

    • Opened nRF Connect For Mobile v2.4.8 on an iPhone 11 Pro (Software version 14.0)
    • Started scanning (with no filters) and saw the device advertising with the name "Nordic_UART_Service", and connected to that device
    • Enabled notifications for the TX Characteristic
    • Wrote "Hello" in Termite and saw that 0x68-6C-6C-6F-0A was received in the App
    • Wrote "Hello" from the RX Characteristic (UTF8 and Request) and saw that it was received in Termite

    Could you try to repeat the same steps, and if you still encounter issues, could you point to what is different between our environments. A sniffer log may be useful as well

    Best regards,

    Simon

  • I was also unable to reproduce it today, so I did some more investigating. It seems the issue occurs when the following steps are taken:

    1. Build and flash with prj_minimal.conf (nrf52833dk_nrf52833)

    2. Connect via nrfconnect ios app, and test notifications using serial port (everything works)

    3. Build and flash with prj.conf (nrf52833dk_nrf52833)

    4. Connect via nrfconnect ios app and try to enable notifications (error occurs here)

    5. Hard reboot phone

    6. Connect via nrfconnect ios app, and test notifications using serial port (everything works)

    7. Disconnect nrf52833dk, connect nrf52840dk

    8. Build and flash with prj_minimal.conf (nrf52840dk_nrf52840)

    9. Connect via nrfconnect ios app, but device never connects (the only meaningful line in the log is "cbCentralManager.connect()"

    10. Build and flash with prj.conf (nrf52840dk_nrf52840)

    11. Connect via nrfconnect ios app, and test notifications using serial port (everything works)

    12. Build and flash with prj_minimal.conf (nrf52840dk_nrf52840)

    13. Connect via nrfconnect ios app, but app just says "connecting" and never connects (the only line in the log is "cbCentralManager.connect()"

    14. Hard reboot phone

    15. Connect via nrfconnect ios app, but app just says "connecting" and never connects (the only line in the log is "cbCentralManager.connect()"

    So it looks like I was wrong about it being related to the nrf52833 specifically; it is more to do with swapping between prj.conf and prj_minimal.conf. Perhaps there is some issue here with caching of connection parameters on iOS, or storing some settings in NVS on the device which are not compatible across the two configuration files (I don't think west erases this area when flashing)

    You can find the capture file at step 13 here: https://www.dropbox.com/s/qkjneuuu3qae4aw/ble_cap.pcapng?dl=0

    Also I forgot to mention that I am using iOS 14.4

  • jeremyherbert said:

    1. Build and flash with prj_minimal.conf (nrf52833dk_nrf52833)

    2. Connect via nrfconnect ios app, and test notifications using serial port (everything works)

    3. Build and flash with prj.conf (nrf52833dk_nrf52833)

    4. Connect via nrfconnect ios app and try to enable notifications (error occurs here)

    5. Hard reboot phone

    6. Connect via nrfconnect ios app, and test notifications using serial port (everything works)

    I guess this is the same issue as explained in this post: https://devzone.nordicsemi.com/f/nordic-q-a/32130/nrf52-sdk14-2-ble_app_uart-peripheral-example-not-working/125035#125035 When you change the .conf file, the way stuff in the GATT table is stored may have changed, leading to this error. However, I was able to reproduce "Writing is not permitted" and tested the suggested solution (turn off Bluetooth from settings for 10 seconds), and it worked.
    I'll look into step 7-15 now.

  • jeremyherbert said:

    7. Disconnect nrf52833dk, connect nrf52840dk

    8. Build and flash with prj_minimal.conf (nrf52840dk_nrf52840)

    9. Connect via nrfconnect ios app, but device never connects (the only meaningful line in the log is "cbCentralManager.connect()"

    10. Build and flash with prj.conf (nrf52840dk_nrf52840)

    11. Connect via nrfconnect ios app, and test notifications using serial port (everything works)

    12. Build and flash with prj_minimal.conf (nrf52840dk_nrf52840)

    13. Connect via nrfconnect ios app, but app just says "connecting" and never connects (the only line in the log is "cbCentralManager.connect()"

    14. Hard reboot phone

    15. Connect via nrfconnect ios app, but app just says "connecting" and never connects (the only line in the log is "cbCentralManager.connect()"

    It seems like the thread sizes are not configured correctly for all the boards. As mentioned here you may have to fine tune the stack sizes. I was able to make the sample work by setting CONFIG_MAIN_STACK_SIZE to 1024.

    Best regards,

    Simon

Related