Print IP info

This commit is contained in:
2023-11-28 18:52:07 +05:30
parent 3d77b11cd9
commit 21beb90a76
6 changed files with 34 additions and 11 deletions
Binary file not shown.
+3 -1
View File
@@ -3,4 +3,6 @@
void setupOTALocal();
void handleOTALocal();
void handleOTARemote();
void handleOTARemote();
void printIPInfo();
+3 -3
View File
@@ -1,9 +1,9 @@
#ifndef BUILD_NUMBER
#define BUILD_NUMBER 42
#define BUILD_NUMBER 47
#endif
#ifndef VERSION
#define VERSION "v0.1.42 - 2023-11-28 18:31:54.334129"
#define VERSION "v0.1.47 - 2023-11-28 18:50:16.207931"
#endif
#ifndef VERSION_SHORT
#define VERSION_SHORT "v0.1.42"
#define VERSION_SHORT "v0.1.47"
#endif
+6
View File
@@ -75,6 +75,7 @@ const String KEY_D = "0x1FE20DF";
const String KEY_ON = "0x1FE48B7";
const String KEY_OFF = "0x1FE48B7";
const String KEY_MODE = "0x1FE58A7";
const String KEY_RPT = "0x1FE10EF";
char lastPressedKey = '\0';
@@ -118,6 +119,9 @@ void handleKeyPress(char pressedKey) {
playBuzzer(BUZZER_PIN, TONE_BEEP_TWICE);
handleOTARemote();
}
if (pressedKey == 'I') {
printIPInfo();
}
// If pressed number
uint8_t currentNumberEntered = pressedKey - '0';
uint8_t lastNumberEntered = lastPressedKey - '0';
@@ -208,6 +212,8 @@ void loop() {
pressedKey = 'R';
} else if (hexKey == KEY_MODE) {
pressedKey = 'U';
} else if (hexKey == KEY_RPT) {
pressedKey = 'I';
}
if (pressedKey != '\0') {
handleKeyPress(pressedKey);
+21 -6
View File
@@ -11,9 +11,11 @@
void setupOTALocal() {
Serial.println("Booting");
char infoBuffer[LCD_COLUMNS];
sprintf(infoBuffer, "W:%s", WIFI_SSID);
showInsideInfo(infoBuffer);
{
char infoBuffer[LCD_COLUMNS];
sprintf(infoBuffer, "W:%s", WIFI_SSID);
showInsideInfo(infoBuffer);
}
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
@@ -33,9 +35,11 @@ void setupOTALocal() {
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress:%u%%\r", (progress / (total / 100)));
char infoBuffer[LCD_COLUMNS];
sprintf(infoBuffer, "LU:P:%u%%", (progress / (total / 100)));
showInsideInfo(infoBuffer);
{
char infoBuffer[LCD_COLUMNS];
sprintf(infoBuffer, "LU:P:%u%%", (progress / (total / 100)));
showInsideInfo(infoBuffer);
}
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]:", error);
@@ -44,11 +48,22 @@ void setupOTALocal() {
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
showInsideInfo("LU:Failed");
});
ArduinoOTA.begin();
Serial.println("Ready");
Serial.print("IP address:");
Serial.println(WiFi.localIP());
showInsideInfo("Ready");
}
void printIPInfo() {
String localIPStr = WiFi.localIP().toString();
char localIP[LCD_COLUMNS];
localIPStr.toCharArray(localIP, LCD_COLUMNS);
char infoBuffer[LCD_COLUMNS];
sprintf(infoBuffer, "W:%s", localIP);
showInsideInfo(infoBuffer);
}
void handleOTALocal() {
+1 -1
View File
@@ -1 +1 @@
42
47