Is there any possible way to sedn the data from peripheral device(nrf52832 dev kit) to nrf52840 dongle which is connected to Bluetooth-less desktop

Hello,

In my project, i want to send the data from the ble device nrf52832 dev kit to the nrf52840 dongle which is connected to a Bluetooth-less desktop. Some desktop doesn't have inbuilt Bluetooth and for that, i used an nrf52840 dongle with the help of nrf connect desktop app i flashed the dongle(here i don't have any example or source file, firmware flashed directly by the app), and when I connect it to desktop & scan the peripheral devices with Bluetooth low energy option in nrf connect app. even I can connect the peripheral devices.

Now the issue is how can I send the data from the nrf52832 dev kit to nrf dongle because there is no source file I couldn't add code to receive the data. i tried ble_app_blinky and ble_app_blinky_c examples to send the button state data from peripheral to central so can i use the same for nrf52832 and dongle.??

if so, using the dongle can we connect it to PC and send the data to pc.??

please let me know how can i implement this.

Thank You. 

Parents
  • Hi Sagarnayakm, 

    Are you using nRF 5 SDK or you are using nRF Connect SDK ? In your other case you were mentioning about Zephyr and nRF Connect SDK. 

    My understanding is that now you have a set-up that you can transmit data from a nRF52 peripheral to the nRF52840 dongle that connect to a PC running nRF Connect for Desktop. 

    Now you want to develop your own application on PC that can do something similar, to receive data from the nRF52 peripheral. 

    My suggestion is to try the ble_app_uart and ble_app_uart_c. You flash the ble_app_uart on one DK and ble_app_uart_c on another DK. Note that you need to use development kit for development. Don't use the dongle for development. 
    After you followed the documentation and can forward UART data from one PC to another PC (or from a phone to the PC), you can write your own application to read the UART data instead of using a UART terminal. 

    After that you can star the next step to either make your own PCB to make a dongle or use nordic dongle and use USB instead of UART. But that should be the next step. 

    This is the most simple way of getting data to PC. If you want to have full control from PC, the same as you have in nRF Connect for Desktop, you would need to use pc_ble_drive. Have a look here: https://github.com/NordicSemiconductor/pc-ble-driver And the python binding here: https://github.com/NordicSemiconductor/pc-ble-driver-py

    We have some examples in the repos that you can have a look. 

  • Hello,

    Thanks for the reply, 

    After you followed the documentation and can forward UART data from one PC to another PC (or from a phone to the PC), you can write your own application to read the UART data instead of using a UART terminal. 

    Regarding this point, I have experienced the ble_app_uart example and i can able to send the data from hw uart and receive it in the dev kit  and push the same data to the mobile app. This is what the example code would do. but i don't have any idea about ble_app_uart_c.

    After that you can star the next step to either make your own PCB to make a dongle or use nordic dongle and use USB instead of UART. But that should be the next step. 

    Already I have my custom dongle pcb board and i tried the usbd_cdc_acm example to send the data from the terminal to the dongle and it's working fine.

    still a lot of effort I don't know which example is suitable for a dongle board since the firmware is flashed via nrf connect app.

    Regarding pc_ble_driver I have seen this before only but it's really confusing and I don't know to kick-start this. please help me step by step then it will very easy to get into that. 

    Please help me.

    Thank You.

  • Hi Sagarnayakm,

    Sorry for late response, it was a long holiday last week in Norway. 
    Have you got any progress in debugging ? 


    As I mentioned, don't test on the dongle. 
    What you need to do is to make the DK - DK works first before you move to the dongle. 
    With the DK you can step into the code. 

    My suggestion is that you start with ble_app_uart_c . Try to port the USB library in and the goal is to print out something on the USB CDC virtual UART port by using app_usbd_cdc_acm_write(). Don't do anything with BLE. 

    If you can print out some dummy log on the USB COM port in the ble_app_uart_c  then you can move to the next step to integrate that with the NUS profile. 

    I can't test your code here because I need the whole project, not just main.c 


  • Hello,

    Yes, I have tested with the dev kit as well as the dongle and I can able to send the data from the peripheral to the central but here once I send the data from the peri-central data is received perfectly, and after this, the next data is sent and if that data less size of first one then it replaces the older data.

    for example first data "hello" then next data "hi" so in the serial monitor "it receives like this "hillo". so it's not printing in the next line.

    1. here I have one more doubt, I want to add NUS service to the ble_app_hids_keyboard example and I have added it successfully without any errors but the device is not advertising after this then I started debugging it throws me err_code 4 for nus_init(). so what will be the issue?

    2. so can we add hid example to the merged one(ble_app_uart_c & ble_usbd ).?? because however, i want to print the data in notepads of connected devices like mobile/laptops.

    Thank You.

  • Hi Sagarnayakm, 

    Could you please confirm that now you can output to USB instead of UART in the ble_app_uart_c code ?
    Regarding your question number 1, could you show how you print the data out using app_usbd_cdc_acm_write() ? 
    If you have a look at usbd_ble_uart example code you can find this: 

            uint16_t length = p_evt->params.rx_data.length;
            if (length + sizeof(ENDLINE_STRING) < BLE_NUS_MAX_DATA_LEN)
            {
                memcpy(m_nus_data_array + length, ENDLINE_STRING, sizeof(ENDLINE_STRING));
                length += sizeof(ENDLINE_STRING);
            }
    
            // Send data through CDC ACM
            ret_code_t ret = app_usbd_cdc_acm_write(&m_app_cdc_acm,
                                                    m_nus_data_array,
                                                    length);

    This is how we add the line break and new line in (endline). 

    Regarding  your 2nd question, I'm not so sure why you want to have HIDs here. Are you planning to have the HIDs keyboard to "type" the text into the mobile/laptop ? 

  • Regarding  your 2nd question, I'm not so sure why you want to have HIDs here. Are you planning to have the HIDs keyboard to "type" the text into the mobile/laptop ? 

    Regarding this, yes my peripheral device contains(ble_app_uart + ble_app_hids_keyboard) and I want to connect this device to my dongle. 

    As I did with dev kits nrf52832(ble_app_uart) and nrf52840 with (ble_app_uart_c). once nrf52840 is powered up peripheral device gets connected and I can able to send the data from peri to central.

    now I just change the peripheral device with my custom board having (ble_app_uart + ble_app_hids_keyboard)  name "Nordic_keyborad" --> "Nordic_UART" to connect with y dongle but its not connecting, advertising continuously.

    Regarding your question number 1, could you show how you print the data out using app_usbd_cdc_acm_write() ? 

    this  is how i am sending it USB dongle.

      

  • Hi, 
    Please use the code I showed in the last reply to add the ENDLINE string to make it go to new line. 

