Skip to content

Commit

Permalink
Fixed ESP8266 core v2.x.x compilation error.
Browse files Browse the repository at this point in the history
  • Loading branch information
mobizt committed Apr 15, 2022
1 parent 7f82959 commit c77b7bb
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 302 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Firebase Arduino Client Library for ESP8266 and ESP32",
"version": "3.1.5",
"version": "3.1.6",
"keywords": "communication, REST, esp32, esp8266, arduino",
"description": "The library supports Firebase products e.g. Realtime database, Cloud Firestore database, Firebase Storage and Google Cloud Storage, Cloud Functions for Firebase and Cloud Messaging. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.",
"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=Firebase Arduino Client Library for ESP8266 and ESP32

version=3.1.5
version=3.1.6

author=Mobizt

Expand Down
17 changes: 10 additions & 7 deletions src/FB_Utils.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Google's Firebase Util class, FB_Utils.h version 1.1.16
* Google's Firebase Util class, FB_Utils.h version 1.1.17
*
* This library supports Espressif ESP8266 and ESP32
*
* Created March 7, 2022
* Created April 15, 2022
*
* This work is a part of Firebase ESP Client library
* Copyright (c) 2022 K. Suwatchai (Mobizt)
Expand Down Expand Up @@ -35,6 +35,9 @@

#include <Arduino.h>
#include "FB_Const.h"
#if defined(ESP8266)
#include <Schedule.h>
#endif
using namespace mb_string;

class UtilsClass
Expand Down Expand Up @@ -1154,12 +1157,12 @@ class UtilsClass

#if defined(ESP32) || defined(ESP8266)

if (time(nullptr) > default_ts && gmtOffset == config->internal.fb_gmt_offset)
if ((unsigned long)time(nullptr) > default_ts && gmtOffset == config->internal.fb_gmt_offset)
return true;

time_t now = time(nullptr);

config->internal.fb_clock_rdy = now > default_ts;
config->internal.fb_clock_rdy = (unsigned long)now > default_ts;

if (!config->internal.fb_clock_rdy || gmtOffset != config->internal.fb_gmt_offset)
{
Expand All @@ -1174,18 +1177,18 @@ class UtilsClass

now = time(nullptr);
unsigned long timeout = millis();
while (now < default_ts)
while ((unsigned long)now < default_ts)
{
now = time(nullptr);
if (now > default_ts || millis() - timeout > ntpTimeout)
if ((unsigned long)now > default_ts || millis() - timeout > ntpTimeout)
break;
delay(0);
}

idle();
}

config->internal.fb_clock_rdy = now > default_ts;
config->internal.fb_clock_rdy = (unsigned long)now > default_ts;
if (config->internal.fb_clock_rdy)
config->internal.fb_gmt_offset = gmtOffset;

Expand Down
8 changes: 4 additions & 4 deletions src/Firebase_ESP_Client.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#ifndef FIREBASE_CLIENT_VERSION
#define FIREBASE_CLIENT_VERSION "3.1.5"
#define FIREBASE_CLIENT_VERSION "3.1.6"
#endif

