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

How to discover services only ones?

Hello,

I'm trying to store the discovered services and characteristics only ones at first connection with an bonded device at the central. So following connection events will be faster. Currently my code for the discovery looks like this:

    case DM_EVT_CONNECTION:
    {

					m_client.handle = (*p_handle);
									
					memset(&m_client.srv_db, 0 , sizeof (m_client.srv_db));
					
					// Discover peer's services. 
					err_code = ble_db_discovery_start(&m_client.srv_db,
																						p_event->event_param.p_gap_param->conn_handle);
					APP_ERROR_CHECK(err_code);							
					
        m_peer_count++;

        if (m_peer_count < MAX_PEER_COUNT)
        {
            scan_start();
        }
					
        break;
    }

Now I want to do something to not have to do ble_db_discovery_start at each connection.

I found that you can use these functions to do this:

ret_code_t dm_application_context_set(dm_handle_t const              * p_handle,
                                    dm_application_context_t const * p_context)

ret_code_t dm_application_context_get(dm_handle_t const        * p_handle,
                                    dm_application_context_t * p_context)

But how to actually do this is never explained.

Can anyone get me on the right track to implement this.

Thanks.

Related