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.

  • Hello,

    sorry, you meant for this,

     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.

    i have used the ble_app_hids_keyboard example and used in-built Bluetooth in my PC to connect my peer device and send data from UART.

    so whatever the data sending from uart to the peer device it sends as a hid keyword and these going to print in Notepad on my PC.

    i don't know that it's possible with a dongle. if this is not possible sorry for the inconvenience.

    Thank You.

  • Have you looked at the example I pointed to: usbd_hid_composite , you press button 4 on the DK it will send letter g to the PC. So instead of button 4, you can make it type the letter automatically based on the data you receive. 

  • Yes, I tried but it is not working. if I pressed the button nothing happened. i connect the com port and i can see only the client: so if I send something gives me the command not found.

    Not only 4th button, i tried all its not working.

  • No you don't connect a COM port. When you connect it to USB it acts as a keyboard. You need to connect to the nRF USB port . Then it will be a new keyboard

  • Yes, it's working but how can i bring this to my dongle that's my question.?

    and I tried to modify the example code a little bit like this, but i couldn't send more than six characters.

    static void bsp_event_callback(bsp_event_t ev)
    {
        switch ((unsigned int)ev)
        {
            case CONCAT_2(BSP_EVENT_KEY_, BTN_MOUSE_X_POS):
                UNUSED_RETURN_VALUE(app_usbd_hid_mouse_x_move(&m_app_hid_mouse, CONFIG_MOUSE_MOVE_STEP));
                UNUSED_RETURN_VALUE(app_timer_start(m_mouse_move_timer, APP_TIMER_TICKS(CONFIG_MOUSE_MOVE_TIME_MS), NULL));
                break;
            case CONCAT_2(BSP_USER_EVENT_RELEASE_, BTN_MOUSE_X_POS):
                UNUSED_RETURN_VALUE(app_timer_stop(m_mouse_move_timer));
                break;
    
            case CONCAT_2(BSP_EVENT_KEY_, BTN_MOUSE_LEFT):
                UNUSED_RETURN_VALUE(app_usbd_hid_mouse_button_state(&m_app_hid_mouse, 0, true));
                break;
            case CONCAT_2(BSP_USER_EVENT_RELEASE_, BTN_MOUSE_LEFT):
                UNUSED_RETURN_VALUE(app_usbd_hid_mouse_button_state(&m_app_hid_mouse, 0, false));
                break;
    
            case CONCAT_2(BSP_EVENT_KEY_, BTN_KBD_SHIFT):
                UNUSED_RETURN_VALUE(app_usbd_hid_kbd_modifier_state_set(&m_app_hid_kbd, APP_USBD_HID_KBD_MODIFIER_LEFT_SHIFT, true));
                break;
            case CONCAT_2(BSP_USER_EVENT_RELEASE_, BTN_KBD_SHIFT):
                UNUSED_RETURN_VALUE(app_usbd_hid_kbd_modifier_state_set(&m_app_hid_kbd, APP_USBD_HID_KBD_MODIFIER_LEFT_SHIFT, false));
                break;
    
            case CONCAT_2(BSP_EVENT_KEY_, BTN_KBD_LETTER):
                //UNUSED_RETURN_VALUE(app_usbd_hid_kbd_key_control(&m_app_hid_kbd, CONFIG_KBD_LETTER, true));
                for(int i=10;i<25;i++)
                {
                UNUSED_RETURN_VALUE(app_usbd_hid_kbd_key_control(&m_app_hid_kbd,i, true));
                }
                break;
            case CONCAT_2(BSP_USER_EVENT_RELEASE_, BTN_KBD_LETTER):
                //UNUSED_RETURN_VALUE(app_usbd_hid_kbd_key_control(&m_app_hid_kbd, CONFIG_KBD_LETTER, false));
                for(int j=10;j<25;j++)
                {
                UNUSED_RETURN_VALUE(app_usbd_hid_kbd_key_control(&m_app_hid_kbd,j, false));
                }
                break;
    
            default:
                return; // no implementation needed
        }
    }

    Thank You

