Skip to content

Commit

Permalink
Merge branch 'bugfix/gattc_example_strcmp' into 'master'
Browse files Browse the repository at this point in the history
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. #502

See merge request !652
  • Loading branch information
jack0c committed Apr 24, 2017
2 parents 99e461c + a797dca commit 36ed7f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/bluetooth/gatt_client/main/gattc_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down

0 comments on commit 36ed7f5

Please sign in to comment.