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
106 stars 6 forks source link

Issue in Compiliing == > 'class String' has no member named 'val' .. #63

Closed Eashubh128 closed 4 months ago

Eashubh128 commented 4 months ago

I was trying to compile then this error pops up , I cannot identify where in my code does this happen.

In file included from /Users/eashubhthapliyal/Documents/Arduino/libraries/FirebaseClient/src/./firestore/DataOptions.h:34, from /Users/eashubhthapliyal/Documents/Arduino/libraries/FirebaseClient/src/firestore/Databases.h:29, from /Users/eashubhthapliyal/Documents/Arduino/libraries/FirebaseClient/src/FirebaseClient.h:43, from /Users/eashubhthapliyal/Documents/Arduino/mouthwash_v5_1Apr/mouthwash_v5_1Apr.ino:18: /Users/eashubhthapliyal/Documents/Arduino/libraries/FirebaseClient/src/./firestore/Values.h: In instantiation of 'Values::Value::Value(T) [with T = String]': /Users/eashubhthapliyal/Documents/Arduino/mouthwash_v5_1Apr/mouthwash_v5_1Apr.ino:436:43: required from here /Users/eashubhthapliyal/Documents/Arduino/libraries/FirebaseClient/src/./firestore/Values.h:476:38: error: 'class String' has no member named 'val' Value(T value) { buf = value.val(); }



The code i am using is 
`void generateDocument() {
  taskcomplete = false;
  String documentName = deviceDetails.DEVICE_ID.c_str();
  String dateTime = getLocalTime();
  documentName.replace(" ", "%");
  String documentPath = COLLECTION_PATH + documentName;
  Values::IntegerValue timesRef(deviceDetails.timesRef);
  Values::IntegerValue cupsRem(deviceDetails.cupsRem);
  Values::StringValue devId(deviceDetails.DEVICE_ID.c_str());
  Values::StringValue installedOn(deviceDetails.installedOn.c_str());
  Values::StringValue installedBy(deviceDetails.installedBy.c_str());
  Values::StringValue macAdr(deviceDetails.macAdr);
  Values::StringValue refOn(deviceDetails.refOn.c_str());
  Values::StringValue refBy(deviceDetails.refBy.c_str());
  Values::StringValue lastUpd(dateTime);
  Values::GeoPointValue geoV(String(latlng.latitude.c_str()).toDouble(), String(latlng.longitude.c_str()).toDouble());
  Values::DoubleValue washRem1(mouthWashDetail1.mouthWashPercentage);
  Values::DoubleValue washRem2(mouthWashDetail2.mouthWashPercentage);
  Values::DoubleValue battPer(deviceDetails.batteryPercentage);

  Document<Values::Value> doc("instOn", Values::Value(installedOn));
  doc.add("instBy", Values::Value(installedBy));
  doc.add("macAdr", Values::Value(macAdr));
  doc.add("battRem", Values::Value(battPer));
  doc.add("washRem1", Values::Value(washRem1));
  doc.add("washRem2", Values::Value(washRem2));
  doc.add("cupsRem", Values::Value(cupsRem));
  doc.add("refOn", Values::Value(refOn));
  doc.add("refBy", Values::Value(refBy));
  doc.add("ref", Values::Value(timesRef));
  doc.add("latlng", Values::Value(geoV));
  doc.add("lstUpd", Values::Value(dateTime));

  if (!taskcomplete) {
    taskcomplete = true;
    Serial.println("Creating a document... ");
    if (Docs.createDocument(aClient, Firestore::Parent(FIREBASE_PROJECT_ID), documentPath, DocumentMask(), doc)) {
      Serial.println("Document created successfully");
    } else {
      Serial.println("Document patching ......");
      dateTime = getLocalTime();
      PatchDocumentOptions patchOptions(DocumentMask("devId,instOn,instBy,macAdr,battRem,washRem,washRem,cupsRem,refOn,refByref,latlng,lstUp"), DocumentMask(), Precondition());
      bool patchResult = Docs.patch(aClient, Firestore::Parent(FIREBASE_PROJECT_ID), documentPath, patchOptions, doc);
      if (patchResult) {
        Serial.println("Document patched successfully");
      } else {
        Serial.println("Document patch failed");
      }
    }
  }
}
`
 - Arduino 2.2.1
 -  Library Version 1.1.8
mobizt commented 4 months ago

In your code you should verify your code line by line.

Eashubh128 commented 4 months ago

Just to point me in the right direction it is coming just cuz of the firebase part right where i am creating a document ? Also now i have updated to the latest arduino version

mobizt commented 4 months ago

You have to debug your code yourself.

You are putting an unsupported variable or object into the function.

You have to read the documentation on the placeholder class and follow the examples.

Avoid string concatenation as the input for the function.

Eashubh128 commented 4 months ago

Hey thanks , I found the error out Values::StringValue lastUpd(dateTime.c_str()); and I was adding it to the doc like this doc.add("lstUpd", Values::Value(dateTime)); instead of doc.add("lstUpd", Values::Value(lastUpd));

mobizt commented 4 months ago

You have to debug your code yourself.

You are putting an unsupported variable or object into the function.

You have to read the documentation on the placeholder class and follow the examples.

Avoid string concatenation as the input for the function.

Eashubh128 commented 4 months ago

Thanks man , will take care of this from now on !!