diff --git a/data/main_menu.html b/data/main_menu.html
new file mode 100644
index 0000000..933b50b
--- /dev/null
+++ b/data/main_menu.html
@@ -0,0 +1,29 @@
+
+ Rally TerraTrip v1
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/data/setWiFi.html b/data/setWiFi.html
new file mode 100644
index 0000000..36f3ce6
--- /dev/null
+++ b/data/setWiFi.html
@@ -0,0 +1,21 @@
+
+ RALLY WIFI Station
+
+
+
+ Your Local IP is: %localip%
+
+
+
\ No newline at end of file
diff --git a/src/index.h b/src/index.h
index 7baeb87..04f0d90 100644
--- a/src/index.h
+++ b/src/index.h
@@ -1,4 +1,4 @@
-const char HTML_startrally1[] PROGMEM = R"rawliteral(
+const char HTML_startrally[] PROGMEM = R"rawliteral(
Rally TerraTrip v1
diff --git a/src/main.cpp b/src/main.cpp
index 0882fba..93e48b9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -406,12 +406,9 @@ String procConst(const String& var){
}
-
-
void OnWiFiEvent(WiFiEvent_t event)
{
switch (event) {
-
case SYSTEM_EVENT_STA_CONNECTED:
Serial.println("ESP32 Connected to WiFi Network");
break;
@@ -427,6 +424,7 @@ void OnWiFiEvent(WiFiEvent_t event)
default: break;
}
}
+
String getPin(){
struct tm timeinfo;
String hasil;
@@ -1086,19 +1084,34 @@ void printMonth(int month)
default: lcd.print(" Error ");break;
}
}
+void showIPAddressOnLCD(){
+ IPAddress mlocalIP;
+ if(WiFi.isConnected()) mlocalIP = WiFi.localIP();
+ else mlocalIP = WiFi.softAPIP();
+ Serial.println(mlocalIP);
+ lcd.setCursor(17,0);
+ lcd.print(mlocalIP[0]);
+ lcd.setCursor(17,1);
+ lcd.print(mlocalIP[1]);
+ lcd.setCursor(17,2);
+ lcd.print(mlocalIP[2]);
+ lcd.setCursor(17,3);
+ lcd.print(mlocalIP[3]);
+}
void mainMenu()
{
MENU = MAIN;
lcd.clear();
lcd.print("1. Rally TSD");
lcd.setCursor(0,1);
- lcd.print("2. Set Main Time");
+ lcd.print("2. Main Time");
lcd.setCursor(0,2);
- lcd.print("3. Input Constanta");
+ lcd.print("3. Constanta");
lcd.setCursor(0,3);
- lcd.print("4. Calibration ODO");
+ lcd.print("4. Calibration");
//lcd.home();
+ showIPAddressOnLCD();
x=2;
y=0;
lcd.cursor();
@@ -2598,8 +2611,6 @@ DS3231_init(DS3231_CONTROL_INTCN);
//
- //Serial.begin(115200);
- //DynamicJsonDocument doc(512);
// Initialize SPIFFS
#ifdef ESP32
if(!SPIFFS.begin(true)){
@@ -2627,7 +2638,7 @@ DS3231_init(DS3231_CONTROL_INTCN);
Serial.println(ssid);
if (yourSSIDString != ""){
strncpy(ssid, yourSSIDString.c_str() , (sizeof ssid)-1);
- // strncpy(ssid, yourSSIDString.c_str() , (sizeof yourSSIDString)-1);
+ // strncpy(ssid, yourSSIDString.c_str() , (sizeof yourSSIDString)-1); //dont show the old password for security reason
}
Serial.println(ssid);
@@ -2651,7 +2662,8 @@ Serial.print("try to connect to ssid:");Serial.print(ssid);Serial.print("; with
Serial.println();
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
-
+
+ mainMenu();
// //settingup MDNS
// if(!MDNS.begin("esp32")) {
// Serial.println("Error starting mDNS");
@@ -2659,6 +2671,7 @@ Serial.print("try to connect to ssid:");Serial.print(ssid);Serial.print("; with
// }
// Serial.println(“MDNS started.”);
// MDNS.addService(“http”, “tcp”, 80);
+
// // Init and get the time
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
printLocalTime();
@@ -2676,7 +2689,6 @@ Serial.print("try to connect to ssid:");Serial.print(ssid);Serial.print("; with
request->send_P(200, "text/html", wifi_html, processor);
return;
}
-
});
server.on("/wifi", HTTP_GET, [](AsyncWebServerRequest * request) {
@@ -2696,77 +2708,51 @@ Serial.print("try to connect to ssid:");Serial.print(ssid);Serial.print("; with
request->send(200, "text/plain", "Hello from undefined");
});
-
-
// Send a GET request to /get?inputString=
server.on("/setwifi", HTTP_POST, [] (AsyncWebServerRequest *request) {
String inputMessage;
boolean bolrestart=false;
boolean POST=true;
- Serial.println("ini masuk /setwifi");
+ Serial.print("/setwifi:");
// GET inputString value on /get?inputString=
if (request->hasParam(PARAM_SSID, POST)) {
inputMessage = request->getParam(PARAM_SSID, POST )->value();
+ Serial.print(inputMessage);Serial.print(";");
if (inputMessage!=""){
+ Serial.print(inputMessage);
writeFile(SPIFFS, "/ssidString.txt", inputMessage.c_str());
delay(50);
bolrestart=true;
- //ESP.restart();
}
}
// GET inputPwd value on /wifi/get?inputPwd=
if (request->hasParam(PARAM_PWD, POST)) {
inputMessage = request->getParam(PARAM_PWD, POST)->value();
+ Serial.print(inputMessage);Serial.print(";");
if (inputMessage!=""){
writeFile(SPIFFS, "/inputPwd.txt", inputMessage.c_str());
delay(50);
bolrestart=true;
- //ESP.restart();
}
}
else {
inputMessage = "No message sent";
}
+ Serial.println("");
if (bolrestart) {
ESP.restart();
}
- Serial.println("ini /setwifi aja");Serial.println(inputMessage);
+ // Serial.println("ini /setwifi aja");Serial.println(inputMessage);
request->send(200, "text/text", inputMessage);
});
- // // Send a GET request to /wifi/get?ssidString=
- // server.on("/wifi/get", HTTP_GET, [] (AsyncWebServerRequest *request) {
- // String inputMessage;
- // // GET ssidString value on /wifi/get?ssidString=
- // Serial.println("ini masuk wifi get");
- // Serial.println(request->params());
- // if (request->hasParam(PARAM_SSID)) {
- // inputMessage = request->getParam(PARAM_SSID)->value();
- // writeFile(SPIFFS, "/ssidString.txt", inputMessage.c_str());
- // delay(100);
- // ESP.restart();
- // }
- // // GET inputPwd value on /wifi/get?inputPwd=
- // else if (request->hasParam(PARAM_PWD)) {
- // inputMessage = request->getParam(PARAM_PWD)->value();
- // writeFile(SPIFFS, "/inputPwd.txt", inputMessage.c_str());
- // delay(100);
- // ESP.restart();
- // }
- // else {
- // inputMessage = "No message sent";
- // }
- // Serial.println("/wifi/get value:"); Serial.println(inputMessage);
- // request->send(200, "text/text", inputMessage);
- // });
-
server.on("/menu", HTTP_GET, [] (AsyncWebServerRequest *request) {
//String s = MAIN_page; //Read HTML contents
//request->send_P(200, "text/html", s); //Send web page
request->send_P(200, "text/html", main_menu);
});
- server.on("/startrally", HTTP_GET, [] (AsyncWebServerRequest *request) {
+ server.on("/startrallytest", HTTP_GET, [] (AsyncWebServerRequest *request) {
//String s = MAIN_page; //Read HTML contents
//request->send_P(200, "text/html", s); //Send web page
String PAGE;
@@ -2782,8 +2768,8 @@ Serial.print("try to connect to ssid:");Serial.print(ssid);Serial.print("; with
request->send(200, "text/html", PAGE);
});
- server.on("/startrally1", HTTP_GET, [] (AsyncWebServerRequest *request) {
- request->send_P(200, "text/html", HTML_startrally1, processor);
+ server.on("/startrally", HTTP_GET, [] (AsyncWebServerRequest *request) {
+ request->send_P(200, "text/html", HTML_startrally, processor);
});
server.on("/bootstrap.css", HTTP_GET, [] (AsyncWebServerRequest *request) {
@@ -2873,14 +2859,6 @@ Serial.print("try to connect to ssid:");Serial.print(ssid);Serial.print("; with
Serial.println("TOGGLE 2");
request->redirect("/startrally1");
});
-// //server.on("/adc", HTTP_GET); //This is display page
-// server.on("/readADC", HTTP_GET, [] (AsyncWebServerRequest *request) {
-// // int a = analogRead(A0);
-// // String adcValue = String(millis());
-// String adcValue = getPin();
-// Serial.println(adcValue);
-// request->send_P(200, "text/plain", adcValue.c_str()); //Send ADC value only to client ajax request
-// });
server.on("/calibration", HTTP_GET, [] (AsyncWebServerRequest *request) {
int params = request->params(); //showing all params
diff --git a/src/template_html.h b/src/template_html.h
index 507e931..5402afd 100644
--- a/src/template_html.h
+++ b/src/template_html.h
@@ -165,51 +165,27 @@ const char HTML_END[] PROGMEM = R"rawliteral(
)rawliteral";
-// HTML web page to handle 3 input fields (inputString, inputInt, inputFloat)
-const char index_html[] PROGMEM = R"rawliteral(
-
- ESP Input Form
-
-
-
-
-
-
-
-)rawliteral";
-
const char wifi_html[] PROGMEM = R"rawliteral(
- ESP WIFI Station
+ RALLY WIFI Station
-
- Your Local IP is: %localip%
-
-
-
+
+
+ Your Local IP is: %localip%
+
+
)rawliteral";
@@ -221,87 +197,30 @@ const char main_menu[] PROGMEM = R"rawliteral(
Rally TerraTrip v1
-
+
-
+
-
-
-