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

Can I combine the ble_app_nus_c and usbd_ble_uart together?

Hello, I am working on a multi peripherals to one central project based on the NUS service of NORDIC chip. Now I use nRF52840 Dongle as the central board. I have debug the usbd_ble_uart project in the example folder to send and receive data via NUS service between DONGLE board and cell phone. 

Now I want to combine the usbd_ble_uart and ble_app_nus_c together. The ble_app_nus_c work as the firmware of the central board and receive the data from peripheral board. Then transmit the data to the laptop via the usb protocol. I copied all the files and code needed from usbd_ble_uart to the ble_app_nus_c project. When link the files in the compiling, many errors occurred. 

In usbd_ble_uart project, the BLE NUS service instance is defined as BLE_NUS_DEF(m_nus, NRF_SDH_BLE_TOTAL_LINK_COUNT);  In ble_app_nus_c project, the BLE NUS client instances is defined as BLE_NUS_C_ARRAY_DEF(m_ble_nus_c, NRF_SDH_BLE_CENTRAL_LINK_COUNT); Can these two instances be defined in one project? I added both ble_nus.c and ble_nus_c.c to the project. But seem that all the codes in ble_nus.c is not actived in compiling even I have enable the BLE_NUS service in sdk_config.h. 

How can I enable USBD communication in the BLE_APP_NUS_C project? Any help will be appreciated. Thanks a lot.

  • Hi Ming, 
    Could you show the error when you try to compile ?

    I assume you are trying to build a central ? Why are you hving ble_nus.c instead of ble_nus_c.c ? It should be the client on the central, not the server. 
    So BLE_NUS_C_ENABLED should be = 1 in sdk_config.h 

    If you don't plan to have the server on the central, please remove the ble_nus.c 

  • Hi Hung, thanks for you information. In linking, errors are "undefined reference to `app_usbd_cdc_acm_rx_size'" and "undefined reference to `app_usbd_class_append'". All the codes are related to USBD_CDC function and I have included all the c and h files in the project. For ble_nus_c, it is very tricky. Some explanation mention that the 'c' means client but actually it is located in ble_central folder. I have other successful example for multi peripherals to one central project which are made by several peripheral with "ble_nus" firmware and one central with "ble_nus_c" firmware. 

    I have disable the ble_nus.c from the project and the errors were shown as above. The firmware really trouble me a lot.

  • Please let us know on which example you based your application on . 
    Please made sure you have defined APP_USBD_ENABLED = 1 in sdk_config.h 

    If you based your application on usbd_ble_uart  example you shouldn't have any problem with the USB library. 

    What I would suggest you to do is: 

    - Start with usbd_ble_uart  

    - Study the ble_app_uart_c

    - Remove ble_nus.c and ble_nus.h they are the server 

    - Add ble_nus_c.c and ble_nus_c.h , make sure to enable them in sdk_config.h 

    - Initialize the central, following what inside the ble_app_uart_c example. 

    I assume you are making a central device that can collect data from a peripheral running ble_nus server. 

  • Yes, now the firmware with both BLE and USBD works. Thanks.

Related