From 939cff9b31516397c1aa467452e055a46938f3e4 Mon Sep 17 00:00:00 2001 From: Guy Mishol Date: Fri, 3 Jan 2025 16:53:35 +0200 Subject: [PATCH 1/4] nimble/host: Fix wrong Host Error Code used in GATT client code A wrong Host Error Code was used in ble_gattc.c file cause compilation error. Fix it by replacing with the correct Host Error Code. --- nimble/host/src/ble_gattc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nimble/host/src/ble_gattc.c b/nimble/host/src/ble_gattc.c index b3c8e04e12..0ff4ec28e6 100644 --- a/nimble/host/src/ble_gattc.c +++ b/nimble/host/src/ble_gattc.c @@ -4444,7 +4444,7 @@ ble_gatts_notify_multiple_custom(uint16_t conn_handle, conn = ble_hs_conn_find(conn_handle); if (conn == NULL) { - return ENOTCONN; + return BLE_HS_ENOTCONN; } /* Read missing values */ @@ -4527,7 +4527,7 @@ ble_gatts_notify_multiple(uint16_t conn_handle, BLE_HS_LOG_DEBUG("conn_handle %d\n", conn_handle); conn = ble_hs_conn_find(conn_handle); if (conn == NULL) { - return ENOTCONN; + return BLE_HS_ENOTCONN; } /** Skip sending to client that doesn't support this feature */ From 734a53dccc1593134a2edf7aa05b7e23e4082395 Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 30 Dec 2024 23:38:40 +0100 Subject: [PATCH 2/4] debug: Declare as printf-style, remove empty statement This resolves the -Wformat-nonliteral warning by (which complains about non-literals used as printf formatters, unless the containing function itself is also printf style), and a stray leftover empty debug statement discovered by that warning: -Wformat-nonliteral is a bit of a false postive here because due to the level prefix, the empty printf is not *really* empty, but it is accurate enough in that it does not provide any valuable details. --- nimble/host/src/ble_gatts.c | 2 -- porting/npl/riot/include/nimble/nimble_npl_os_log.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/nimble/host/src/ble_gatts.c b/nimble/host/src/ble_gatts.c index c77e561b73..ee6a8a3c65 100644 --- a/nimble/host/src/ble_gatts.c +++ b/nimble/host/src/ble_gatts.c @@ -1619,8 +1619,6 @@ ble_gatts_peer_cl_sup_feat_update(uint16_t conn_handle, struct os_mbuf *om) int rc = 0; int i; - BLE_HS_LOG(DEBUG, ""); - if (!om) { return BLE_ATT_ERR_INSUFFICIENT_RES; } diff --git a/porting/npl/riot/include/nimble/nimble_npl_os_log.h b/porting/npl/riot/include/nimble/nimble_npl_os_log.h index 5fcce6aeec..91c8047547 100644 --- a/porting/npl/riot/include/nimble/nimble_npl_os_log.h +++ b/porting/npl/riot/include/nimble/nimble_npl_os_log.h @@ -24,6 +24,7 @@ /* Example on how to use macro to generate module logging functions */ #define BLE_NPL_LOG_IMPL(lvl) \ + __attribute__((__format__ (__printf__, 1, 0))) \ static inline void _BLE_NPL_LOG_CAT(BLE_NPL_LOG_MODULE, \ _BLE_NPL_LOG_CAT(_, lvl))(const char *fmt, ...)\ { \ From 2a14c85d5a6124b8835b89a40da7afb68446c39e Mon Sep 17 00:00:00 2001 From: Guy Mishol Date: Fri, 3 Jan 2025 17:05:29 +0200 Subject: [PATCH 3/4] nimble/host: Fix a build warning caused by using undeclared min function Use of undeclared min function causes build warning. Declare the min and max function in file ble_l2cap_coc.c --- nimble/host/src/ble_l2cap_coc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nimble/host/src/ble_l2cap_coc.c b/nimble/host/src/ble_l2cap_coc.c index a3d1b1c22d..d4cb15f971 100644 --- a/nimble/host/src/ble_l2cap_coc.c +++ b/nimble/host/src/ble_l2cap_coc.c @@ -27,6 +27,14 @@ #if MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM) != 0 && NIMBLE_BLE_CONNECT +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + #define BLE_L2CAP_SDU_SIZE 2 STAILQ_HEAD(ble_l2cap_coc_srv_list, ble_l2cap_coc_srv); From 2fcb7812d765adc6f167c2c6a5c56e2bfaf2c6e9 Mon Sep 17 00:00:00 2001 From: Guy Mishol Date: Fri, 3 Jan 2025 17:09:32 +0200 Subject: [PATCH 4/4] nimble/host: Fix a build warning caused by undeclared ARRAY_SIZE macro Use of undeclared ARRAY_SIZE macro causes build warning. Add include to "os/util.h" in ble_store_config.c file. --- nimble/host/store/config/src/ble_store_config.c | 1 + 1 file changed, 1 insertion(+) diff --git a/nimble/host/store/config/src/ble_store_config.c b/nimble/host/store/config/src/ble_store_config.c index 664b8768bf..b800a4ee58 100644 --- a/nimble/host/store/config/src/ble_store_config.c +++ b/nimble/host/store/config/src/ble_store_config.c @@ -24,6 +24,7 @@ #include "syscfg/syscfg.h" #include "host/ble_hs.h" #include "base64/base64.h" +#include "os/util.h" #include "store/config/ble_store_config.h" #include "ble_store_config_priv.h"