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

C# PC app development with nRF52840-dongle

Our purpose is to integrate BLE 5 in our embedded application, and do it quickly.. We basically need to send/receive data with maximum throughput. 

Per thread below, we are planning to use the ble_app_uart on the embedded side.

For developing the PC app side, assume we are using the nRF52840-dongle you recommended in thread below, where can I find a code example in C# for doing this, implementing the NUS profile? I see there is JS/Node.js code of nrf-connect, but this is somewhat distant from our .NET environment.

Also i see in the Android app - nRF Toolbox - there is a UART app. So basically I'm looking for an equivalent C#/Windows code sample.

Does the pc-ble-driver in C++ cover the NUS service?

Spun off from:

Getting started with MBN52832 BLE Module

Parents
  • Hi,

    For developing the PC app side, assume we are using the nRF52840-dongle you recommended in thread below, where can I find a code example in C# for doing this, implementing the NUS profile? I see there is JS/Node.js code of nrf-connect, but this is somewhat distant from our .NET environment.

    Nordic does not provide any C# bindings for the pc-ble-driver, unfortunately. We only supply is the pc-ble-driver (C++) and JS and Python bindings.

    Does the pc-ble-driver in C++ cover the NUS service?

    No. The pc-ble-driver itself just provides the PC side of the SoftDevice API, and it does not incorporate any functionality that is not part of the SoftDevice. That means that you need to implement services yourself, as well as other higher-level functionality if needed (such as bond management, equivalently to what the peer manager library does in the SDK).

    Lastly, please note that if you need high throughput, it might be better to use a natively supported Bluetooth device on the PC side rather than the nRF52840 dongle, since the pc-ble-driver and the rest of the SoftDevice serialization system introduces a significant overhead that reduces the throughput. (The nRF52840 is a good development tool though, when used together with the nRF Connect for Desktop BLE app or nRF Sniffer.)

  • Thanks Einar. What do mean by "a natively supported Bluetooth device on the PC side"? Can you give an example of such a device? 

Reply Children
  • What I mean is a Bluetooth dongle (or integrated Bluetooth chip) that is supported by the native Bluetooth stack of the PC operating system (Windows, Linux, etc). I do not have any specific recommendations.

  • Hi Einar, I have the nRF52840 dongle. I have downloaded and built the "pc-ble-driver" library. I am running the "heart_rate_collector_sd_api_v6" project and it is failing on communication:

    Serial port used: COM11
    Baud rate used: 1000000
    Info: Successfully opened COM11. Baud rate: 1000000. Flow control: none. Parity: none.
    Status: 6, message: Target Reset performed
    Status: 7, message: Connection active
    Warning: Failed to receive response for command
    Status: 4, message: Error sending packet to target. Code: 0x8016
    sd_ble_cfg_set() failed when attempting to set BLE_GAP_CFG_ROLE_COUNT. Error code: 0x8003
    Error: serial port write operation on port COM11 failed. Error: The device does not recognize the command.[22]
    Status: 4, message: Error sending packet to target. Code: 0x802a
    Failed to enable BLE stack. Error code: 32773

    C:\Work\BLE\pc-ble-driver-master3\build\examples\Debug\heart_rate_collector_sd_api_v6.exe (process 26196) exited with code 32773.

    My setup includes the ISP1807 which includes the nRF52840 SoC as BLE peripheral..

    More info: Using nRFConnect all is working - I manage to connect to the BLE peripheral and get it's characteristics etc. The same is true using my Android phone with nRF Connect app.  

    Please help.

    Also, I noticed that during this failure, the dongle is reset, and USB is disconnected and reconnected (observed in Device Manager)

  • Hi,

    Have you remembered to flash the connectivity firmware to the dongle? And which exact connectivity firmware version do you use, and which exact pc-ble-driver version? They must match.

  • The pre-built hex files in the pc-ble-driver repo (here) are not complete or up to date. The easiest is to install pc-ble-driver-py via pip, and find it under <site-packages>\pc_ble_driver_py\hex\sd_api_v5. You can find the "site-packages" folder using 'python -m site'

Related