je peux afficher 'cadence' dans le moniteur serie ou l écrire sur un fichier .csv sur une carte SD
par contre quand je veux l écrire dans la memoire SPIFFS de ma carte j ai cette erreur
error: invalid conversion from 'int' to 'const char*' [-fpermissive]
j ouvre bien ma memoire, crée le fichier mais après je bute
void setup() {
Serial.begin(115200);
if(!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)){
Serial.println("SPIFFS Mount Failed");
return;
}
listDir(SPIFFS, "/", 0);
writeFile(SPIFFS, "/data.csv", "Cadence\n");
} // End of setup.
// This is the Arduino main loop function.
void loop() {
appendFile(SPIFFS, "/data.csv",'cadence');
je suis sur que vous avez des idées pour résoudre mon problème.
en effet c est pas facile
c est la variable cadence que je voudrai inscrire dans la memoire
je la declare par int cadence
je la calcule et la valide par la fonction.
elle est comprise entre 0 et 150
merci
void setup() {
Serial.begin(115200);
if(!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)){
Serial.println("SPIFFS Mount Failed");
return;
}
listDir(SPIFFS, "/", 0);
writeFile(SPIFFS, "/data.csv", "Cadence\n");
Serial.println("Starting Arduino BLE Client application...");
BLEDevice::init("");
// Retrieve a Scanner and set the callback we want to use to be informed when we
// have detected a new device. Specify that we want active scanning and start the
// scan to run for 5 seconds.
BLEScan* pBLEScan = BLEDevice::getScan();
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setInterval(1349);
pBLEScan->setWindow(449);
pBLEScan->setActiveScan(true);
pBLEScan->start(5, false);
} // End of setup.
// This is the Arduino main loop function.
void loop() {
char cadenceC[cadence];
appendFile(SPIFFS, "/data.csv",cadenceC);
appendFile(SPIFFS, "/data.csv","\n");
// If the flag "doConnect" is true then we have scanned for and found the desired
// BLE Server with which we wish to connect. Now we connect to it. Once we are
// connected we set the connected flag to be true.
if (doConnect == true) {
if (connectToServer()) {
Serial.println("We are now connected to the BLE Server.");
} else {
Serial.println("We have failed to connect to the server; there is nothin more we will do.");
}
doConnect = false;
}
// If we are connected to a peer BLE Server, update the characteristic each time we are reached
// with the current time since boot.
if (connected) {
String newValue = "Time since boot: " + String(millis()/1000);
Serial.println("Setting new characteristic value to \"" + newValue + "\"");
// Set the characteristic's value to be the array of bytes that is actually a string.
pRemoteCharacteristic->writeValue(newValue.c_str(), newValue.length());
}else if(doScan){
BLEDevice::getScan()->start(0); // this is just eample to start scan after disconnect, most likely there is better way to do it in arduino
}
delay(1000); // Delay a second between loops.
} // End of loop
Comme veux-tu que cela fonctionne ?
Tu déclares un tableau cadenceC qui a pour taille la valeur d'une variable cadence, sans l'initialiser.
Ce tableau contient n'importe quoi car c'est une variable locale sur la pile.
Mais tu pourrais simplifier en écrivant directement cadence :
void appendFile(fs::FS &fs, const char * path, int cadence)
{
// ...
if(file.println(cadence)){
// ...
}
// et dans la loop :
appendFile(SPIFFS, "/data.csv",cadence);
// et tu te passes de la variable cadenceC