Created
May 15, 2021 17:49
-
-
Save nishanc/9d7293cb685ccd2869a3815310420d7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//access SD card for WiFi SSID and Password | |
if (!SD_MMC.begin()) { | |
Serial.println("Failed to mount card"); | |
return; | |
} | |
File file = SD_MMC.open("/ssid.txt", FILE_READ); | |
File file_pwd = SD_MMC.open("/pwd.txt", FILE_READ); | |
if (!file || !file_pwd) { | |
Serial.println("Opening file to read failed"); | |
return; | |
} | |
Serial.println("File Content: SSID"); | |
while (file.available()) { | |
int l = file.readBytesUntil('\n', ssid, sizeof(ssid)); | |
if (l > 0 && ssid[l-1] == '\r') { | |
l--; | |
} | |
ssid[l] = 0; | |
} | |
Serial.println(ssid); | |
Serial.println("File Content: Password"); | |
while (file_pwd.available()) { | |
int l = file_pwd.readBytesUntil('\n', password, sizeof(password)); | |
if (l > 0 && password[l-1] == '\r') { | |
l--; | |
} | |
password[l] = 0; | |
} | |
Serial.println(password); | |
file.close(); | |
file_pwd.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment