diff --git a/library.json b/library.json index 7d7d955..8467579 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "ERa", - "version": "0.9.0", + "version": "0.9.1", "description": "E-Ra by EoH. An IoT Market Enabler! It supports WiFi, Ethernet, Zigbee, Modbus, Serial. Works with boards like Arduino, ESP8266, ESP32, STM32, Raspberry Pi...", "keywords": "ERa, E-Ra, esp8266, esp32, stm32, raspberry-pi, http, mqtt, zigbee, modbus, sensors, control, device, smartphone, mobile, app, web, cloud, communication, protocol, iot, wifi, ethernet, serial", "authors": diff --git a/library.properties b/library.properties index a645592..eb39951 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ERa -version=0.9.0 +version=0.9.1 author=EoH Ltd license=MIT maintainer=EoH Ltd diff --git a/src/BLE/ERaBLETranspEsp32.hpp b/src/BLE/ERaBLETranspEsp32.hpp index 8ecb676..64d2abf 100644 --- a/src/BLE/ERaBLETranspEsp32.hpp +++ b/src/BLE/ERaBLETranspEsp32.hpp @@ -15,7 +15,7 @@ #include #define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b" -#define CHARACTERISTIC_UUID_TKN "cf153564-bc0d-11ed-afa1-0242ac120002" +#define CHARACTERISTIC_UUID_TKN "cf153c1f-bc0d-11ed-afa1-0242ac120002" #define CHARACTERISTIC_UUID_RSP "fba737c2-9f19-4779-9ef2-9446c29d0bf5" #define CHARACTERISTIC_UUID_CMD "b32f3620-2846-4d1c-88aa-5dd06c0ad15e" diff --git a/src/BLE/ERaNimBLETransp.hpp b/src/BLE/ERaNimBLETransp.hpp index 1170a5e..f5fb78e 100644 --- a/src/BLE/ERaNimBLETransp.hpp +++ b/src/BLE/ERaNimBLETransp.hpp @@ -14,7 +14,7 @@ #include #define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b" -#define CHARACTERISTIC_UUID_TKN "cf153564-bc0d-11ed-afa1-0242ac120002" +#define CHARACTERISTIC_UUID_TKN "cf153c1f-bc0d-11ed-afa1-0242ac120002" #define CHARACTERISTIC_UUID_RSP "fba737c2-9f19-4779-9ef2-9446c29d0bf5" #define CHARACTERISTIC_UUID_CMD "b32f3620-2846-4d1c-88aa-5dd06c0ad15e" diff --git a/src/ERa/ERaApi.hpp b/src/ERa/ERaApi.hpp index c85f84c..5b87f6c 100644 --- a/src/ERa/ERaApi.hpp +++ b/src/ERa/ERaApi.hpp @@ -22,18 +22,24 @@ #endif #if defined(analogInputToDigitalPin) - #define ERA_DECODE_PIN(pin) analogInputToDigitalPin(pin) + #define ERA_DECODE_PIN(pin) analogInputToDigitalPin(pin) #else - #define ERA_DECODE_PIN(pin) pin + #define ERA_DECODE_PIN(pin) pin #endif -#define ERA_INVALID_PIN 0xFF -#define ERA_CHECK_PIN(pin) if (pin == ERA_INVALID_PIN) { continue; } -#define ERA_CHECK_PIN_RETURN(pin) if (pin == ERA_INVALID_PIN) { return; } +#define ERA_INVALID_PIN 0xFF -#define ERA_DECODE_PIN_NUMBER(pin) pin -#define ERA_DECODE_PIN_NAME(pin) (((pin[0] == 'a') || (pin[0] == 'A')) ? \ - ERA_DECODE_PIN(atoi(pin + 1)) : ERA_DECODE_PIN_NUMBER(atoi(pin))) +#if defined(digitalPinIsValid) + #define ERA_CHECK_PIN(pin) if (!digitalPinIsValid(pin)) { continue; } + #define ERA_CHECK_PIN_RETURN(pin) if (!digitalPinIsValid(pin)) { return; } +#else + #define ERA_CHECK_PIN(pin) if (pin == ERA_INVALID_PIN) { continue; } + #define ERA_CHECK_PIN_RETURN(pin) if (pin == ERA_INVALID_PIN) { return; } +#endif + +#define ERA_DECODE_PIN_NUMBER(pin) pin +#define ERA_DECODE_PIN_NAME(pin) (((pin[0] == 'a') || (pin[0] == 'A')) ? \ + ERA_DECODE_PIN(atoi(pin + 1)) : ERA_DECODE_PIN_NUMBER(atoi(pin))) enum ERaTypeWriteT { ERA_WRITE_VIRTUAL_PIN = 0, diff --git a/src/ERa/ERaData.hpp b/src/ERa/ERaData.hpp index 382e27e..09c1615 100644 --- a/src/ERa/ERaData.hpp +++ b/src/ERa/ERaData.hpp @@ -508,20 +508,26 @@ void ERaDataBuff::onChangeHex(uint8_t value) { inline void ERaDataBuff::onChangeHex(const uint8_t* ptr, size_t size) { - if (ptr == nullptr || !size) { + if ((ptr == nullptr) || !size) { return; } size_t len = size * 2 + 1; - char* buf = (char*)malloc(len); - if (buf == nullptr) { - return; + char locBuf[32] {0}; + char* buf = locBuf; + if (len > sizeof(locBuf)) { + buf = (char*)malloc(len); + if (buf == nullptr) { + return; + } } + size_t pos {0}; for (size_t i = 0; i < size; ++i) { - size_t pos = i * 2; - snprintf(buf + pos, size - pos, "%02x", ptr[i]); + pos += snprintf(buf + pos, len - pos, "%02x", ptr[i]); } onChange(buf); - free(buf); + if (buf != locBuf) { + free(buf); + } buf = nullptr; } diff --git a/src/ERa/ERaHelper.hpp b/src/ERa/ERaHelper.hpp index 33babfd..fd19279 100644 --- a/src/ERa/ERaHelper.hpp +++ b/src/ERa/ERaHelper.hpp @@ -14,7 +14,7 @@ template class StaticRefHelper { public: static S& instance(Args&... tail) { - static S& _instance(tail...); + static S _instance(tail...); return _instance; } };