mobizt / FirebaseClient

🔥Async Firebase Client for Arduino. Supports Realtime Database, Cloud Firestore Database, Firebase Storage, Cloud Messaging, Google Cloud Functions and Google Cloud Storage.
MIT License
134 stars 8 forks source link

UserAuth' does not name a type #40

Closed pascal060 closed 7 months ago

pascal060 commented 7 months ago

Hello,

In Arduino IDE 1.8.19 I have this issue " exit status 1 'UserAuth' does not name a type" , when compiling the exemple code :

`/**

include

if defined(ESP32) || defined(ARDUINO_RASPBERRY_PI_PICO_W)

include

elif defined(ESP8266)

include

elif __has_include()

include

elif __has_include()

include

elif __has_include()

include

endif

include

define WIFI_SSID "WIFI_AP"

define WIFI_PASSWORD "WIFI_PASSWORD"

// The API key can be obtained from Firebase console > Project Overview > Project settings.

define API_KEY "Web_API_KEY"

// User Email and password that already registerd or added in your project.

define USER_EMAIL "USER_EMAIL"

define USER_PASSWORD "USER_PASSWORD"

define DATABASE_URL "URL"

void asyncCB(AsyncResult &aResult);

void printResult(AsyncResult &aResult);

DefaultNetwork network; // initilize with boolean parameter to enable/disable network reconnection

UserAuth user_auth(API_KEY, USER_EMAIL, USER_PASSWORD);

FirebaseApp app;

if defined(ESP32) || defined(ESP8266) || defined(PICO_RP2040)

include

WiFiClientSecure ssl_client;

elif defined(ARDUINO_ARCH_SAMD)

include

WiFiSSLClient ssl_client;

endif

// In case the keyword AsyncClient using in this example was ambigous and used by other library, you can change // it with other name with keyword "using" or use the class name AsyncClientClass directly.

using AsyncClient = AsyncClientClass;

AsyncClient aClient(ssl_client, getNetwork(network));

if defined(ESP32) || defined(ESP8266) || defined(PICO_RP2040)

WiFiClientSecure ssl_client2;

elif __has_include()

WiFiSSLClient ssl_client2;

endif

AsyncClient aClient2(ssl_client2, getNetwork(network));

RealtimeDatabase Database;

AsyncResult aResult_no_callback;

unsigned long ms = 0;

void setup() {

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

Serial.print("Connecting to Wi-Fi");
unsigned long ms = millis();
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);

Serial.println("Initializing app...");

if defined(ESP32) || defined(ESP8266) || defined(PICO_RP2040)

ssl_client.setInsecure();
ssl_client2.setInsecure();

if defined(ESP8266)

ssl_client.setBufferSizes(4096, 1024);
ssl_client2.setBufferSizes(4096, 1024);

endif

endif

app.setCallback(asyncCB);

initializeApp(aClient2, app, getAuth(user_auth));

// Waits for app to be authenticated.
// For asynchronous operation, this blocking wait can be ignored by calling app.loop() in loop().
ms = millis();
while (app.isInitialized() && !app.ready() && millis() - ms < 120 * 1000)
    ;

app.getApp<RealtimeDatabase>(Database);

Database.url(DATABASE_URL);

Database.get(aClient, "/test/stream", asyncCB, true /* SSE mode (HTTP Streaming) */);

// Only one Get in SSE mode (HTTP Streaming) is allowed, the operation will be cancelled if
// another Get in SSE mode (HTTP Streaming) was called.

// To get anyc result without callback
// Database.get(aClient, "/test/stream", aResult_no_callback, true /* SSE mode (HTTP Streaming) */);

// To assign UID for async result
// Database.get(aClient, "/test/stream", asyncCB, true /* SSE mode (HTTP Streaming) */, "myUID");

// To stop the async (stream) operation.
// aClient.stopAsync();

}

void loop() { // This function is required for handling async operations and maintaining the authentication tasks. app.loop();

// This required when different AsyncClients than used in FirebaseApp assigned to the Realtime database functions.
Database.loop();

if (millis() - ms > 20000 && app.ready())
{
    ms = millis();

    JsonWriter writer;

    object_t json, obj1, obj2;

    writer.create(obj1, "ms", ms);
    writer.create(obj2, "rand", random(10000, 30000));
    writer.join(json, 2, obj1, obj2);

    Database.set<object_t>(aClient2, "/test/stream/number", json, asyncCB);

    // When the async operation queue was full, the operation will be cancelled for new sync and async operation.
    // When the async operation was time out, it will be removed from queue and allow the slot for the new async operation.

    // To assign UID for async result
    // Database.set<object_t>(aClient2, "/test/stream/number", json, asyncCB, "myUID");
}

// To get anyc result without callback
// printResult(aResult_no_callback);

}

void asyncCB(AsyncResult &aResult) { // To get the UID (string) from async result // aResult.uid();

printResult(aResult);

}

void printResult(AsyncResult &aResult) { if (aResult.appEvent().code() > 0) { Firebase.printf("Event msg: %s, code: %d\n", aResult.appEvent().message().c_str(), aResult.appEvent().code()); }

if (aResult.isDebug())
{
    Firebase.printf("Debug msg: %s\n", aResult.debug().c_str());
}

if (aResult.isError())
{
    Firebase.printf("Error msg: %s, code: %d\n", aResult.error().message().c_str(), aResult.error().code());
}

if (aResult.available())
{
    // To get the UID (string) from async result
    // aResult.uid();

    RealtimeDatabaseResult &RTDB = aResult.to<RealtimeDatabaseResult>();
    if (RTDB.isStream())
    {
        Firebase.printf("event: %s\n", RTDB.event().c_str());
        Firebase.printf("path: %s\n", RTDB.dataPath().c_str());
        Firebase.printf("data: %s\n", RTDB.to<const char *>());
        Firebase.printf("type: %d\n", RTDB.type());

        // The stream event from RealtimeDatabaseResult can be converted to the values as following.
        bool v1 = RTDB.to<bool>();
        int v2 = RTDB.to<int>();
        float v3 = RTDB.to<float>();
        double v4 = RTDB.to<double>();
        String v5 = RTDB.to<String>();
    }
    else
    {
        Firebase.printf("payload: %s\n", aResult.c_str());
    }
}

}`

