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

NUS service without service discovery

Hi.

I have implemented the Central and Peripheral NUS service on two devices(nRF52). Since the central knows the characteristic values, I would like to bypass service discovery to reduce the time connection. I removed the "ble_db_discovery_start" from the BLE_GAP_EVT_CONNECTED and I found the handle values of RX, TX but I don't know how can I store them in my code and how can I use them to read and write the data. I would appreciate it if you kindly help me to overcome this problem.

thanks.

Parents
  • I solved my problem with the following solution.

    void bypass_discovery(ble_nus_c_t * p_ble_nus_c)
    {
         ble_nus_c_evt_t nus_c_evt;
         memset(&nus_c_evt,0,sizeof(ble_nus_c_evt_t));

        // the handle values of rx, tx, and ccd may be different in your project.
         nus_c_evt.handles.nus_rx_handle = 16;   
         nus_c_evt.handles.nus_tx_handle = 20;  
         nus_c_evt.handles.nus_tx_cccd_handle = 21;  
         nus_c_evt.conn_handle = conn_hndl;
         nus_c_evt.evt_type = BLE_NUS_C_EVT_DISCOVERY_COMPLETE;
         p_ble_nus_c->evt_handler(p_ble_nus_c, &nus_c_evt);
    }

    I made the following changes in the BLE_GAP_EVT_CONNECTED case under the ble_evt_handler function.


    case BLE_GAP_EVT_CONNECTED:

         // err_code = ble_db_discovery_start(&m_db_disc, p_ble_evt->evt.gap_evt.conn_handle);
         //  APP_ERROR_CHECK(err_code);

            bypass_discovery(&m_ble_nus_c);

Reply
  • I solved my problem with the following solution.

    void bypass_discovery(ble_nus_c_t * p_ble_nus_c)
    {
         ble_nus_c_evt_t nus_c_evt;
         memset(&nus_c_evt,0,sizeof(ble_nus_c_evt_t));

        // the handle values of rx, tx, and ccd may be different in your project.
         nus_c_evt.handles.nus_rx_handle = 16;   
         nus_c_evt.handles.nus_tx_handle = 20;  
         nus_c_evt.handles.nus_tx_cccd_handle = 21;  
         nus_c_evt.conn_handle = conn_hndl;
         nus_c_evt.evt_type = BLE_NUS_C_EVT_DISCOVERY_COMPLETE;
         p_ble_nus_c->evt_handler(p_ble_nus_c, &nus_c_evt);
    }

    I made the following changes in the BLE_GAP_EVT_CONNECTED case under the ble_evt_handler function.


    case BLE_GAP_EVT_CONNECTED:

         // err_code = ble_db_discovery_start(&m_db_disc, p_ble_evt->evt.gap_evt.conn_handle);
         //  APP_ERROR_CHECK(err_code);

            bypass_discovery(&m_ble_nus_c);

Children
No Data
Related