is that possible to send the peripheral device data to bluetooth less desktop over ble

Hello,

In my project, I want to send the data from the ble device nrf52832 dev kit to a connected in-built Bluetooth desktop/PC. Some desktop doesn't have inbuilt Bluetooth and for that, so I used a third-party dongle(TP link dongle) that provides Bluetooth capability to Bluetooth-less desktop. I scanned the peripheral devices with a third-party dongle same as the in-built desktop/PC Bluetooth. next, successfully send the data from the peripheral device to the desktop/PC. but i want to develop a custom dongle to send/receive the data from peripherals devices as well as it provides Bluetooth capability to Bluetooth less desktop/PC.

I have tried the nrf52840 dongle and most of them say that it's not recommended for development and even it didn't provide any Bluetooth capability to the desktop as in-built. using nrf connect desktop app we can scan and connect the device but i need the same as the in-built Bluetooth.

So please let me know how can i achieve this.

Thank You. 

Parents
  • Hello,

    If you want a Bluetooth dongle for a bluetooth-less desktop/PC, it needs to contain a certain firmware. This firmware is Bluetooth HCI (Host Controller Interface) over USB. If the dongle doesn't contain this, then the computer will not be able to use it as a Bluetooth dongle. 

    However, if you want to add more functionality into this dongle, thus changing the FW to no longer be pure HCI, the computer will no longer see it as a Bluetooth dongle, so I don't think what you describe is possible.

    It is however possible to use a Bluetooth HCI dongle for what you want to, but it requires some sort of application running on your PC. But if I understand you correctly, you have already accomplished this?

    Best regards,

    Edvin

  • Hello,

    so I don't think what you describe is possible.

    So it's not possible to scan the peripheral devices and send the data from the peripheral to a central device that is connected to a Bluetooth-less desktop.

    But how TP link Bluetooth adapter can achieve this.? in their website they give some drivers for pc. will it work for all,?

    I didn't try hci example so can I try that once to get an idea? or its not suitable for my application.

    Thank You

  • Hello,

    Thanks for the reply,

    let me try and update you,

  • Hello,

    I tried to add usbd_hid_composite example to ble_app_uart_c example and i got this error,

    <info> app: drv_clock_init:133
    
    <error> app: ERROR 133 [NRF_ERROR_MODULE_ALREADY_INITIALIZED] at C:\NFC_NRF\nRF5_SDK_17.1.0_ddde560\examples\ble_central\ble_app_uart_c - Copy\main.c:862
    PC at: 0x0002E939

    so cross-checked in main.c I didn't find any reinitialization. but in nrf_drv_clock.c of usbd_hid_composite this code is  not visible,

    static void clock_irq_handler(nrfx_clock_evt_type_t evt)
    {
        if (evt == NRFX_CLOCK_EVT_HFCLK_STARTED)
        {
            m_clock_cb.hfclk_on = true;
            clock_clk_started_notify(NRF_DRV_CLOCK_EVT_HFCLK_STARTED);
        }
        if (evt == NRFX_CLOCK_EVT_LFCLK_STARTED)
        {
            m_clock_cb.lfclk_on = true;
            clock_clk_started_notify(NRF_DRV_CLOCK_EVT_LFCLK_STARTED);
        }
    #if CALIBRATION_SUPPORT
        if (evt == NRFX_CLOCK_EVT_CTTO)
        {
            nrf_drv_clock_hfclk_request(&m_clock_cb.cal_hfclk_started_handler_item);
        }
    
        if (evt == NRFX_CLOCK_EVT_CAL_DONE)
        {
            nrf_drv_clock_hfclk_release();
            bool aborted = (m_clock_cb.cal_state == CAL_STATE_ABORT);
            m_clock_cb.cal_state = CAL_STATE_IDLE;
            if (m_clock_cb.cal_done_handler)
            {
                m_clock_cb.cal_done_handler(aborted ?
                    NRF_DRV_CLOCK_EVT_CAL_ABORTED : NRF_DRV_CLOCK_EVT_CAL_DONE);
            }
        }
    #endif // CALIBRATION_SUPPORT
    }
    
    #ifdef SOFTDEVICE_PRESENT
    /**
     * @brief SoftDevice SoC event handler.
     *
     * @param[in] evt_id    SoC event.
     * @param[in] p_context Context.
     */
    static void soc_evt_handler(uint32_t evt_id, void * p_context)
    {
        if (evt_id == NRF_EVT_HFCLKSTARTED)
        {
            m_clock_cb.hfclk_on = true;
            clock_clk_started_notify(NRF_DRV_CLOCK_EVT_HFCLK_STARTED);
        }
    }
    NRF_SDH_SOC_OBSERVER(m_soc_evt_observer, CLOCK_CONFIG_SOC_OBSERVER_PRIO, soc_evt_handler, NULL);
    
    /**
     * @brief SoftDevice enable/disable state handler.
     *
     * @param[in] state     State.
     * @param[in] p_context Context.
     */
    static void sd_state_evt_handler(nrf_sdh_state_evt_t state, void * p_context)
    {
        switch (state)
        {
            case NRF_SDH_EVT_STATE_ENABLE_PREPARE:
                NVIC_DisableIRQ(POWER_CLOCK_IRQn);
                break;
    
            case NRF_SDH_EVT_STATE_ENABLED:
                CRITICAL_REGION_ENTER();
                /* Make sure that nrf_drv_clock module is initialized */
                if (!m_clock_cb.module_initialized)
                {
                    (void)nrf_drv_clock_init();
                }
                /* SD is one of the LFCLK requesters, but it will enable it by itself. */
                ++(m_clock_cb.lfclk_requests);
                m_clock_cb.lfclk_on = true;
                CRITICAL_REGION_EXIT();
                break;
    
            case NRF_SDH_EVT_STATE_DISABLED:
                /* Reinit interrupts */
                ASSERT(m_clock_cb.module_initialized);
                nrfx_clock_enable();
    
                /* SD leaves LFCLK enabled - disable it if it is no longer required. */
                nrf_drv_clock_lfclk_release();
                break;
    
            default:
                break;
        }
    }
    
    NRF_SDH_STATE_OBSERVER(m_sd_state_observer, CLOCK_CONFIG_STATE_OBSERVER_PRIO) =
    {
        .handler   = sd_state_evt_handler,
        .p_context = NULL,
    };
    

    but its visible in ble_app_uart_c example so did I make any mistake here. please let me know.

    Thank You.

  • What function returned the value that is checked in main.c line 862?

    BR,
    Edvin

  • Hello,

    nrf_drv_clock_init(); return this error.

    Thank You.

