mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 12:44:33 +02:00
Merge branch 'bugfix/gattc_example_strcmp' into 'master'
Fix device_name check in gatt_client example `strcmp` was used against `adv_name` array, which was not a zero terminated string, causing `strcmp` check to fail for valid names. Ref. https://github.com/espressif/esp-idf/pull/502 See merge request !652
This commit is contained in:
@@ -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 (adv_name != NULL) {
|
||||||
if (strcmp((char *)adv_name, device_name) == 0) {
|
if (strlen(device_name) == adv_name_len && strncmp((char *)adv_name, device_name, adv_name_len) == 0) {
|
||||||
ESP_LOGI(GATTC_TAG, "Searched device %s", device_name);
|
ESP_LOGI(GATTC_TAG, "Searched device %s\n", device_name);
|
||||||
if (connect == false) {
|
if (connect == false) {
|
||||||
connect = true;
|
connect = true;
|
||||||
ESP_LOGI(GATTC_TAG, "Connect to the remote device.");
|
ESP_LOGI(GATTC_TAG, "Connect to the remote device.");
|
||||||
|
Reference in New Issue
Block a user