Skip to content

Commit

Permalink
Fix Firebase Realtime database Boolean issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Apr 10, 2024
1 parent 6cd3f65 commit 2aae95a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=FirebaseClient

version=1.0.14
version=1.0.15

author=Mobizt

Expand Down
2 changes: 1 addition & 1 deletion src/FirebaseClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#undef FIREBASE_CLIENT_VERSION
#endif

#define FIREBASE_CLIENT_VERSION "1.0.14"
#define FIREBASE_CLIENT_VERSION "1.0.15"

#include <Arduino.h>
#include "./core/FirebaseApp.h"
Expand Down
27 changes: 17 additions & 10 deletions src/core/AsyncResult/Value.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Created April 7, 2024
* Created April 10, 2024
*
* The MIT License (MIT)
* Copyright (c) 2024 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -200,7 +200,7 @@ class ValueConverter
{
static bool const value = std::is_same<T, uint64_t>::value || std::is_same<T, int64_t>::value || std::is_same<T, uint32_t>::value || std::is_same<T, int32_t>::value ||
std::is_same<T, uint16_t>::value || std::is_same<T, int16_t>::value || std::is_same<T, uint8_t>::value || std::is_same<T, int8_t>::value ||
std::is_same<T, double>::value || std::is_same<T, float>::value || std::is_same<T, bool>::value || std::is_same<T, int>::value;
std::is_same<T, double>::value || std::is_same<T, float>::value || std::is_same<T, int>::value;
};

template <typename T = object_t>
Expand All @@ -210,18 +210,25 @@ class ValueConverter
}

template <typename T = const char *>
auto getVal(String &buf, T value) -> typename std::enable_if<(v_number<T>::value || v_sring<T>::value) && !std::is_same<T, object_t>::value && !std::is_same<T, string_t>::value && !std::is_same<T, boolean_t>::value && !std::is_same<T, number_t>::value, void>::type
auto getVal(String &buf, T value) -> typename std::enable_if<(v_number<T>::value || v_sring<T>::value || std::is_same<T, bool>::value) && !std::is_same<T, object_t>::value && !std::is_same<T, string_t>::value && !std::is_same<T, boolean_t>::value && !std::is_same<T, number_t>::value, void>::type
{
buf = "";
if (v_sring<T>::value)
buf += '\"';
buf += value;
if (v_sring<T>::value)
buf += '\"';
buf.remove(0, buf.length());
if (std::is_same<T, bool>::value)
{
buf = value ? "true" : "false";
}
else
{
if (v_sring<T>::value)
buf += '\"';
buf += value;
if (v_sring<T>::value)
buf += '\"';
}
}

template <typename T>
auto to(const char *payload) -> typename std::enable_if<v_number<T>::value, T>::type
auto to(const char *payload) -> typename std::enable_if<v_number<T>::value || std::is_same<T, bool>::value, T>::type
{
if (!useLength && strlen(payload) > 0)
{
Expand Down

0 comments on commit 2aae95a

Please sign in to comment.