From ed400c4feb7955bdc839fbf33b463a73c898a033 Mon Sep 17 00:00:00 2001 From: Peter Johanson <peter@peterjohanson.com> Date: Wed, 19 Jul 2023 16:21:06 +0000 Subject: [PATCH] fix(bluetooth): Corrected use of `bt_addr_le_cmp` * Properly compare to zero when comparing LE addresses. --- app/src/ble.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/ble.c b/app/src/ble.c index 6607574c..38a9833c 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -281,14 +281,14 @@ int zmk_ble_put_peripheral_addr(const bt_addr_le_t *addr) { for (int i = 0; i < ZMK_SPLIT_BLE_PERIPHERAL_COUNT; i++) { // If the address is recognized and already stored in settings, return // index and no additional action is necessary. - if (!bt_addr_le_cmp(&peripheral_addrs[i], addr)) { + if (bt_addr_le_cmp(&peripheral_addrs[i], addr) == 0) { return i; } // If the peripheral address slot is open, store new peripheral in the // slot and return index. This compares against BT_ADDR_LE_ANY as that // is the zero value. - if (!bt_addr_le_cmp(&peripheral_addrs[i], BT_ADDR_LE_ANY)) { + if (bt_addr_le_cmp(&peripheral_addrs[i], BT_ADDR_LE_ANY) == 0) { char addr_str[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(addr, addr_str, sizeof(addr_str)); LOG_DBG("Storing peripheral %s in slot %d", addr_str, i);