static void btc_gattc_search_service(btc_ble_gattc_args_t *arg)
{
- tBT_UUID *srvc_uuid = (tBT_UUID *)(&arg->uuid);
- BTA_GATTC_ServiceSearchRequest(arg->conn_id, srvc_uuid);
+ tBT_UUID srvc_uuid;
+
+ if (arg->have_uuid) {
+ btc_to_bta_uuid(&srvc_uuid, &arg->uuid);
+ BTA_GATTC_ServiceSearchRequest(arg->conn_id, &srvc_uuid);
+ } else {
+ BTA_GATTC_ServiceSearchRequest(arg->conn_id, NULL);
+ }
}
static void btc_gattc_get_first_char(btc_ble_gattc_args_t *arg)
case BTA_GATTC_SEARCH_RES_EVT: {
tBTA_GATTC_SRVC_RES *srvc_res = &arg->srvc_res;
param.search_res.conn_id = srvc_res->conn_id;
- memcpy(¶m.search_res.service_id, &srvc_res->service_uuid, sizeof(esp_gatt_srvc_id_t));
+ bta_to_btc_srvc_id(¶m.search_res.service_id, &srvc_res->service_uuid);
BTC_GATTC_CB_TO_APP(ESP_GATTC_SEARCH_RES_EVT, ¶m);
break;
}
#include "bta_gatt_api.h"
#include "esp_gap_ble_api.h"
#include "esp_gattc_api.h"
+#include "esp_gatt_defs.h"
#include "esp_bt_main.h"
conidx = gattc_data->open.conn_id;
LOG_ERROR("conidx = %x, if = %x\n",conidx, gattc_data->open.gatt_if);
esp_ble_gattc_search_service(conidx, NULL);
- LOG_ERROR("ESP_GATTC_OPEN_EVT\n");
+ LOG_ERROR("ESP_GATTC_OPEN_EVT status %d\n", gattc_data->open.status);
+ break;
+ case ESP_GATTC_SEARCH_RES_EVT: {
+ esp_gatt_srvc_id_t *srvc_id = &gattc_data->search_res.service_id;
+ conidx = gattc_data->open.conn_id;
+ LOG_ERROR("SEARCH RES: conidx = %x\n", conidx);
+ if (srvc_id->id.uuid.len == ESP_UUID_LEN_16) {
+ LOG_ERROR("UUID16: %x\n", srvc_id->id.uuid.uuid.uuid16);
+ } else if (srvc_id->id.uuid.len == ESP_UUID_LEN_32) {
+ LOG_ERROR("UUID32: %x\n", srvc_id->id.uuid.uuid.uuid32);
+ } else if (srvc_id->id.uuid.len == ESP_UUID_LEN_128) {
+ LOG_ERROR("UUID128: %x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x,%x\n", srvc_id->id.uuid.uuid.uuid128[0],
+ srvc_id->id.uuid.uuid.uuid128[1],srvc_id->id.uuid.uuid.uuid128[2], srvc_id->id.uuid.uuid.uuid128[3],
+ srvc_id->id.uuid.uuid.uuid128[4],srvc_id->id.uuid.uuid.uuid128[5],srvc_id->id.uuid.uuid.uuid128[6],
+ srvc_id->id.uuid.uuid.uuid128[7],srvc_id->id.uuid.uuid.uuid128[8],srvc_id->id.uuid.uuid.uuid128[9],
+ srvc_id->id.uuid.uuid.uuid128[10],srvc_id->id.uuid.uuid.uuid128[11],srvc_id->id.uuid.uuid.uuid128[12],
+ srvc_id->id.uuid.uuid.uuid128[13],srvc_id->id.uuid.uuid.uuid128[14],srvc_id->id.uuid.uuid.uuid128[15]);
+ } else {
+ LOG_ERROR("UNKNOWN LEN %d\n", srvc_id->id.uuid.len);
+ }
+ break;
+ }
+ case ESP_GATTC_SEARCH_CMPL_EVT:
+ conidx = gattc_data->search_cmpl.conn_id;
+ LOG_ERROR("SEARCH_CMPL: conidx = %x, status %d\n",conidx, gattc_data->search_cmpl.status);
break;
default:
- break;
+ break;
}
}