From cee369fd923a807e2d942e190d6f34045383d678 Mon Sep 17 00:00:00 2001 From: h2zero Date: Sat, 15 Jan 2022 12:43:17 -0700 Subject: [PATCH] Cleanup ARM-gcc compiler warnings. --- src/HIDTypes.h | 9 ++------- src/NimBLEClient.cpp | 4 ++-- src/NimBLELog.h | 10 +++++----- src/NimBLERemoteCharacteristic.cpp | 4 ++-- src/NimBLERemoteDescriptor.cpp | 6 +++--- src/NimBLEScan.cpp | 2 +- src/NimBLEServer.cpp | 4 ++-- 7 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/HIDTypes.h b/src/HIDTypes.h index 726b84b..8ee31da 100644 --- a/src/HIDTypes.h +++ b/src/HIDTypes.h @@ -45,13 +45,8 @@ /* of data as per HID Class standard */ /* Main items */ -#ifdef ARDUINO_ARCH_ESP32 -#define HIDINPUT(size) (0x80 | size) -#define HIDOUTPUT(size) (0x90 | size) -#else -#define INPUT(size) (0x80 | size) -#define OUTPUT(size) (0x90 | size) -#endif +#define HIDINPUT(size) (0x80 | size) +#define HIDOUTPUT(size) (0x90 | size) #define FEATURE(size) (0xb0 | size) #define COLLECTION(size) (0xa0 | size) #define END_COLLECTION(size) (0xc0 | size) diff --git a/src/NimBLEClient.cpp b/src/NimBLEClient.cpp index 5b71c5f..810159e 100644 --- a/src/NimBLEClient.cpp +++ b/src/NimBLEClient.cpp @@ -465,7 +465,7 @@ void NimBLEClient::updateConnParams(uint16_t minInterval, uint16_t maxInterval, */ void NimBLEClient::setDataLen(uint16_t tx_octets) { #if defined(CONFIG_NIMBLE_CPP_IDF) && defined(ESP_IDF_VERSION) && \ - ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(4,3,2) + ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 3 && ESP_IDF_VERSION_PATCH >= 2 return; #else uint16_t tx_time = (tx_octets + 14) * 8; @@ -1084,7 +1084,7 @@ uint16_t NimBLEClient::getMTU() { NIMBLE_LOGD(LOG_TAG, "ble_sm_inject_io result: %d", rc); } else if (event->passkey.params.action == BLE_SM_IOACT_NUMCMP) { - NIMBLE_LOGD(LOG_TAG, "Passkey on device's display: %d", event->passkey.params.numcmp); + NIMBLE_LOGD(LOG_TAG, "Passkey on device's display: %" PRIu32, event->passkey.params.numcmp); pkey.action = event->passkey.params.action; // Compatibility only - Do not use, should be removed the in future if(NimBLEDevice::m_securityCallbacks != nullptr) { diff --git a/src/NimBLELog.h b/src/NimBLELog.h index 75c3e44..dda9073 100644 --- a/src/NimBLELog.h +++ b/src/NimBLELog.h @@ -50,26 +50,26 @@ # endif # if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 4 -# define NIMBLE_LOGD( tag, format, ... ) console_printf("D %s: "#format"\n",tag,##__VA_ARGS__) +# define NIMBLE_LOGD( tag, format, ... ) console_printf("D %s: " format "\n", tag, ##__VA_ARGS__) # else # define NIMBLE_LOGD( tag, format, ... ) (void)tag # endif # if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 3 -# define NIMBLE_LOGI( tag, format, ... ) console_printf("I %s: "#format"\n",tag,##__VA_ARGS__) +# define NIMBLE_LOGI( tag, format, ... ) console_printf("I %s: " format "\n", tag, ##__VA_ARGS__) # else # define NIMBLE_LOGI( tag, format, ... ) (void)tag # endif # if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 2 -# define NIMBLE_LOGW( tag, format, ... ) console_printf("W %s: "#format"\n",tag,##__VA_ARGS__) +# define NIMBLE_LOGW( tag, format, ... ) console_printf("W %s: " format "\n", tag, ##__VA_ARGS__) # else # define NIMBLE_LOGW( tag, format, ... ) (void)tag # endif # if CONFIG_NIMBLE_CPP_LOG_LEVEL >= 1 -# define NIMBLE_LOGE( tag, format, ... ) console_printf("E %s: "#format"\n",tag,##__VA_ARGS__) -# define NIMBLE_LOGC( tag, format, ... ) console_printf("CRIT %s: "#format"\n",tag,##__VA_ARGS__) +# define NIMBLE_LOGE( tag, format, ... ) console_printf("E %s: " format "\n", tag, ##__VA_ARGS__) +# define NIMBLE_LOGC( tag, format, ... ) console_printf("CRIT %s: " format "\n", tag, ##__VA_ARGS__) # else # define NIMBLE_LOGE( tag, format, ... ) (void)tag # define NIMBLE_LOGC( tag, format, ... ) (void)tag diff --git a/src/NimBLERemoteCharacteristic.cpp b/src/NimBLERemoteCharacteristic.cpp index 7fe283d..8567967 100644 --- a/src/NimBLERemoteCharacteristic.cpp +++ b/src/NimBLERemoteCharacteristic.cpp @@ -563,11 +563,11 @@ int NimBLERemoteCharacteristic::onReadCB(uint16_t conn_handle, if(rc == 0) { if(attr) { - uint32_t data_len = OS_MBUF_PKTLEN(attr->om); + uint16_t data_len = OS_MBUF_PKTLEN(attr->om); if(((*strBuf).length() + data_len) > BLE_ATT_ATTR_MAX_LEN) { rc = BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; } else { - NIMBLE_LOGD(LOG_TAG, "Got %d bytes", data_len); + NIMBLE_LOGD(LOG_TAG, "Got %u bytes", data_len); (*strBuf) += std::string((char*) attr->om->om_data, data_len); return 0; } diff --git a/src/NimBLERemoteDescriptor.cpp b/src/NimBLERemoteDescriptor.cpp index d2e1728..64ce06d 100644 --- a/src/NimBLERemoteDescriptor.cpp +++ b/src/NimBLERemoteDescriptor.cpp @@ -180,7 +180,7 @@ std::string NimBLERemoteDescriptor::readValue() { } } while(rc != 0 && retryCount--); - NIMBLE_LOGD(LOG_TAG, "<< Descriptor readValue(): length: %d rc=%d", value.length(), rc); + NIMBLE_LOGD(LOG_TAG, "<< Descriptor readValue(): length: %u rc=%d", value.length(), rc); return value; } // readValue @@ -209,11 +209,11 @@ int NimBLERemoteDescriptor::onReadCB(uint16_t conn_handle, if(rc == 0) { if(attr) { - uint32_t data_len = OS_MBUF_PKTLEN(attr->om); + uint16_t data_len = OS_MBUF_PKTLEN(attr->om); if(((*strBuf).length() + data_len) > BLE_ATT_ATTR_MAX_LEN) { rc = BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; } else { - NIMBLE_LOGD(LOG_TAG, "Got %d bytes", data_len); + NIMBLE_LOGD(LOG_TAG, "Got %u bytes", data_len); (*strBuf) += std::string((char*) attr->om->om_data, data_len); return 0; } diff --git a/src/NimBLEScan.cpp b/src/NimBLEScan.cpp index 041bd2f..57a5df3 100644 --- a/src/NimBLEScan.cpp +++ b/src/NimBLEScan.cpp @@ -283,7 +283,7 @@ bool NimBLEScan::isScanning() { * @return True if scan started or false if there was an error. */ bool NimBLEScan::start(uint32_t duration, void (*scanCompleteCB)(NimBLEScanResults), bool is_continue) { - NIMBLE_LOGD(LOG_TAG, ">> start(duration=%d)", duration); + NIMBLE_LOGD(LOG_TAG, ">> start: duration=%" PRIu32, duration); // Save the callback to be invoked when the scan completes. m_scanCompleteCB = scanCompleteCB; diff --git a/src/NimBLEServer.cpp b/src/NimBLEServer.cpp index 11a28d0..4e4ab7f 100644 --- a/src/NimBLEServer.cpp +++ b/src/NimBLEServer.cpp @@ -537,7 +537,7 @@ NimBLEConnInfo NimBLEServer::getPeerIDInfo(uint16_t id) { NIMBLE_LOGD(LOG_TAG, "BLE_SM_IOACT_DISP; ble_sm_inject_io result: %d", rc); } else if (event->passkey.params.action == BLE_SM_IOACT_NUMCMP) { - NIMBLE_LOGD(LOG_TAG, "Passkey on device's display: %d", event->passkey.params.numcmp); + NIMBLE_LOGD(LOG_TAG, "Passkey on device's display: %" PRIu32, event->passkey.params.numcmp); pkey.action = event->passkey.params.action; // Compatibility only - Do not use, should be removed the in future if(NimBLEDevice::m_securityCallbacks != nullptr) { @@ -786,7 +786,7 @@ void NimBLEServer::updateConnParams(uint16_t conn_handle, */ void NimBLEServer::setDataLen(uint16_t conn_handle, uint16_t tx_octets) { #if defined(CONFIG_NIMBLE_CPP_IDF) && defined(ESP_IDF_VERSION) && \ - ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(4,3,2) + ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 3 && ESP_IDF_VERSION_PATCH >= 2 return; #else uint16_t tx_time = (tx_octets + 14) * 8;