Reply Children
  • Awesome..!!,

    it's printing to the next line but I have one more doubt can we add the hid example to this code to print it in Notepad on PC as well??

  • Hi Sagarnayakm, 

    I'm not so sure about what you plan to do. My understanding is that you want to create a "virtual" keyboard, that can type what arrives at the USB port ? 

    But how do you connect that virtual keyboard to PC ? Is it via USB ? 
    I would suggest to take a look at the \examples\peripheral\usbd_hid_composite . Pressing button 4 when running the demo will send letter 'g' 

    Note that to create a HID keyboard it's a bit complex and you will need to do some study to be able to integrate it to your application. 

    If you are planning to connect the HIDs device via BLE to a tablet/phone (not USB) then it's a different story . And you will need to study the \examples\ble_peripheral\ble_app_hids_keyboard example. 

  • If you are planning to connect the HIDs device via BLE to a tablet/phone (not USB) then it's a different story

    I have implemented this thing already like when I connect my peripheral device to a tablet/phone/laptop whatever data I am sending is printed in Notepad on the tablet/phone/laptop.

    but now this thing should happen via dongle -->USB--> to a desktop/PC(Notepad). So first tell me is this possible or not.?

    because already I have my custom board and I don't want to make it useless. 

    please let me know as soon as possible and best way to do that.

    Thank You.

  • Hi Sagarnayakm, 

    You need to clarify to me are you planning to make the dongle works as a "virtual" keyboard that can type the data you receive from the peer device ? 


    If you are, it's possible. As I mentioned if you look at usbd_hid_composite example, pressing button 4 on the Devkit will type letter 'g' on PC . You would need to base from that and develop your application. 

  • Hello,

    I didn't get what a virtual keyboard means,

    If you are planning to connect the HIDs device via BLE to a tablet/phone (not USB) then it's a different story

     but the thing is I have implemented this on my peer device and it writes the data to Notepad directly when I connect to PC.

     So my point is if the PC doesn't have in-built Bluetooth, providing Bluetooth capability to that using a dongle. so instead of sending the data to the serial port, I want to write it the same as above.

    so now I hope you understand it properly and tell me how can i proceed with this.

    and one more thing I used Putty software to store the logging data to a .txt file also and it's working but I don't want to connect any com port here. Whenever I send the data from a peer device it should directly to Notepad. so is a need to build any driver on the PC side? if so, how can I proceed with that.? any support.?

Related