How to use the string to use it static const *in
-
Hello,
Instead of writing the tokens in the code, I would like to save the token Out and the token In in two files in SPIFFS. On startup I read from the file the line of the token into a variable of type String, but I haven't succeeded yet, it gives conversion error on compilation. Does anyone know how to do it?// file content:
cbbb726f-1e9b-4da2-a121-acf2da1f6d98String inToken = "";
file = SPIFFS.open("/inToken.txt");//file in SPIFFS
while (file.available()) {
inToken = file.readStringUntil('\n'); // read line with the token
}
//---static const char *In = "cbbb726f-1e9b-4da2-a121-acf2da1f6d98"static const char *In = inToken; // compile error
file.close();Thanks
Regards -
@sato said in How to use the string to use it static const *in:
static const char *In = inToken
Hello,
just use "String inToken..." directly, e.g.:
mqttClient.publish(&inToken[0], ...)
or
mqttClient.publish(inToken.c_str(), ...)
You can apply the same principle to "String outToken" that you read from a file.
You can drop "In" and "Out" variables...
Best regards,
kl3m3n -
-
-
@Sato Great!
Best regards,
kl3m3n