Reply
  • Yes, it's working but how can i bring this to my dongle that's my question.?

    and I tried to modify the example code a little bit like this, but i couldn't send more than six characters.

    static void bsp_event_callback(bsp_event_t ev)
    {
        switch ((unsigned int)ev)
        {
            case CONCAT_2(BSP_EVENT_KEY_, BTN_MOUSE_X_POS):
                UNUSED_RETURN_VALUE(app_usbd_hid_mouse_x_move(&m_app_hid_mouse, CONFIG_MOUSE_MOVE_STEP));
                UNUSED_RETURN_VALUE(app_timer_start(m_mouse_move_timer, APP_TIMER_TICKS(CONFIG_MOUSE_MOVE_TIME_MS), NULL));
                break;
            case CONCAT_2(BSP_USER_EVENT_RELEASE_, BTN_MOUSE_X_POS):
                UNUSED_RETURN_VALUE(app_timer_stop(m_mouse_move_timer));
                break;
    
            case CONCAT_2(BSP_EVENT_KEY_, BTN_MOUSE_LEFT):
                UNUSED_RETURN_VALUE(app_usbd_hid_mouse_button_state(&m_app_hid_mouse, 0, true));
                break;
            case CONCAT_2(BSP_USER_EVENT_RELEASE_, BTN_MOUSE_LEFT):
                UNUSED_RETURN_VALUE(app_usbd_hid_mouse_button_state(&m_app_hid_mouse, 0, false));
                break;
    
            case CONCAT_2(BSP_EVENT_KEY_, BTN_KBD_SHIFT):
                UNUSED_RETURN_VALUE(app_usbd_hid_kbd_modifier_state_set(&m_app_hid_kbd, APP_USBD_HID_KBD_MODIFIER_LEFT_SHIFT, true));
                break;
            case CONCAT_2(BSP_USER_EVENT_RELEASE_, BTN_KBD_SHIFT):
                UNUSED_RETURN_VALUE(app_usbd_hid_kbd_modifier_state_set(&m_app_hid_kbd, APP_USBD_HID_KBD_MODIFIER_LEFT_SHIFT, false));
                break;
    
            case CONCAT_2(BSP_EVENT_KEY_, BTN_KBD_LETTER):
                //UNUSED_RETURN_VALUE(app_usbd_hid_kbd_key_control(&m_app_hid_kbd, CONFIG_KBD_LETTER, true));
                for(int i=10;i<25;i++)
                {
                UNUSED_RETURN_VALUE(app_usbd_hid_kbd_key_control(&m_app_hid_kbd,i, true));
                }
                break;
            case CONCAT_2(BSP_USER_EVENT_RELEASE_, BTN_KBD_LETTER):
                //UNUSED_RETURN_VALUE(app_usbd_hid_kbd_key_control(&m_app_hid_kbd, CONFIG_KBD_LETTER, false));
                for(int j=10;j<25;j++)
                {
                UNUSED_RETURN_VALUE(app_usbd_hid_kbd_key_control(&m_app_hid_kbd,j, false));
                }
                break;
    
            default:
                return; // no implementation needed
        }
    }

    Thank You

