- #include "SPIFFS.h"
- #include <WiFi.h>
- void setup(){
- File file;
- Serial.begin(115200);
- if(!SPIFFS.begin(true)){
- Serial.println("An Error has occurred while mounting SPIFFS");
- return;
- }
- file = SPIFFS.open("/test.txt", FILE_WRITE);
- if(!file){
- Serial.println("There was an error opening the file for writing");
- return;
- }
- else
- {
- Serial.println("Opening the file for writing");
- }
- String ssid= "MAD";
- String pass = "1234567890";
- if(file.println(test))
- {
- Serial.println("SSID Written");
- }
- //file.close();
- file = SPIFFS.open("/test.txt",FILE_APPEND);
- if(!file){
- Serial.println("There was an error opening the file for appending");
- return;
- }
- if(file.println(test2))
- {
- Serial.println("Password Was Written");
- }
- file.close();
- file =SPIFFS.open("/test.txt");
- //read
- if(!file){
- Serial.println("There was an error opening the file for reading");
- return;
- }
- else
- {
- Serial.println("Opening the file for reading");
- }
- Serial.println("File Content : ");
- int i=0;
- String s,p;
- while(file.available())
- {
- if(i == 0)
- s = file.readStringUntil('\n');
- else
- p = file.readStringUntil('\n');
- i++;
- }
- file.close();
- Serial.println(s.c_str());
- Serial.println(p.c_str());
- WiFi.softAP(s.c_str(),p.c_str());
- Serial.print("Connecting to WiFi..");
- // while (WiFi.status() != WL_CONNECTED) {
- // delay(500);
- // Serial.print(".");
- // }
- }
- void loop(){}
SSID and PASSWORD read from SPIFFS file contain newline
-
- Posts: 16
- Joined: Tue Aug 06, 2019 6:18 am
SSID and PASSWORD read from SPIFFS file contain newline
Re: SSID and PASSWORD read from SPIFFS file contain newline
file.printfile.println
-
- Posts: 828
- Joined: Mon Jul 22, 2019 3:20 pm
Re: SSID and PASSWORD read from SPIFFS file contain newline
s.trim();
p.trim();
p.trim();
Who is online
Users browsing this forum: Bing [Bot] and 62 guests