FirebaseClient. Error compiling ESP8266 code

I have an ESP8266 running a code that saves data from a weather station on Firebase.

On November 6th, I started getting errors when accessing Firebase.

I checked and found that there had been changes in the access and authentication of the aforementioned site.

After some research, I realized that the Firebase access library I was using had become obsolete.

I installed the new library and started using its examples to understand what the data I would need to provide to re-access Firebase would be like.

But every example I try to use gives me a compilation error.

The new library I am referring to is:

" GitHub - mobizt/FirebaseClient: 🔥Async Firebase Client for Arduino. Supports Realtime Database, Cloud Firestore Database, Firebase Storage, Cloud Messaging, Google Cloud Functions and Google Cloud Storage.

and I am trying the SimpleNoAuth.ino example.

My IDE is on version 1.8.9

In all examples the error occurs due to this line:

"
C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/AsyncResult.h:55:1: error: expected class-name before '{' token

{

^
"
I did not find any topic in the forum or on the WEB reporting this specific problem.

Could this error be occurring because I use version 1.8.9 of the IDE?
Am I missing any other library to be included?
Has anyone had this type of problem with this library?

Below is the example code and the list of errors when compiling the example: SimpleNoAuth.ino

Code:

/**
 * This example is for new users which are familiar with other legacy Firebase libraries.
 *
 * The example shows how to set, push and get the values to/from Realtime database.
 *
 * All functions used in this example are blocking (sync) functions.
 *
 * This example will use the database secret for priviledge Realtime database access which does not need
 * to change the security rules or it can access Realtime database no matter what the security rules are set.
 *
 * This example is for ESP32, ESP8266 and Raspberry Pi Pico W.
 *
 * You can adapt the WiFi and SSL client library that are available for your devices.
 *
 * For the ethernet and GSM network which are not covered by this example,
 * you have to try another elaborate examples and read the library documentation thoroughly.
 *
 */

/** Change your Realtime database security rules as the following.
 {
  "rules": {
    ".read": true,
    ".write": true
  }
}
*/

#include <Arduino.h>
#if defined(ESP32) || defined(ARDUINO_RASPBERRY_PI_PICO_W)
#include <WiFi.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#endif

#include <FirebaseClient.h>
#include <WiFiClientSecure.h>

#define WIFI_SSID "WIFI_AP"
#define WIFI_PASSWORD "WIFI_PASSWORD"

#define DATABASE_URL "URL"

WiFiClientSecure ssl;
DefaultNetwork network;
AsyncClientClass client(ssl, getNetwork(network));

FirebaseApp app;
RealtimeDatabase Database;
AsyncResult result;
NoAuth noAuth;

void printError(int code, const String &msg)
{
    Firebase.printf("Error, msg: %s, code: %d\n", msg.c_str(), code);
}

void setup()
{

    Serial.begin(115200);
    WiFi.begin(WIFI_SSID, WIFI_PASSWORD);

    Serial.print("Connecting to Wi-Fi");
    while (WiFi.status() != WL_CONNECTED)
    {
        Serial.print(".");
        delay(300);
    }
    Serial.println();
    Serial.print("Connected with IP: ");
    Serial.println(WiFi.localIP());
    Serial.println();

    Firebase.printf("Firebase Client v%s\n", FIREBASE_CLIENT_VERSION);

    ssl.setInsecure();
#if defined(ESP8266)
    ssl.setBufferSizes(1024, 1024);
#endif

    // Initialize the authentication handler.
    initializeApp(client, app, getAuth(noAuth));

    // Binding the authentication handler with your Database class object.
    app.getApp<RealtimeDatabase>(Database);

    // Set your database URL
    Database.url(DATABASE_URL);

    // In sync functions, we have to set the operating result for the client that works with the function.
    client.setAsyncResult(result);

    // Set, push and get integer value

    Serial.print("Set int... ");
    bool status = Database.set<int>(client, "/test/int", 12345);
    if (status)
        Serial.println("ok");
    else
        printError(client.lastError().code(), client.lastError().message());

    Serial.print("Push int... ");
    String name = Database.push<int>(client, "/test/push", 12345);
    if (client.lastError().code() == 0)
        Firebase.printf("ok, name: %s\n", name.c_str());
    else
        printError(client.lastError().code(), client.lastError().message());

    Serial.print("Get int... ");
    int v1 = Database.get<int>(client, "/test/int");
    if (client.lastError().code() == 0)
        Serial.println(v1);
    else
        printError(client.lastError().code(), client.lastError().message());

    // Set, push and get Boolean value

    Serial.print("Set bool... ");
    status = Database.set<bool>(client, "/test/bool", true);
    if (status)
        Serial.println("ok");
    else
        printError(client.lastError().code(), client.lastError().message());

    Serial.print("Push bool... ");
    String name = Database.push<bool>(client, "/test/push", true);
    if (client.lastError().code() == 0)
        Firebase.printf("ok, name: %s\n", name.c_str());

    Serial.print("Get bool... ");
    bool v2 = Database.get<bool>(client, "/test/bool");
    if (client.lastError().code() == 0)
        Serial.println(v2);
    else
        printError(client.lastError().code(), client.lastError().message());

    // Set, push, and get String value

    Serial.print("Set string... ");
    status = Database.set<String>(client, "/test/string", "hello");
    if (status)
        Serial.println("ok");
    else
        printError(client.lastError().code(), client.lastError().message());

    Serial.print("Push String... ");
    String name = Database.push<String>(client, "/test/push", "hello");
    if (client.lastError().code() == 0)
        Firebase.printf("ok, name: %s\n", name.c_str());

    Serial.print("Get string... ");
    String v3 = Database.get<String>(client, "/test/string");
    if (client.lastError().code() == 0)
        Serial.println(v3);
    else
        printError(client.lastError().code(), client.lastError().message());

    // Set, push, and get float value

    Serial.print("Set float... ");
    status = Database.set<number_t>(client, "/test/float", number_t(123.456, 2));
    if (status)
        Serial.println("ok");
    else
        printError(client.lastError().code(), client.lastError().message());

    Serial.print("Push float... ");
    String name = Database.push<number_t>(client, "/test/push", number_t(123.456, 2));
    if (client.lastError().code() == 0)
        Firebase.printf("ok, name: %s\n", name.c_str());

    Serial.print("Get float... ");
    float v4 = Database.get<float>(client, "/test/float");
    if (client.lastError().code() == 0)
        Serial.println(v4);
    else
        printError(client.lastError().code(), client.lastError().message());

    // Set, push, and get double value

    Serial.print("Set double... ");
    status = Database.set<number_t>(client, "/test/double", number_t(1234.56789, 4));
    if (status)
        Serial.println("ok");
    else
        printError(client.lastError().code(), client.lastError().message());

    Serial.print("Push double... ");
    String name = Database.push<number_t>(client, "/test/push", number_t(1234.56789, 4));
    if (client.lastError().code() == 0)
        Firebase.printf("ok, name: %s\n", name.c_str());

    Serial.print("Get double... ");
    double v5 = Database.get<double>(client, "/test/double");
    if (client.lastError().code() == 0)
        Serial.println(v5);
    else
        printError(client.lastError().code(), client.lastError().message());

    // Set, push, and get JSON value

    Serial.print("Set JSON... ");
    status = Database.set<object_t>(client, "/test/json", object_t("{\"test\":{\"data\":123}}"));
    if (status)
        Serial.println("ok");
    else
        printError(client.lastError().code(), client.lastError().message());

    Serial.print("Push JSON... ");
    String name = Database.push<object_t>(client, "/test/push", object_t("{\"test\":{\"data\":123}}"));
    if (client.lastError().code() == 0)
        Firebase.printf("ok, name: %s\n", name.c_str());

    Serial.print("Get JSON... ");
    String v6 = Database.get<String>(client, "/test/json");
    if (client.lastError().code() == 0)
        Serial.println(v6);
    else
        printError(client.lastError().code(), client.lastError().message());

    // Set, push and get Array value

    Serial.print("Set Array... ");
    status = Database.set<object_t>(client, "/test/array", object_t("[1,2,\"test\",true]"));
    if (status)
        Serial.println("ok");
    else
        printError(client.lastError().code(), client.lastError().message());

    Serial.print("Push Array... ");
    String name = Database.push<object_t>(client, "/test/push", object_t("[1,2,\"test\",true]"));
    if (client.lastError().code() == 0)
        Firebase.printf("ok, name: %s\n", name.c_str());

    Serial.print("Get Array... ");
    String v7 = Database.get<String>(client, "/test/array");
    if (client.lastError().code() == 0)
        Serial.println(v7);
    else
        printError(client.lastError().code(), client.lastError().message());
}

void loop()
{
    // We don't need to poll the async task using Database.loop(); as in the Stream examples because
    // only blocking (sync) functions were used in this example.

    // We don't have to poll authentication handler task using app.loop() as seen in other examples
    // because the database secret is the priviledge access key that never expired.
}

Erro printout:

Arduino: 1.8.9 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

In file included from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AuthConfig.h:31:0,

                 from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/FirebaseApp.h:29,

                 from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/FirebaseClient.h:32,

                 from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\examples\RealtimeDatabase\Simple\SimpleNoAuth\SimpleNoAuth.ino:36:

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/AsyncResult.h:55:1: error: expected class-name before '{' token

 {

 ^

In file included from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AuthConfig.h:31:0,

                 from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/FirebaseApp.h:29,

                 from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/FirebaseClient.h:32,

                 from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\examples\RealtimeDatabase\Simple\SimpleNoAuth\SimpleNoAuth.ino:36:

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/AsyncResult.h: In member function 'T& AsyncResult::to()':

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/AsyncResult.h:293:29: error: 'RealtimeDatabaseResult' was not declared in this scope

         if (std::is_same<T, RealtimeDatabaseResult>::value)

                             ^

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/AsyncResult.h:293:51: error: template argument 2 is invalid

         if (std::is_same<T, RealtimeDatabaseResult>::value)

                                                   ^

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/AsyncResult.h:294:20: error: 'rtdbResult' was not declared in this scope

             return rtdbResult;

                    ^

In file included from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncClient/AsyncClient.h:39:0,

                 from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/FirebaseApp.h:30,

                 from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/FirebaseClient.h:32,

                 from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\examples\RealtimeDatabase\Simple\SimpleNoAuth\SimpleNoAuth.ino:36:

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/RTDBResultBase.h: At global scope:

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/RTDBResultBase.h:34:5: error: expected class-name before '{' token

     {

     ^

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/RTDBResultBase.h:41:32: error: 'RealtimeDatabaseResult' has not been declared

         void setNullETagOption(RealtimeDatabaseResult *rtdbResult, bool val)

                                ^

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/RTDBResultBase.h:46:38: error: 'RealtimeDatabaseResult' does not name a type

         bool getNullETagOption(const RealtimeDatabaseResult *rtdbResult)

                                      ^

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/RTDBResultBase.h:46:62: error: ISO C++ forbids declaration of 'rtdbResult' with no type [-fpermissive]

         bool getNullETagOption(const RealtimeDatabaseResult *rtdbResult)

                                                              ^

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/RTDBResultBase.h:51:28: error: 'RealtimeDatabaseResult' has not been declared

         void setRefPayload(RealtimeDatabaseResult *rtdbResult, String *payload)

                            ^

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/RTDBResultBase.h: In member function 'void firebase::RTDBResultBase::setNullETagOption(int*, bool)':

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/RTDBResultBase.h:43:25: error: request for member 'null_etag' in '* rtdbResult', which is of non-class type 'int'

             rtdbResult->null_etag = val;

                         ^

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/RTDBResultBase.h: In member function 'bool firebase::RTDBResultBase::getNullETagOption(const int*)':

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/RTDBResultBase.h:48:32: error: request for member 'null_etag' in '* rtdbResult', which is of non-class type 'const int'

             return rtdbResult->null_etag;

                                ^

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/RTDBResultBase.h: In member function 'void firebase::RTDBResultBase::setRefPayload(int*, String*)':

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/AsyncResult/RTDBResultBase.h:53:25: error: request for member 'ref_payload' in '* rtdbResult', which is of non-class type 'int'

             rtdbResult->ref_payload = payload;

                         ^

In file included from C:\Users\ruilv\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Arduino.h:31:0,

                 from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\examples\RealtimeDatabase\Simple\SimpleNoAuth\SimpleNoAuth.ino:29:

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/JSON.h: In member function 'void JsonWriter::join(object_t&, int, ...)':

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/JSON.h:196:22: error: cannot receive objects of non-trivially-copyable type 'struct object_t' through '...'; 

         object_t p = va_arg(ap, object_t);

                      ^

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\src/./core/JSON.h:209:17: error: cannot receive objects of non-trivially-copyable type 'struct object_t' through '...'; 

             p = va_arg(ap, object_t);

                 ^

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\examples\RealtimeDatabase\Simple\SimpleNoAuth\SimpleNoAuth.ino: At global scope:

SimpleNoAuth:49:1: error: 'RealtimeDatabase' does not name a type

 RealtimeDatabase Database;

 ^

C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\examples\RealtimeDatabase\Simple\SimpleNoAuth\SimpleNoAuth.ino: In function 'void setup()':

SimpleNoAuth:86:16: error: 'RealtimeDatabase' was not declared in this scope

     app.getApp<RealtimeDatabase>(Database);

                ^

SimpleNoAuth:86:34: error: 'Database' was not declared in this scope

     app.getApp<RealtimeDatabase>(Database);

                                  ^

SimpleNoAuth:97:32: error: expected primary-expression before 'int'

     bool status = Database.set<int>(client, "/test/int", 12345);

                                ^

SimpleNoAuth:104:33: error: expected primary-expression before 'int'

     String name = Database.push<int>(client, "/test/push", 12345);

                                 ^

SimpleNoAuth:111:27: error: expected primary-expression before 'int'

     int v1 = Database.get<int>(client, "/test/int");

                           ^

In file included from C:\Users\ruilv\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Arduino.h:29:0,

                 from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\examples\RealtimeDatabase\Simple\SimpleNoAuth\SimpleNoAuth.ino:29:

SimpleNoAuth:120:27: error: expected primary-expression before 'bool'

     status = Database.set<bool>(client, "/test/bool", true);

                           ^

SimpleNoAuth:120:27: error: expected ';' before 'bool'

SimpleNoAuth:127:12: error: redeclaration of 'String name'

     String name = Database.push<bool>(client, "/test/push", true);

            ^

SimpleNoAuth:104:12: error: 'String name' previously declared here

     String name = Database.push<int>(client, "/test/push", 12345);

            ^

In file included from C:\Users\ruilv\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266/Arduino.h:29:0,

                 from C:\Users\ruilv\Documents\Arduino\libraries\FirebaseClient\examples\RealtimeDatabase\Simple\SimpleNoAuth\SimpleNoAuth.ino:29:

SimpleNoAuth:127:33: error: expected primary-expression before 'bool'

     String name = Database.push<bool>(client, "/test/push", true);

                                 ^

SimpleNoAuth:132:28: error: expected primary-expression before 'bool'

     bool v2 = Database.get<bool>(client, "/test/bool");

                            ^

SimpleNoAuth:141:33: error: expected primary-expression before '>' token

     status = Database.set<String>(client, "/test/string", "hello");

                                 ^

SimpleNoAuth:148:12: error: redeclaration of 'String name'

     String name = Database.push<String>(client, "/test/push", "hello");

            ^

SimpleNoAuth:104:12: error: 'String name' previously declared here

     String name = Database.push<int>(client, "/test/push", 12345);

            ^

SimpleNoAuth:148:39: error: expected primary-expression before '>' token

     String name = Database.push<String>(client, "/test/push", "hello");

                                       ^

SimpleNoAuth:153:36: error: expected primary-expression before '>' token

     String v3 = Database.get<String>(client, "/test/string");

                                    ^

SimpleNoAuth:162:35: error: expected primary-expression before '>' token

     status = Database.set<number_t>(client, "/test/float", number_t(123.456, 2));

                                   ^

SimpleNoAuth:169:12: error: redeclaration of 'String name'

     String name = Database.push<number_t>(client, "/test/push", number_t(123.456, 2));

            ^

SimpleNoAuth:104:12: error: 'String name' previously declared here

     String name = Database.push<int>(client, "/test/push", 12345);

            ^

SimpleNoAuth:169:41: error: expected primary-expression before '>' token

     String name = Database.push<number_t>(client, "/test/push", number_t(123.456, 2));

                                         ^

SimpleNoAuth:174:29: error: expected primary-expression before 'float'

     float v4 = Database.get<float>(client, "/test/float");

                             ^

SimpleNoAuth:183:35: error: expected primary-expression before '>' token

     status = Database.set<number_t>(client, "/test/double", number_t(1234.56789, 4));

                                   ^

SimpleNoAuth:190:12: error: redeclaration of 'String name'

     String name = Database.push<number_t>(client, "/test/push", number_t(1234.56789, 4));

            ^

SimpleNoAuth:104:12: error: 'String name' previously declared here

     String name = Database.push<int>(client, "/test/push", 12345);

            ^

SimpleNoAuth:190:41: error: expected primary-expression before '>' token

     String name = Database.push<number_t>(client, "/test/push", number_t(1234.56789, 4));

                                         ^

SimpleNoAuth:195:30: error: expected primary-expression before 'double'

     double v5 = Database.get<double>(client, "/test/double");

                              ^

SimpleNoAuth:204:35: error: expected primary-expression before '>' token

     status = Database.set<object_t>(client, "/test/json", object_t("{\"test\":{\"data\":123}}"));

                                   ^

SimpleNoAuth:211:12: error: redeclaration of 'String name'

     String name = Database.push<object_t>(client, "/test/push", object_t("{\"test\":{\"data\":123}}"));

            ^

SimpleNoAuth:104:12: error: 'String name' previously declared here

     String name = Database.push<int>(client, "/test/push", 12345);

            ^

SimpleNoAuth:211:41: error: expected primary-expression before '>' token

     String name = Database.push<object_t>(client, "/test/push", object_t("{\"test\":{\"data\":123}}"));

                                         ^

SimpleNoAuth:216:36: error: expected primary-expression before '>' token

     String v6 = Database.get<String>(client, "/test/json");

                                    ^

SimpleNoAuth:225:35: error: expected primary-expression before '>' token

     status = Database.set<object_t>(client, "/test/array", object_t("[1,2,\"test\",true]"));

                                   ^

SimpleNoAuth:232:12: error: redeclaration of 'String name'

     String name = Database.push<object_t>(client, "/test/push", object_t("[1,2,\"test\",true]"));

            ^

SimpleNoAuth:104:12: error: 'String name' previously declared here

     String name = Database.push<int>(client, "/test/push", 12345);

            ^

SimpleNoAuth:232:41: error: expected primary-expression before '>' token

     String name = Database.push<object_t>(client, "/test/push", object_t("[1,2,\"test\",true]"));

                                         ^

SimpleNoAuth:237:36: error: expected primary-expression before '>' token

     String v7 = Database.get<String>(client, "/test/array");

                                    ^

exit status 1
'RealtimeDatabase' does not name a type

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Nothing to do with the IDE. No missing library. I am getting different error than you. Yours appears to be a damaged file, try deleting that and getting the sample again or even try a different example, very rarely an example is flawed. I will try some others.

I downloaded the library and tried to compile the same sketch as you. There is one error, the redeclaration of a String variable. This happens a few times. Not sure why. You should delete the library you downloaded and just install it from the Library Manager (see pic) but it may still have issues. I have never seen a library with so many warnings, that would concern me. The same error happens on at least one other sample I tried. Something is very weird. You will need to submit an issue to the github repository to get the bugs fixed.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.