From 2aae95ae4a2771fec7048910c22523d31a6d3894 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 10 Apr 2024 18:13:42 +0700 Subject: [PATCH] Fix Firebase Realtime database Boolean issue. --- library.json | 2 +- library.properties | 2 +- src/FirebaseClient.h | 2 +- src/core/AsyncResult/Value.h | 27 +++++++++++++++++---------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/library.json b/library.json index 9584dfd7..c35349fd 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "FirebaseClient", - "version": "1.0.14", + "version": "1.0.15", "keywords": "communication, REST, esp32, esp8266, arduino", "description": "Async Firebase Client library for Arduino.", "repository": { diff --git a/library.properties b/library.properties index 6ca2470e..f2d48601 100644 --- a/library.properties +++ b/library.properties @@ -1,6 +1,6 @@ name=FirebaseClient -version=1.0.14 +version=1.0.15 author=Mobizt diff --git a/src/FirebaseClient.h b/src/FirebaseClient.h index 6cf39973..c8adfd14 100644 --- a/src/FirebaseClient.h +++ b/src/FirebaseClient.h @@ -30,7 +30,7 @@ #undef FIREBASE_CLIENT_VERSION #endif -#define FIREBASE_CLIENT_VERSION "1.0.14" +#define FIREBASE_CLIENT_VERSION "1.0.15" #include #include "./core/FirebaseApp.h" diff --git a/src/core/AsyncResult/Value.h b/src/core/AsyncResult/Value.h index 57623837..4b7aeb51 100644 --- a/src/core/AsyncResult/Value.h +++ b/src/core/AsyncResult/Value.h @@ -1,5 +1,5 @@ /** - * Created April 7, 2024 + * Created April 10, 2024 * * The MIT License (MIT) * Copyright (c) 2024 K. Suwatchai (Mobizt) @@ -200,7 +200,7 @@ class ValueConverter { static bool const value = std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || - std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value; + std::is_same::value || std::is_same::value || std::is_same::value; }; template @@ -210,18 +210,25 @@ class ValueConverter } template - auto getVal(String &buf, T value) -> typename std::enable_if<(v_number::value || v_sring::value) && !std::is_same::value && !std::is_same::value && !std::is_same::value && !std::is_same::value, void>::type + auto getVal(String &buf, T value) -> typename std::enable_if<(v_number::value || v_sring::value || std::is_same::value) && !std::is_same::value && !std::is_same::value && !std::is_same::value && !std::is_same::value, void>::type { - buf = ""; - if (v_sring::value) - buf += '\"'; - buf += value; - if (v_sring::value) - buf += '\"'; + buf.remove(0, buf.length()); + if (std::is_same::value) + { + buf = value ? "true" : "false"; + } + else + { + if (v_sring::value) + buf += '\"'; + buf += value; + if (v_sring::value) + buf += '\"'; + } } template - auto to(const char *payload) -> typename std::enable_if::value, T>::type + auto to(const char *payload) -> typename std::enable_if::value || std::is_same::value, T>::type { if (!useLength && strlen(payload) > 0) {