diff --git a/README.md b/README.md
index 5eb5393..535852a 100644
--- a/README.md
+++ b/README.md
@@ -64,13 +64,14 @@ After connection with APRX based DIGI it can be used as KISS-TNC
* In the left column click on the ANT-shaped icon, choose your board and click on "Upload". COM port should be detected automatically Wait for procedure to finish and keep reading
## Configuring parameters
-Wait for the board to reboot, connect to "N0CALL AP" WiFi network, password is: xxxxxxxxxx (10 times "x") and point your browser to "192.168.4.1"
+Wait for the board to reboot, connect to "N0CALL AP" WiFi network, password is: xxxxxxxxxx (10 times "x") and point your browser to "192.168.4.1". Hover your mouse to textboxes to get useful hints.
### WiFi Settings
you can scan for local SSID or manually type in name and password
* Scan WiFi: scan for local WiFi networks
* SSID: name of the AP to connect to
* Password: password of WiFi AP
+* AUTO AP Password: if configured network is not reachable the AP mode will be enabled, SSID will be your callsign and this will be the password
### APRS Settings
These are main APRS settings such as callsign, SSID and symbol (refer to: http://www.aprs.org/symbols.html). Please remember to turn ON GPS in order to use it as a tracker.
diff --git a/data_embed/index.html b/data_embed/index.html
index 0ca51c3..6e94212 100644
--- a/data_embed/index.html
+++ b/data_embed/index.html
@@ -26,15 +26,15 @@
WiFi SSID
-
+
WiFi Password
-
+
AUTO AP Password
-
+
diff --git a/include/preference_storage.h b/include/preference_storage.h
index fc883be..084f0ac 100644
--- a/include/preference_storage.h
+++ b/include/preference_storage.h
@@ -9,6 +9,7 @@ extern Preferences preferences;
// MAX 15 chars for preferenece key!!!
static const char *const PREF_WIFI_SSID = "wifi_ssid";
static const char *const PREF_WIFI_PASSWORD = "wifi_password";
+static const char *const PREF_AP_PASSWORD = "ap_password";
// LoRa settings
static const char *const PREF_LORA_FREQ_PRESET_INIT = "lora_freq_i";
static const char *const PREF_LORA_FREQ_PRESET = "lora_freq";
diff --git a/src/TTGO_T-Beam_LoRa_APRS.ino b/src/TTGO_T-Beam_LoRa_APRS.ino
index eb3a5c2..6508baa 100644
--- a/src/TTGO_T-Beam_LoRa_APRS.ino
+++ b/src/TTGO_T-Beam_LoRa_APRS.ino
@@ -366,9 +366,9 @@ void batt_read(){
BattVolts = axp.getBattVoltage()/1000;
InpVolts = axp.getVbusVoltage()/1000;
#elif T_BEAM_V0_7
- BattVolts = ((float)analogRead(35) / 8192.0) * 2.0 * 3.3 * (1100.0 / 1000.0); // fixed thanks to Luca IU2FRL
+ BattVolts = (((float)analogRead(35) / 8192.0) * 2.0 * 3.3 * (1100.0 / 1000.0))+0.41; // fixed thanks to Luca IU2FRL
#else
- BattVolts = analogRead(35)*7.221/4096; // fixed thanks to Luca IU2FRL
+ BattVolts = analogRead(35)*7.221/4096;
#endif
}
diff --git a/src/taskWebServer.cpp b/src/taskWebServer.cpp
index 1f0b987..ce39ab2 100644
--- a/src/taskWebServer.cpp
+++ b/src/taskWebServer.cpp
@@ -24,7 +24,9 @@ std::list receivedPackets;
const int MAX_RECEIVED_LIST_SIZE = 50;
String apSSID = "";
-String apPassword = "xxxxxxxxxx";
+String apPassword;
+String defApPassword = "xxxxxxxxxx";
+
WebServer server(80);
#ifdef KISS_PROTOCOL
WiFiServer tncServer(NETWORK_TNC_PORT);
@@ -112,16 +114,38 @@ void handle_ScanWifi() {
}
void handle_SaveWifiCfg() {
- if (!server.hasArg(PREF_WIFI_SSID) || !server.hasArg(PREF_WIFI_PASSWORD)){
- server.send(500, "text/plain", "Invalid request");
+ if (!server.hasArg(PREF_WIFI_SSID) || !server.hasArg(PREF_WIFI_PASSWORD) || !server.hasArg(PREF_AP_PASSWORD)){
+ server.send(500, "text/plain", "Invalid request, make sure all fields are set");
}
+
if (!server.arg(PREF_WIFI_SSID).length()){
- server.send(403, "text/plain", "Empty SSID or Password");
+ server.send(403, "text/plain", "Empty SSID");
+ } else {
+ // Update SSID
+ preferences.putString(PREF_WIFI_SSID, server.arg(PREF_WIFI_SSID));
+ Serial.println("Updated SSID: " + server.arg(PREF_WIFI_SSID));
}
- preferences.putString(PREF_WIFI_SSID, server.arg(PREF_WIFI_SSID));
- preferences.putString(PREF_WIFI_PASSWORD, server.arg(PREF_WIFI_PASSWORD));
+ if (server.arg(PREF_WIFI_PASSWORD)!="*" && server.arg(PREF_WIFI_PASSWORD).length()>0 && server.arg(PREF_WIFI_PASSWORD).length()<8){
+ server.send(403, "text/plain", "WiFi Password must be minimum 8 character");
+ } else {
+ if (server.arg(PREF_WIFI_PASSWORD)!="*") {
+ // Update WiFi password
+ preferences.putString(PREF_WIFI_PASSWORD, server.arg(PREF_WIFI_PASSWORD));
+ Serial.println("Updated WiFi PASS: " + server.arg(PREF_WIFI_PASSWORD));
+ }
+ }
+ if (server.arg(PREF_AP_PASSWORD)!="*" && server.arg(PREF_AP_PASSWORD).length()<8){
+ server.send(403, "text/plain", "AP Password must be minimum 8 character");
+ } else {
+ if (server.arg(PREF_AP_PASSWORD)!="*") {
+ // Update AP password
+ preferences.putString(PREF_AP_PASSWORD, server.arg(PREF_AP_PASSWORD));
+ Serial.println("Updated AP PASS: " + server.arg(PREF_AP_PASSWORD));
+ }
+ }
+
server.sendHeader("Location", "/");
server.send(302,"text/html", "");
}
@@ -159,6 +183,7 @@ void handle_Restore() {
void handle_Cfg() {
String jsonData = "{";
jsonData += String("\"") + PREF_WIFI_PASSWORD + "\": \"" + jsonEscape((preferences.getString(PREF_WIFI_PASSWORD).isEmpty() ? String("") : "*")) + R"(",)";
+ jsonData += String("\"") + PREF_AP_PASSWORD + "\": \"" + jsonEscape((preferences.getString(PREF_AP_PASSWORD).isEmpty() ? String("") : "*")) + R"(",)";
jsonData += jsonLineFromPreferenceString(PREF_WIFI_SSID);
jsonData += jsonLineFromPreferenceDouble(PREF_LORA_FREQ_PRESET);
jsonData += jsonLineFromPreferenceInt(PREF_LORA_SPEED_PRESET);
@@ -198,6 +223,7 @@ void handle_Cfg() {
void handle_ReceivedList() {
PSRAMJsonDocument doc(MAX_RECEIVED_LIST_SIZE * 1000);
+ //DynamicJsonDocument doc(MAX_RECEIVED_LIST_SIZE * 500);
JsonObject root = doc.to();
auto received = root.createNestedArray("received");
for (auto element: receivedPackets){
@@ -346,6 +372,12 @@ void handle_saveDeviceCfg(){
String wifi_password = preferences.getString(PREF_WIFI_PASSWORD);
String wifi_ssid = preferences.getString(PREF_WIFI_SSID);
+ if (preferences.getString(PREF_AP_PASSWORD).length() > 8) {
+ // 8 characters is requirements for WPA2
+ apPassword = preferences.getString(PREF_AP_PASSWORD);
+ } else {
+ apPassword = defApPassword;
+ }
if (!wifi_ssid.length()){
WiFi.softAP(apSSID.c_str(), apPassword.c_str());
} else {
@@ -361,15 +393,24 @@ void handle_saveDeviceCfg(){
retryWifi += 1;
if (retryWifi > 60) {
WiFi.softAP(apSSID.c_str(), apPassword.c_str());
+ //WiFi.softAP(apSSID.c_str(), "password");
Serial.println("Unable to connect to to wifi. Starting AP");
+ Serial.print("SSID: ");
+ Serial.print(apSSID.c_str());
+ Serial.print(" Password: ");
+ Serial.println(apPassword.c_str());
break;
}
}
- if (WiFi.getMode() == wifi_mode_t::WIFI_MODE_AP){
+ //Serial.print("WiFi Mode: ");
+ //Serial.println(WiFi.getMode());
+ if (WiFi.getMode() == 3){
Serial.println("Running AP. IP: " + WiFi.softAPIP().toString());
- } else {
+ } else if (WiFi.getMode() == 1) {
Serial.println("Connected. IP: " + WiFi.localIP().toString());
+ } else {
+ Serial.println("WiFi Mode: " + WiFi.getMode());
}
#ifdef ENABLE_SYSLOG