From a797dca528e3860204cfd6987be1bdde5e25dc68 Mon Sep 17 00:00:00 2001 From: Asuki Kono Date: Tue, 11 Apr 2017 20:54:33 +0900 Subject: [PATCH] Replace to strncmp from strcmp to check device_name on examples/bluetooth/gatt_client (Amended slightly from version in https://github.com/espressif/esp-idf/pull/502 to account for differences when adv_name is a prefix of device_name.) --- examples/bluetooth/gatt_client/main/gattc_demo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/bluetooth/gatt_client/main/gattc_demo.c b/examples/bluetooth/gatt_client/main/gattc_demo.c index 2d852c831..089289d00 100644 --- a/examples/bluetooth/gatt_client/main/gattc_demo.c +++ b/examples/bluetooth/gatt_client/main/gattc_demo.c @@ -318,8 +318,8 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par } if (adv_name != NULL) { - if (strcmp((char *)adv_name, device_name) == 0) { - ESP_LOGI(GATTC_TAG, "Searched device %s", device_name); + if (strlen(device_name) == adv_name_len && strncmp((char *)adv_name, device_name, adv_name_len) == 0) { + ESP_LOGI(GATTC_TAG, "Searched device %s\n", device_name); if (connect == false) { connect = true; ESP_LOGI(GATTC_TAG, "Connect to the remote device.");