Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix EvilPortal with board setups without SD #482

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 35 additions & 32 deletions esp32_marauder/EvilPortal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,43 +87,44 @@ void EvilPortal::setHtmlFromSerial() {
}

bool EvilPortal::setHtml() {
if (this->using_serial_html) {
Serial.println("html previously set");
return true;
}
Serial.println("Setting HTML...");
File html_file = sd_obj.getFile("/" + this->target_html_name);
if (!html_file) {
#ifdef HAS_SCREEN
this->sendToDisplay("Could not find /" + this->target_html_name);
this->sendToDisplay("Touch to exit...");
#endif
Serial.println("Could not find /" + this->target_html_name + ". Use stopscan...");
return false;
}
else {
if (html_file.size() > MAX_HTML_SIZE) {
#ifdef HAS_SD
if (this->using_serial_html) {
Serial.println("html previously set");
return true;
}
Serial.println("Setting HTML...");
File html_file = sd_obj.getFile("/" + this->target_html_name);
if (!html_file) {
#ifdef HAS_SCREEN
this->sendToDisplay("The given HTML is too large.");
this->sendToDisplay("The Byte limit is " + (String)MAX_HTML_SIZE);
this->sendToDisplay("Could not find /" + this->target_html_name);
this->sendToDisplay("Touch to exit...");
#endif
Serial.println("The provided HTML is too large. Byte limit is " + (String)MAX_HTML_SIZE + "\nUse stopscan...");
Serial.println("Could not find /" + this->target_html_name + ". Use stopscan...");
return false;
}
String html = "";
while (html_file.available()) {
char c = html_file.read();
if (isPrintable(c))
html.concat(c);
else {
if (html_file.size() > MAX_HTML_SIZE) {
#ifdef HAS_SCREEN
this->sendToDisplay("The given HTML is too large.");
this->sendToDisplay("The Byte limit is " + (String)MAX_HTML_SIZE);
this->sendToDisplay("Touch to exit...");
#endif
Serial.println("The provided HTML is too large. Byte limit is " + (String)MAX_HTML_SIZE + "\nUse stopscan...");
return false;
}
String html = "";
while (html_file.available()) {
char c = html_file.read();
if (isPrintable(c))
html.concat(c);
}
strncpy(index_html, html.c_str(), strlen(html.c_str()));
this->has_html = true;
Serial.println("html set");
html_file.close();
return true;
}
strncpy(index_html, html.c_str(), strlen(html.c_str()));
this->has_html = true;
Serial.println("html set");
html_file.close();
return true;
}

#endif
}

bool EvilPortal::setAP(LinkedList<ssid>* ssids, LinkedList<AccessPoint>* access_points) {
Expand All @@ -136,6 +137,7 @@ bool EvilPortal::setAP(LinkedList<ssid>* ssids, LinkedList<AccessPoint>* access_
break;
}
}
#ifdef HAS_SD
// If there are no SSIDs and there are no APs selected, pull from file
// This means the file is last resort
if ((ssids->size() <= 0) && (temp_ap_name == "")) {
Expand Down Expand Up @@ -177,9 +179,10 @@ bool EvilPortal::setAP(LinkedList<ssid>* ssids, LinkedList<AccessPoint>* access_
ap_config_file.close();
}
}
#endif
// There are SSIDs in the list but there could also be an AP selected
// Priority is SSID list before AP selected and config file
else if (ssids->size() > 0) {
if (ssids->size() > 0) {
ap_config = ssids->get(0).essid;
if (ap_config.length() > MAX_AP_NAME_SIZE) {
#ifdef HAS_SCREEN
Expand Down
Loading