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.

Parents
  • For me it doesn't really mater if it is persistently or not it thought it would be most easy to do it persistently because the Device Manager supports that. I want to bond one device at the time and the peripheral is an simple S110 device with a button. The Central is constantly scanning for it's bonded device and tries to connect with it.

    This is all working fine but to make the connection extra fast I want to save the discovered services. I tried to implement an none persistent version but I couldn't really figure out how to do that.

    Now there are these functions meant for saving the context but there is no example anywhere on how to use them. Especially how do I set the p_context pointer or what should I give to this p_context so it knows the discovered services.

Reply
  • For me it doesn't really mater if it is persistently or not it thought it would be most easy to do it persistently because the Device Manager supports that. I want to bond one device at the time and the peripheral is an simple S110 device with a button. The Central is constantly scanning for it's bonded device and tries to connect with it.

    This is all working fine but to make the connection extra fast I want to save the discovered services. I tried to implement an none persistent version but I couldn't really figure out how to do that.

    Now there are these functions meant for saving the context but there is no example anywhere on how to use them. Especially how do I set the p_context pointer or what should I give to this p_context so it knows the discovered services.

Children
No Data
Related