Reply Children
  • Hello hello..!!.

    That suggests that the clock is already initialized, wouldn't you agree? Try setting a breakpoint inside nrf_drv_clock_init() and see if it is reached before you reach line 862 in main.c. Is it reached? If so, you can just comment out nrf_drv_clock_init() on line 862 in main.c.

    Best regards,

    Edvin

  • Hello,

    Thanks for the reply,

    i added break point before nrf_drv_clock_init() and inside that also with some debugging prints,

    ret_code_t nrf_drv_clock_init(void)
    {
        ret_code_t err_code = NRF_SUCCESS;
        if (m_clock_cb.module_initialized)
        {
          
            printf("func\r\n");
            err_code = NRF_ERROR_MODULE_ALREADY_INITIALIZED;
            nrf_delay_ms(100);
        }
        else
        {
            m_clock_cb.p_hf_head      = NULL;
            m_clock_cb.hfclk_requests = 0;
            m_clock_cb.p_lf_head      = NULL;
            m_clock_cb.lfclk_requests = 0;
            err_code = nrfx_clock_init(clock_irq_handler);
    #ifdef SOFTDEVICE_PRESENT
            if (!nrf_sdh_is_enabled())
    #endif
            {
                nrfx_clock_enable();
            }
    
    #if CALIBRATION_SUPPORT
            m_clock_cb.cal_state = CAL_STATE_IDLE;
    #endif
    
            m_clock_cb.module_initialized = true;
        }
    
        if (nrf_wdt_started())
        {
            m_clock_cb.lfclk_on = true;
        }
    
        NRF_LOG_INFO("Function: %s, error code: %s.",
                     (uint32_t)__func__,
                     (uint32_t)NRF_LOG_ERROR_STRING_GET(err_code));
        printf("err_sagar:%d\r\n",err_code);
        nrf_delay_ms(100);
        return err_code;
    }

    so in main.c for ble_stack_init() it will enter to nrf_drv_clock_init()  and return err_code:0 then for nrf_drv_clock_init() in main.c again it will enter but return err_code:133.

    so this screenshot of serial port data,

    so I think commented out is the correct way, if not Please let me know, because if I am trying to send the counter val data continuously to print in Notepad on PC it's not working. 

    the same thing is working on usbd_hid_example,

     for (;;)
        {
            val+=1;       
            app_usbd_hid_kbd_key_control(&m_app_hid_kbd, val, 0);  // Release the key
    
            nrf_delay_ms(100);
    
            app_usbd_hid_kbd_key_control(&m_app_hid_kbd, val, 1);  // Press the key
    
            nrf_delay_ms(100);
                
            while (app_usbd_event_queue_process())
            {
                /* Nothing to do */
            }
            idle_state_handle();
    
        }
    
    }
    

    Thank You.

  • If it is not working, check the return values from the app_usbd_hid_kbd... calls.

Related