how to get all services supported by slaver?

xzwang
Posts: 22
Joined: Wed Dec 14, 2016 4:54 am

how to get all services supported by slaver?

Postby xzwang » Fri Dec 30, 2016 9:15 am

I have read the exmaple15, esp32 as the GATT Client. It can connect the indicated device now, but there is no code to get all services,charasteristics,descriptions. I have found the API:
esp_ble_gattc_get_characteristic(uint16_t conn_id,esp_gatt_srvc_id_t *srvc_id, esp_gatt_id_t *start_char_id);
esp_ble_gattc_get_descriptor(uint16_t conn_id,esp_gatt_srvc_id_t *srvc_id, esp_gatt_id_t *char_id,esp_gatt_id_t *start_descr_id);

I use these two APIs and want to get all included services,characteristics,descriptions. Sometimes esp32 has list all information, but sometimes it crashed.


Anyone has ever implement this function(list all connection info)? This is my first step to get connected device's info. Second step is writing characteristic and receiving notify. I also want to connect more than one ble devices.

My key code is followed:

Code: Select all

static void esp_gattc_cb(uint32_t event, void *param)
{
        ...
	case ESP_GATTC_SEARCH_CMPL_EVT:
	    ...
	    //call esp_ble_gattc_get_characteristic for each service
	    while( service_node )
	    {
	        esp_ble_gattc_get_characteristic( conn_id, service_node->srvc_id, NULL );
	        service_node = service_node->next;
	    }
	    break;
	    
	case ESP_GATTC_GET_CHAR_EVT:
	    ...
	    esp_ble_gattc_get_descriptor( conn_id, srvc_id, char_id, NULL );
	    esp_ble_gattc_get_characteristic( conn_id, srvc_id, char_id );
	    break;
	    
	case ESP_GATTC_GET_DESCR_EVT:
	    ...
	    esp_ble_gattc_get_descriptor( conn_id, srvc_id, char_id, descr_id );
	    break;
}

Narmor
Posts: 3
Joined: Mon Feb 20, 2017 10:07 pm

Re: how to get all services supported by slaver?

Postby Narmor » Mon Feb 20, 2017 10:11 pm

Have you found a solution to your problem? I want to do the same thing, but I have just started working with the esp and bluetooth, so im not really progressing atm. It would be nice to see some snippets if you have solved the problem! Thanks!

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 19 guests