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

working principle of db discovery module

Hi 

i have below requirement:

My device acts as central and i am using db discovery module to discover services which are registered using ble_db_discovery_evt_register().

and i have registered Heart Rates sensor service UUID 180D. now my device should discover service and if HRS service is offered by peripheral then my device prints service is available.

Problem: If the peripheral offers only HRS then my device says service available.

else if peripheral offers HRS and other services then my device is unable to find HRS from list of services offered by peripheral device.

why is this happening?

what modifications should be done to achieve my requirement.

Thanks

Rekha

Parents
  • attached

    //Init service 
    static void services_init(void)
    {
      ret_code_t         err_code;
      ble_dis_init_t     dis_init;
      nrf_ble_qwr_init_t qwr_init = {0};
     
      // Initialize Queued Write Module.
      qwr_init.error_handler = nrf_qwr_error_handler;
      
      err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init);
      APP_ERROR_CHECK(err_code);
      
      // Initialize Device Information Service.
      memset(&dis_init, 0, sizeof(dis_init));
      
      ble_srv_ascii_to_utf8(&dis_init.manufact_name_str, (char *)MANUFACTURER_NAME);
      
      dis_init.dis_char_rd_sec = SEC_OPEN;
      
      err_code = ble_dis_init(&dis_init);
      APP_ERROR_CHECK(err_code);
      
      /*  RK code to initialize the nonin services used by the application.*/
      ble_uuid_t            ble_uuid;
    //  BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HEALTH_THERMOMETER_SERVICE);
      BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HEART_RATE_SERVICE);
     
      err_code = ble_db_discovery_evt_register(&ble_uuid);
      }
      
      
      
      ////call db_discovery_start in ble_evt_handler
       if (normal_mode_on == false)
          {
            do 
            {
              err_code = ble_db_discovery_start(&m_db_disc[p_gap_evt->conn_handle],p_gap_evt->conn_handle);
              if (err_code == NRF_SUCCESS)
              {
                NRF_LOG_INFO("discovery started :busy status\n");
                APP_ERROR_CHECK(err_code);
              }
              
            }while(err_code == NRF_ERROR_BUSY);
            }
        
    
    
    ////discovery event handler comparing for services offered by peripheral with that of registered services
    
    void ble_serv_on_db_disc_evt(ble_db_discovery_evt_t const * p_evt)
    {
      // Check if the Led Button Service was discovered.
      
      ret_code_t err_code;
      
      for (uint8_t i =0; i < sizeof(m_scan_uuid)/sizeof(m_scan_uuid[0]); i++)
      {
        
        if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE &&
            p_evt->params.discovered_db.srv_uuid.uuid == m_scan_uuid[i].uuid &&
              p_evt->params.discovered_db.srv_uuid.type == m_scan_uuid[i].type)
        {
          NRF_LOG_INFO("Service available:%x \n\r", p_evt->params.discovered_db.srv_uuid.uuid);
        }
      }
    }
        
            
    code snippets for reference.

  • Hi i got answer already ..i got confused.

    Thanks

Reply Children
No Data
Related