Children
  • If you already have a solution that works with devices that support Bluetooth, I think the best solution is to use a Bluetooth dongle to allow device that doesn't have native Bluetooth support to have Bluetooth. 
    This is generic Bluetooth dongle (not nRF52840 dongle) and would use the computer native Bluetooth driver to communicate via BLE. 

    My understanding is that you have already a project that works with phone/tablet and PC that have Bluetooth ? 

    If it's the case, getting a generic Bluetooth dongle (just search for "Bluetooth 5.0 adapter" ) would be a better option that what you are trying to do now. The nRF52840 doesn't have the software/firmware to do the same as the generic Bluetooth adapter. 


  • If it's the case, getting a generic Bluetooth dongle (just search for "Bluetooth 5.0 adapter" ) would be a better option that what you are trying to do now. The nRF52840 doesn't have the software/firmware to do the same as the generic Bluetooth adapter. 

    I have already tried this also with a tp-link Bluetooth adapter and its works fine but I want to make it with nr dongle custom board. 

    I tried to add the usbd_hid_composite example to the merged one (ble_app_uart_c +usbd_ble_uart) so we can achieve this right.?

    And also can't able to add nrf_nvic.c and nrf_soc.c files.

    Thank You

  • I'm afraid that we won't be able to provide more help on this as it's more of application development that you need to do. Please try to check and debug why you can't send more than 6 characters. 

  • Hello,

    i can able to send the data continuously by doing like this,

    int main(void)
    {
        ret_code_t ret;
        static const app_usbd_config_t usbd_config = {
            .ev_state_proc = usbd_user_ev_handler,
        };
    
        //ret = NRF_LOG_INIT(NULL);
        //APP_ERROR_CHECK(ret);
    
        ret = nrf_drv_clock_init();
        APP_ERROR_CHECK(ret);
    
        //nrf_drv_clock_lfclk_request(NULL);
        //while(!nrf_drv_clock_lfclk_is_running())
        //{
        //    /* Just waiting */
        //}
    
        //ret = app_timer_init();
        //APP_ERROR_CHECK(ret);
    
        //ret = app_timer_create(&m_mouse_move_timer, APP_TIMER_MODE_REPEATED, mouse_move_timer_handler);
        //APP_ERROR_CHECK(ret);
    
        //init_bsp();
    
    //#if NRF_CLI_ENABLED
    //    init_cli();
    //#endif
    
        ret = app_usbd_init(&usbd_config);
        APP_ERROR_CHECK(ret);
    
    //    app_usbd_class_inst_t const * class_inst_mouse;
    //#if CONFIG_HAS_MOUSE
    //    class_inst_mouse = app_usbd_hid_mouse_class_inst_get(&m_app_hid_mouse);
    //#else
    //    class_inst_mouse = app_usbd_dummy_class_inst_get(&m_app_mouse_dummy);
    //#endif
    //    ret = app_usbd_class_append(class_inst_mouse);
    //    APP_ERROR_CHECK(ret);
    
        app_usbd_class_inst_t const * class_inst_kbd;
    #if CONFIG_HAS_KBD
        class_inst_kbd = app_usbd_hid_kbd_class_inst_get(&m_app_hid_kbd);
    #else
        class_inst_kbd = app_usbd_dummy_class_inst_get(&m_app_kbd_dummy);
    #endif
        ret = app_usbd_class_append(class_inst_kbd);
        APP_ERROR_CHECK(ret);
    
        NRF_LOG_INFO("USBD HID composite example started.");
        
        if (USBD_POWER_DETECTION)
        {
            ret = app_usbd_power_events_enable();
            APP_ERROR_CHECK(ret);
        }
        else
        {
            NRF_LOG_INFO("No USB power detection enabled\r\nStarting USB now");
    
            app_usbd_enable();
            app_usbd_start();
        }
    
        while (true)
        {
            counter+=1;
    
            nrf_delay_ms(50);
    
            app_usbd_hid_kbd_key_control(&m_app_hid_kbd, counter, 1);  // Press the key
    
            nrf_delay_ms(50);
    
            app_usbd_hid_kbd_key_control(&m_app_hid_kbd, counter, 0);  // Release the key
    
            nrf_delay_ms(50);
    
            if(counter==39)
            {
            counter=3;
            }
    
            while (app_usbd_event_queue_process())
            {
                /* Nothing to do */
            }
    //#if NRF_CLI_ENABLED
    //        nrf_cli_process(&m_cli_uart);
    //#endif
    
            //UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());
            /* Sleep CPU only if there was no interrupt since last loop processing */
            __WFE();
        }
    }
    

    afte this i started to add the code for ble_app_uart_c but  after adding this the first time I got 

    nrf_drv_clock_init() return ERROR 133 [NRF_ERROR_MODULE_ALREADY_INITIALIZED]

     then I commented out nrf_drv_clock_init() because maybe in a soft device its initialized and i checked that with 

    ret = nrf_drv_clock_init_check();
    NRF_LOG_INFO("ret:%d\r\n",ret);

     it returns 1 so it is initialized then after commenting out no errors but I couldn't send the data to Notepad. 

    what will be the problem.?

    Thank You

Related