======================= In file included from c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\authconfig.h:31:0, from c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:29, from C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\src/FirebaseClient.h:36, from C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\examples\RealtimeDatabase\Async\Stream\Stream.ino:34: c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\asyncresult\asyncresult.h: In member function 'T& AsyncResult::to()': c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\asyncresult\asyncresult.h:367:29: error: 'RealtimeDatabaseResult' was not declared in this scope if (std::is_same<T, RealtimeDatabaseResult>::value) ^ c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\asyncresult\asyncresult.h:367:51: error: template argument 2 is invalid if (std::is_same<T, RealtimeDatabaseResult>::value) ^ c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\asyncresult\asyncresult.h:368:20: error: 'rtdbResult' was not declared in this scope return rtdbResult; ^ In file included from C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\src/FirebaseClient.h:36:0, from C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\examples\RealtimeDatabase\Async\Stream\Stream.ino:34: c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h: At global scope: c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:40:12: error: 'JWTClass' does not name a type static JWTClass JWT; ^ c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:67:9: error: 'JSONUtil' does not name a type JSONUtil json; ^ In file included from C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\src/FirebaseClient.h:36:0, from C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\examples\RealtimeDatabase\Async\Stream\Stream.ino:34: c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h: In member function 'bool firebase::FirebaseApp::parseToken(const String&)': c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:139:78: error: 'setLastError' was not declared in this scope setLastError(sData ? &sData->aResult : nullptr, code, str); ^ c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:183:75: error: 'struct firebase::user_auth_data' has no member named 'sa' auth_data.app_token.val[app_tk_ns::pid] = auth_data.user_auth.sa.val[sa_ns::pid]; ^ c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h: In member function 'bool firebase::FirebaseApp::processAuth()': c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:349:17: error: 'JWT' was not declared in this scope JWT.jwt_data.err_code = FIREBASE_ERROR_JWT_CREATION_REQUIRED; ^ c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:434:25: error: 'json' was not declared in this scope json.addObject(sData->request.val[req_hndlr_ns::payload], "returnSecureToken", "true", false, true); ^ c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:490:29: error: 'json' was not declared in this scope json.addObject(sData->request.val[req_hndlr_ns::payload], "requestType", "VERIFY_EMAIL", true); ^ In file included from C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\src/FirebaseClient.h:36:0, from C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\examples\RealtimeDatabase\Async\Stream\Stream.ino:34: c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:495:29: error: 'json' was not declared in this scope json.addObject(sData->request.val[req_hndlr_ns::payload], "requestType", "PASSWORD_RESET", true); ^ c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:503:25: error: 'json' was not declared in this scope json.addObject(sData->request.val[req_hndlr_ns::payload], "idToken", auth_data.user_auth.user.val[user_ns::id_token].length() ? auth_data.user_auth.user.val[user_ns::id_token] : auth_data.app_token.val[app_tk_ns::token], true, true); ^ c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:508:25: error: 'json' was not declared in this scope json.addObject(sData->request.val[req_hndlr_ns::payload], "grantType", "refresh_token", true); ^ c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:516:29: error: 'json' was not declared in this scope json.addObject(sData->request.val[req_hndlr_ns::payload], "email", auth_data.user_auth.user.val[user_ns::em], true); ^ c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:519:25: error: 'json' was not declared in this scope json.addObject(sData->request.val[req_hndlr_ns::payload], "returnSecureToken", "true", false, true); ^ In file included from C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\examples\RealtimeDatabase\Async\Stream\Stream.ino:34:0: C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\src/FirebaseClient.h: In member function 'void firebase::FirebaseClient::initializeApp(AsyncClientClass&, firebase::FirebaseApp&, firebase::user_auth_data&)': C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\src/FirebaseClient.h:198:152: error: 'struct firebase::user_auth_data' has no member named 'sa' uint32_t exp = app.auth_data.user_auth.auth_type == auth_user_id_token ? app.auth_data.user_auth.user.expire : app.auth_data.user_auth.sa.expire; ^ C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\examples\RealtimeDatabase\Async\Stream\Stream.ino: At global scope: Stream:53:1: error: 'UserAuth' does not name a type UserAuth user_auth(API_KEY, USER_EMAIL, USER_PASSWORD); ^ Stream:80:1: error: 'RealtimeDatabase' does not name a type RealtimeDatabase Database; ^ C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\examples\RealtimeDatabase\Async\Stream\Stream.ino: In function 'void setup()': Stream:119:42: error: 'user_auth' was not declared in this scope initializeApp(aClient2, app, getAuth(user_auth)); ^ Stream:127:16: error: 'RealtimeDatabase' was not declared in this scope app.getApp(Database); ^ Stream:127:34: error: 'Database' was not declared in this scope app.getApp(Database); ^ C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\examples\RealtimeDatabase\Async\Stream\Stream.ino: In function 'void loop()': Stream:152:5: error: 'Database' was not declared in this scope Database.loop(); ^ Stream:158:9: error: 'JsonWriter' was not declared in this scope JsonWriter writer; ^ Stream:162:9: error: 'writer' was not declared in this scope writer.create(obj1, "ms", ms); ^ Stream:166:30: error: expected primary-expression before '>' token Database.set(aClient2, "/test/stream/number", json, asyncCB); ^ C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\examples\RealtimeDatabase\Async\Stream\Stream.ino: In function 'void printResult(AsyncResult&)': Stream:209:9: error: 'RealtimeDatabaseResult' was not declared in this scope RealtimeDatabaseResult &RTDB = aResult.to(); ^ Stream:209:33: error: 'RTDB' was not declared in this scope RealtimeDatabaseResult &RTDB = aResult.to(); ^ Stream:209:51: error: the value of 'RealtimeDatabaseResult' is not usable in a constant expression RealtimeDatabaseResult &RTDB = aResult.to(); ^ C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\examples\RealtimeDatabase\Async\Stream\Stream.ino:209:9: note: 'RealtimeDatabaseResult' was not declared 'constexpr' RealtimeDatabaseResult &RTDB = aResult.to(); ^ Stream:209:75: error: no matching function for call to 'AsyncResult::to()' RealtimeDatabaseResult &RTDB = aResult.to(); ^ In file included from c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\authconfig.h:31:0, from c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\firebaseapp.h:29, from C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\src/FirebaseClient.h:36, from C:\Users\pasca\Documents\Arduino\libraries\FirebaseClient-main\examples\RealtimeDatabase\Async\Stream\Stream.ino:34: c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\asyncresult\asyncresult.h:364:8: note: candidate: template T& AsyncResult::to() T &to() ^ c:\users\pasca\documents\arduino\libraries\firebaseclient-main\src\core\asyncresult\asyncresult.h:364:8: note: template argument deduction/substitution failed: Stream:214:51: error: expected primary-expression before 'const' Firebase.printf("data: %s\n", RTDB.to<const char *>()); ^ Stream:218:31: error: expected primary-expression before 'bool' bool v1 = RTDB.to(); ^ Stream:219:30: error: expected primary-expression before 'int' int v2 = RTDB.to(); ^ Stream:220:32: error: expected primary-expression before 'float' float v3 = RTDB.to(); ^ Stream:221:33: error: expected primary-expression before 'double' double v4 = RTDB.to(); ^ Stream:222:39: error: expected primary-expression before '>' token String v5 = RTDB.to(); ^ Stream:222:41: error: expected primary-expression before ')' token String v5 = RTDB.to(); ^ Plusieurs bibliothèque trouvées pour "WiFi.h" Utilisé : C:\Users\pasca\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.6\libraries\WiFi Non utilisé : C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\libraries\WiFi exit status 1 'UserAuth' does not name a type

for ESP32 dev module Partition scheme : minimal SPIFFS with OTA

Thanks for your answer

mobizt commented 7 months ago

You have to update your ESP32 Arduino to latest version. https://github.com/espressif/arduino-esp32/releases/tag/2.0.15