I am currently using your code to try connect to firebase. The code works most of the time but sometimes enters into an infinite loop while waiting for "ready". Do you have any idea why firebase would not be able to connect, why it would enter an infinite loop and how one could fix it?
`void GatewayLayer4::firebaseInit()
{
/ Assign the certificate data (optional) /
//config.cert.data = rootCACert;
/* Assign the project host and api key (required) */
config.host = FIREBASE_HOST;
config.api_key = API_KEY;
/* Assign the sevice account credentials and private key (required) */
config.service_account.data.client_email = FIREBASE_CLIENT_EMAIL;
config.service_account.data.project_id = FIREBASE_PROJECT_ID;
config.service_account.data.private_key = PRIVATE_KEY;
uint8_t selfNameArr[SENSOR_LENGTH] = {0};
uint8_t *ptr_selfNameArr = &selfNameArr[0];
selfName(ptr_selfNameArr);
std::string selfNameString = (char*)selfNameArr;
auth.token.uid = selfNameString;
/** Assign the custom claims (optional)
* This uid will be compare to the auth.token.premium_account variable
* (for this case) in the database rules.
*/
auth.token.claims.add("premium_account", true);
auth.token.claims.add("admin", true);
Firebase.reconnectWiFi(true);
Firebase.setReadTimeout(fbdo, 1000 * 120);
fbdo.setResponseSize(8192);
String base_path = //removed
Firebase.begin(&config, &auth);
path = base_path + auth.token.uid.c_str();
struct token_info_t info = Firebase.authTokenInfo();
String ready = "ready";
while (ready.compareTo(getTokenStatus(info)))
{
delay(1000);
#ifdef LL4_DEBUG_FIREBASE
Serial.println("GatewayLayer4::firebaseSetup(): Connecting to Firebase");
#endif
info = Firebase.authTokenInfo();
}
I am currently using your code to try connect to firebase. The code works most of the time but sometimes enters into an infinite loop while waiting for "ready". Do you have any idea why firebase would not be able to connect, why it would enter an infinite loop and how one could fix it?
`void GatewayLayer4::firebaseInit() { / Assign the certificate data (optional) / //config.cert.data = rootCACert;
}`