Code: Select all
esp_err_t register_gattc(void)
{
esp_err_t ret;
ret = esp_ble_gattc_register_callback(esp_gattc_cb);
if (ret)
{
ESP_LOGE(COEX_TAG, "%s gattc register failed, error code = %x\n", __func__, ret);
return ret;
}
ret = esp_ble_gattc_app_register(GATTC_PROFILE_C_APP_ID);
if (ret)
{
ESP_LOGE(COEX_TAG, "%s gattc app register failed, error code = %x\n", __func__, ret);
return ret;
}
esp_err_t local_mtu_ret = esp_ble_gatt_set_local_mtu(500);
if (local_mtu_ret)
{
ESP_LOGE(COEX_TAG, "set local MTU failed, error code = %x", local_mtu_ret);
return local_mtu_ret;
}
return ESP_OK;
}
Code: Select all
static esp_err_t unregister_gattc(void)
{
esp_err_t ret;
// 注销GATT客户端应用
ret = esp_ble_gattc_app_unregister(GATTC_PROFILE_C_APP_ID);
if (ret)
{
ESP_LOGE(COEX_TAG, "%s gattc app unregister failed, error code = %x\n", __func__, ret);
return ret;
}
// 注销GATT客户端回调函数
ret = esp_ble_gattc_register_callback(NULL);
if (ret)
{
ESP_LOGE(COEX_TAG, "%s gattc unregister failed, error code = %x\n", __func__, ret);
return ret;
}
return ESP_OK;
}
Code: Select all
I (14276) GATTC_GATTS_COEX: GATTC unregisted.
E (14276) BT_APPL: Deregister Failed unknown client cif
E (14276) GATTC_GATTS_COEX: unregister_gattc gattc unregister failed, error code = ffffffff
I (14286) GATTC_GATTS_COEX: BLE closed.
W (14296) BT_APPL: bta_dm_disable BTA_DISABLE_DELAY set to 200 ms