Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

BLE CLI NUS COM Port

I am trying to use the RF5 BLE CLI (Nordic NUS driver). 

I need a plug and play COM port for Windows, iOS, and OS/X.  This has to work for a customer.

It pairs easily, but then what?  nRF5 Connect doesn't work (it just gives me a blank screen on connect), and it is pretty useless anyway since it reprograms everything.  The Python script doesn't do anything, and that is also useless for end customer use.  If there was an API or document that explained how to interface an app, that would work as well as a COM port.

-Erik

Parents
  • Hi Erik, 

    Could you give me some more explanation on your set-up ? What do you want to achieve and how are you connecting things together ? What is RF5 BLE CLI ? 

    Please provide exact SDK version, exact firmware project you are using. 

  • Hello Hung Bui,

    The nRF5_SDK_15.2.0;  Console over Bluetooth Application (internally known as the BLE CLI).   (Harware: Laird BL652: S132 on PCA10040)

    What I need is a real-time BLE monitoring of a Accelerometer and being able to read a history via BLE.  Using XML over the BLE CLI seems to be the only solution I can find after spending a week digging through the Nordic, Laird, and Bluetooth websites.

    I am asking for a way to generate a serial port for the BLE pairing, or some Win32 or Linux sample code to connect to the pairing.

    Thanks,

    -Erik

  • Oh, my mistake. We usually refer it as ble_app_cli example.  

    If you want to connect using the native Bluetooth on PC you may want to look for documentation and example from Microsoft. We actually don't have any example that use PC native bluetooth.

  • Okay, I wrote an app to talk to the device from Windows, but it won't send any data from BLE to the PC.  I can send from the PC to BLE without a problem.  The notify is never being called.  I have tried with several developers BLE apps to test it and it doesn't seem to be in my app.  Any ideas?  Do I need to send something to tell BLE to turn on the Notify?  I noticed that the BLE_GATT_HVX_NOTIFICATION is being checked for in the initial connect.  Is there some sort of documentation on all this?

    Thanks,

    -Erik

  • Found a partial answer, https://devzone.nordicsemi.com/f/nordic-q-a/561/what-does-cccd-mean

    I am trying to figure out how to write to the CCCD from Windows now.

  • Hi Erik, 

    You can find the code to enable CCCD in this file at ValueChangedSubscribeToggle_Click() function. 

  • Ug, C#.  I figured it out using the BluetoothGATTSetDescriptorValue call.  I will post my app here when I get some time after my project is delivered.  All in C++.

Reply
  • Ug, C#.  I figured it out using the BluetoothGATTSetDescriptorValue call.  I will post my app here when I get some time after my project is delivered.  All in C++.

Children
  • Just a note on what I found.  It turns out that there is a serious bug in the GATT functionality from Microsoft in WIN32.  But it all works in WIN64.

  • Another note, it seems that Linux based OSes (such as OS/X, iOS, Android) are very touchy about timing.  Make sure that the handler for errors does NOT call APP_ERROR_HANDLER() for the default.  This took months of reverse engineering the source to find.

  • Thanks Erik for the update. Could you give some more information about the bug you found ? As far as I understand APP_ERROR_HANDLER() will check if the result/return is NRF_SUCCESS (0) it will ignore that. 

  • I have a timed routine (created by app_timer_create) that runs a notify to send values from an accelerometer.  If I call APP_ERROR_HANDLER() in the call, BLE will not pair.  It crashes and resets, and while Windows BLE is smart enough to handle that, Linux BLE is not.  Commenting out the one line made everything work.

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    static void accelerometer_service_timeout_handler(void * p_context)
    {
    uint32_t err_code;
    err_code = ble_acs_measurement_send(&m_acs, &m_acc_meas);
    switch (err_code)
    {
    case NRF_SUCCESS:
    // Measurement was successfully sent.
    break;
    case NRF_ERROR_INVALID_STATE:
    // Ignore error.
    break;
    default:
    //APP_ERROR_HANDLER(err_code);
    break;
    }
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • I think it worth checking what the err_code actually was. It could be that the buffer was full. In that case, it's OK to ignore.