/**
* Google's Firebase ESP Client Main class, Firebase_ESP_Client.h v3.1.5
* Google's Firebase ESP Client Main class, Firebase_ESP_Client.h v3.1.6
*
* This library supports Espressif ESP8266 and ESP32 MCUs
*
* Created March 5, 2022
* Created April 15, 2022
*
* Updates:
* - Fixed compile error for FirebaseJsonArray remove.
* - Fixed ESP8266 core v2.x.x compilation error.
*
*
* This work is a part of Firebase ESP Client library
Expand Down
4 changes: 2 additions & 2 deletions src/json/FirebaseJson.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* FirebaseJson, version 2.6.14
* FirebaseJson, version 2.6.15
*
* The Easiest Arduino library to parse, create and edit JSON object using a relative path.
*
* Created March 5, 2022
* Created April 15, 2022
*
* Features
* - Using path to access node element in search style e.g. json.get(result,"a/b/c")
Expand Down
10 changes: 2 additions & 8 deletions src/json/FirebaseJson.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* FirebaseJson, version 2.6.14
* FirebaseJson, version 2.6.15
*
* The Easiest Arduino library to parse, create and edit JSON object using a relative path.
*
* Created March 5, 2022
* Created April 15, 2022
*
* Features
* - Using path to access node element in search style e.g. json.get(result,"a/b/c")
Expand Down Expand Up @@ -87,13 +87,7 @@

using namespace mb_string;

#if defined __has_include
#if __has_include(<Client.h>)
#include <Client.h>
#endif
#else
#include <Client.h>
#endif

#ifdef __cplusplus
extern "C"
Expand Down
30 changes: 15 additions & 15 deletions src/json/MB_JSON/MB_JSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MB_JSON.c v1.0.1 based on the modified version of cJSON.c v1.7.14 (Sept 3, 2020)
All original static cJSON functions and static variables will be prefixed with MB_JSON_.
Created December 20, 2022
Copyright (c) 2022 Mobizt (K. Suwatchai)
Expand Down Expand Up @@ -1685,11 +1685,11 @@ MB_JSON_bool MB_JSON_get_array_buffer_length(const MB_JSON *const item, MB_JSON_

buf_len->depth++;

// add newline and tab after [
//add newline and tab after [
if (buf_len->format)
{
// '\n';
buf_len->size += 1;
buf_len->size+= 1;
//'\t';
buf_len->size += buf_len->depth;
}
Expand All @@ -1714,7 +1714,7 @@ MB_JSON_bool MB_JSON_get_array_buffer_length(const MB_JSON *const item, MB_JSON_

buf_len->depth--;

// add newline and tab before ]
//add newline and tab before ]
if (buf_len->format)
{
//'\n';
Expand Down Expand Up @@ -1754,7 +1754,7 @@ static MB_JSON_bool MB_JSON_print_array(const MB_JSON *const item, MB_JSON_print
output_buffer->offset++;
output_buffer->depth++;

// add newline and tab after [
//add newline and tab after [
if (output_buffer->format)
{
output_pointer = MB_JSON_ensure(output_buffer, 2);
Expand Down Expand Up @@ -1794,7 +1794,7 @@ static MB_JSON_bool MB_JSON_print_array(const MB_JSON *const item, MB_JSON_print
return false;
}
*output_pointer++ = ',';
// add newline and tab after ,
//add newline and tab after ,
if (output_buffer->format)
{
*output_pointer++ = '\n';
Expand Down Expand Up @@ -1828,7 +1828,7 @@ static MB_JSON_bool MB_JSON_print_array(const MB_JSON *const item, MB_JSON_print
}
output_buffer->depth--;

// add newline and tab before ]
//add newline and tab before ]
if (output_buffer->format)
{
output_pointer = MB_JSON_ensure(output_buffer, 2);
Expand Down Expand Up @@ -1977,9 +1977,9 @@ static MB_JSON_bool MB_JSON_get_object_buffer_length(const MB_JSON *const item,
MB_JSON *current_item = item->child;

//'{' or "{\n"
length = (size_t)(buf_len->format && current_item != NULL ? 2 : 1);
length = (size_t)(buf_len->format && current_item != NULL ? 2 : 1);

// do nothing for empty object
//do nothing for empty object
if (current_item != NULL)
{
buf_len->depth++;
Expand Down Expand Up @@ -2047,7 +2047,7 @@ static MB_JSON_bool MB_JSON_print_object(const MB_JSON *const item, MB_JSON_prin

*output_pointer++ = '{';

// do nothing for empty object
//do nothing for empty object
if (current_item != NULL)
{
output_buffer->depth++;
Expand Down Expand Up @@ -2668,9 +2668,9 @@ MB_JSON_ReplaceItemViaPointer(MB_JSON *const parent, MB_JSON *const item, MB_JSO
}
else
{ /*
* To find the last item in array quickly, we use prev in array.
* We can't modify the last item's next pointer where this item was the parent's child
*/
* To find the last item in array quickly, we use prev in array.
* We can't modify the last item's next pointer where this item was the parent's child
*/
if (replacement->prev != NULL)
{
replacement->prev->next = replacement;
Expand Down Expand Up @@ -3476,7 +3476,7 @@ MB_JSON_Compare(const MB_JSON *const a, const MB_JSON *const b, const MB_JSON_bo
}

/* doing this twice, once on a and b to prevent true comparison if a subset of b
* TODO: Do this the proper way, this is just a fix for now */
* TODO: Do this the proper way, this is just a fix for now */
MB_JSON_ArrayForEach(b_element, b)
{
a_element = MB_JSON_get_object_item(a, b_element->string, case_sensitive);
Expand Down Expand Up @@ -3511,4 +3511,4 @@ MB_JSON_free(void *object)
MB_JSON_global_hooks.deallocate(object);
}

#endif // MB_JSON_C
#endif //MB_JSON_C
Loading

0 comments on commit c77b7bb

Please sign in to comment.