From 89999abf0d820e336dfe0eb47183735a2889d419 Mon Sep 17 00:00:00 2001 From: Brian Baraban <34078628+bbaraban@users.noreply.github.com> Date: Sun, 3 Jan 2021 19:38:32 -0600 Subject: [PATCH 1/4] Fix incorrect saturation value sent back to SmartThings (#76) Thanks! --- apps/capability_sample/caps_colorControl.c | 2 +- apps/rtl8721c/light_example/main/caps_colorControl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/capability_sample/caps_colorControl.c b/apps/capability_sample/caps_colorControl.c index 83e6ed02..659bea47 100644 --- a/apps/capability_sample/caps_colorControl.c +++ b/apps/capability_sample/caps_colorControl.c @@ -57,7 +57,7 @@ static void caps_colorControl_attr_color_send(caps_colorControl_data_t *caps_dat NULL); value[1].type = IOT_CAP_VAL_TYPE_NUMBER; - value[1].number = caps_data->hue_value; + value[1].number = caps_data->saturation_value; cap_evt[1] = st_cap_create_attr(caps_data->handle, (char *) caps_helper_colorControl.attr_saturation.name, diff --git a/apps/rtl8721c/light_example/main/caps_colorControl.c b/apps/rtl8721c/light_example/main/caps_colorControl.c index 83e6ed02..659bea47 100644 --- a/apps/rtl8721c/light_example/main/caps_colorControl.c +++ b/apps/rtl8721c/light_example/main/caps_colorControl.c @@ -57,7 +57,7 @@ static void caps_colorControl_attr_color_send(caps_colorControl_data_t *caps_dat NULL); value[1].type = IOT_CAP_VAL_TYPE_NUMBER; - value[1].number = caps_data->hue_value; + value[1].number = caps_data->saturation_value; cap_evt[1] = st_cap_create_attr(caps_data->handle, (char *) caps_helper_colorControl.attr_saturation.name, From d607f216336ab849fb54a21140a921d65089c1ae Mon Sep 17 00:00:00 2001 From: stdk-scm <63764571+stdk-scm@users.noreply.github.com> Date: Wed, 6 Jan 2021 16:29:58 +0900 Subject: [PATCH 2/4] Sync-up with iot-core 1.5.6 Signed-off-by: stdk-scm <63764571+stdk-scm@users.noreply.github.com> --- iot-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iot-core b/iot-core index 3bbb40f9..3d808826 160000 --- a/iot-core +++ b/iot-core @@ -1 +1 @@ -Subproject commit 3bbb40f9ea5405be53854b22925976b53d5c42da +Subproject commit 3d808826c777b2b90ab7bb9549cbb9cb8ee5265d From eebedd228463b4b60bb05c15f7ac8ab15a8e4a00 Mon Sep 17 00:00:00 2001 From: Yongsul Oh <46733179+YongsulOh@users.noreply.github.com> Date: Thu, 14 Jan 2021 10:18:54 +0900 Subject: [PATCH 3/4] esp8266: Use CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL for all esp8266 sample apps - Current iot-core needs to use 64bits values in cJSON such as "provisioningTs" but NEWLIB_LIBRARY_LEVEL_NANO does not support 64bits value handling with sprintf so we need to change by NEWLIB_LIBRARY_LEVEL_NORMAL for all esp8266 sample apps - Also remove all unused cJSON patches for NEWLIB_LIBRARY_LEVEL_NANO's sprintf issue - This patch-set will be prevent following 'forcely assert situation' | "Library newlib of nano mode does not support double or long-long format, please enable newlib normal mode." --- apps/esp8266/light_example/sdkconfig | 4 +- apps/esp8266/switch_example/sdkconfig | 4 +- ...encode-json-number-when-sprintf-not-.patch | 102 ------------------ ...on-fix-wrong-traling-zeroes-removing.patch | 42 -------- tools/esp8266/setup_esp8266.sh | 1 - 5 files changed, 4 insertions(+), 149 deletions(-) delete mode 100644 patches/esp8266/cJSON/0001-Add-function-to-encode-json-number-when-sprintf-not-.patch delete mode 100644 patches/esp8266/cJSON/2000-cjson-fix-wrong-traling-zeroes-removing.patch diff --git a/apps/esp8266/light_example/sdkconfig b/apps/esp8266/light_example/sdkconfig index b9082c81..26d3daf8 100644 --- a/apps/esp8266/light_example/sdkconfig +++ b/apps/esp8266/light_example/sdkconfig @@ -344,8 +344,8 @@ CONFIG_MQTT_RECV_BUFFER=2048 CONFIG_MQTT_SEND_CYCLE=30000 CONFIG_MQTT_RECV_CYCLE=100 CONFIG_MQTT_PING_TIMEOUT=3000 -# CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL is not set -CONFIG_NEWLIB_LIBRARY_LEVEL_NANO=y +CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL=y +# CONFIG_NEWLIB_LIBRARY_LEVEL_NANO is not set # CONFIG_NEWLIB_LIBRARY_LEVEL_FLOAT_NANO is not set # CONFIG_NEWLIB_LIBRARY_CUSTOMER is not set # CONFIG_OPENSSL_DEBUG is not set diff --git a/apps/esp8266/switch_example/sdkconfig b/apps/esp8266/switch_example/sdkconfig index b9082c81..26d3daf8 100644 --- a/apps/esp8266/switch_example/sdkconfig +++ b/apps/esp8266/switch_example/sdkconfig @@ -344,8 +344,8 @@ CONFIG_MQTT_RECV_BUFFER=2048 CONFIG_MQTT_SEND_CYCLE=30000 CONFIG_MQTT_RECV_CYCLE=100 CONFIG_MQTT_PING_TIMEOUT=3000 -# CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL is not set -CONFIG_NEWLIB_LIBRARY_LEVEL_NANO=y +CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL=y +# CONFIG_NEWLIB_LIBRARY_LEVEL_NANO is not set # CONFIG_NEWLIB_LIBRARY_LEVEL_FLOAT_NANO is not set # CONFIG_NEWLIB_LIBRARY_CUSTOMER is not set # CONFIG_OPENSSL_DEBUG is not set diff --git a/patches/esp8266/cJSON/0001-Add-function-to-encode-json-number-when-sprintf-not-.patch b/patches/esp8266/cJSON/0001-Add-function-to-encode-json-number-when-sprintf-not-.patch deleted file mode 100644 index f0f869a6..00000000 --- a/patches/esp8266/cJSON/0001-Add-function-to-encode-json-number-when-sprintf-not-.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 18ba760179f793a154871a0167e2eda44afbe25b Mon Sep 17 00:00:00 2001 -From: Hyundo Lee <54927573+hdlee27@users.noreply.github.com> -Date: Fri, 4 Sep 2020 14:58:28 +0900 -Subject: [PATCH] Add function to encode json number when "sprintf" not - support float - -modified by refferring to following patch -: https://github.com/espressif/ESP8266_RTOS_SDK/commit/e5df03c2774748db89fdee7e67f8aa0010b22d3d -Signed-off-by: Hyundo Lee <54927573+hdlee27@users.noreply.github.com> ---- - cJSON.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- - 1 file changed, 59 insertions(+), 1 deletion(-) - -diff --git a/cJSON.c b/cJSON.c -index 60b72c0..91f9ac1 100644 ---- a/cJSON.c -+++ b/cJSON.c -@@ -55,6 +55,14 @@ - #pragma GCC visibility pop - #endif - -+#ifndef CJSON_SPRINTF_FLOAT -+#define CJSON_SPRINTF_FLOAT 0 -+#endif -+ -+#if !CJSON_SPRINTF_FLOAT -+#include -+#endif -+ - #include "cJSON.h" - - /* define our own boolean type */ -@@ -503,6 +511,7 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out - } - else - { -+#if CJSON_SPRINTF_FLOAT - /* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */ - length = sprintf((char*)number_buffer, "%1.15g", d); - -@@ -512,8 +521,57 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out - /* If not, print with 17 decimal places of precision */ - length = sprintf((char*)number_buffer, "%1.17g", d); - } -- } -+#else -+ long long d64 = (long long)d; -+ long d32 = (long)d; -+ -+ /** -+ * Check if 32-bit type data is overflow. -+ */ -+ assert(d32 == d64 && "Library newlib of nano mode does not support double or long-long format, please enable newlib normal mode."); -+ -+ length = sprintf((char*)number_buffer, "%ld", d32); -+ -+ if ((double)d32 != d) { -+ size_t precision = 14; -+ unsigned char *pbuf = number_buffer; -+ -+ if (d < 0.0) { -+ d = (double)d32 - d + 0.00000000000001; -+ } else { -+ d = d - (double)d32; -+ } -+ -+ pbuf = &number_buffer[length]; -+ *pbuf++ = '.'; -+ length++; - -+ while (d > 0.0 && precision--) { -+ d *= 10.0; -+ unsigned char tmp = (unsigned char)d; -+ -+ *pbuf++ = tmp + '0'; -+ length++; -+ -+ d -= (double)tmp; -+ } -+ -+ pbuf = &number_buffer[length - 1]; -+ -+ while (*pbuf == '0') { -+ pbuf--; -+ length--; -+ } -+ -+ if (*pbuf == '.') { -+ pbuf--; -+ length--; -+ } -+ -+ *++pbuf = 0; -+ } -+#endif -+ } - /* sprintf failed or buffer overrun occurred */ - if ((length < 0) || (length > (int)(sizeof(number_buffer) - 1))) - { --- -2.7.4 - diff --git a/patches/esp8266/cJSON/2000-cjson-fix-wrong-traling-zeroes-removing.patch b/patches/esp8266/cJSON/2000-cjson-fix-wrong-traling-zeroes-removing.patch deleted file mode 100644 index d60900df..00000000 --- a/patches/esp8266/cJSON/2000-cjson-fix-wrong-traling-zeroes-removing.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 6eef516b0f3b2d2c21a0e783ab4dd950ed98b2ad Mon Sep 17 00:00:00 2001 -From: Sanghee Kim -Date: Thu, 24 Oct 2019 18:58:59 +0900 -Subject: [PATCH] cjson: fix wrong traling zeroes removing - -When esp8266 set the CONFIG_NEWLIB_LIBRARY_LEVEL_NANO, -libc doesn't support double and long long type. -For this reason, following is implemented for double type. -e5df03c2 feat(cjson): Add function to encode json number when "sprintf" not support float - -However decimal point is not removed when value can be expressed as integers. - -Following is error case, -7.00000000000000088817 -> -7.00000000000000 -> -7. -'7.' is wrong '7' is right. - -Signed-off-by: Sanghee Kim ---- - cJSON.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/cJSON.c b/cJSON.c -index 5f167bf1..46e0ae8e 100644 ---- a/cJSON.c -+++ b/cJSON.c -@@ -555,6 +555,11 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out - length--; - } - -+ if (*pbuf == '.') { -+ pbuf--; -+ length--; -+ } -+ - *++pbuf = 0; - } - #endif --- -2.17.1 - diff --git a/tools/esp8266/setup_esp8266.sh b/tools/esp8266/setup_esp8266.sh index 05acb453..b313d075 100755 --- a/tools/esp8266/setup_esp8266.sh +++ b/tools/esp8266/setup_esp8266.sh @@ -35,6 +35,5 @@ git submodule update --init --recursive git submodule foreach --recursive git reset --hard apply_patch ${BSP_PATH} ${PATCH_PATH} -apply_patch ${BSP_PATH}/components/json/cJSON ${PATCH_PATH}/cJSON apply_patch ${BSP_PATH}/components/mbedtls/mbedtls ${PATCH_PATH}/mbedtls From cd74d74b37920dcfdea975cb05e498a094673470 Mon Sep 17 00:00:00 2001 From: stdk-scm <63764571+stdk-scm@users.noreply.github.com> Date: Wed, 20 Jan 2021 16:36:09 +0900 Subject: [PATCH 4/4] Sync-up with iot-core 1.5.7 Signed-off-by: stdk-scm <63764571+stdk-scm@users.noreply.github.com> --- iot-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iot-core b/iot-core index 3d808826..5584eddc 160000 --- a/iot-core +++ b/iot-core @@ -1 +1 @@ -Subproject commit 3d808826c777b2b90ab7bb9549cbb9cb8ee5265d +Subproject commit 5584eddcf17c14f175ce73090e612d741eca3b98