mirror of
https://github.com/anklimov/lighthub
synced 2025-12-08 04:39:49 +03:00
PWA redirection & local
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
String systemConfig::getMACString()
|
String systemConfig::getMACString()
|
||||||
{
|
{
|
||||||
String res;
|
String res;
|
||||||
for (int i=0; i<6; i++) {res+= (((char)mac[i]>>4)+'0');res+=(((char)mac[i]&0xf)+'0');}
|
for (int i=0; i<6; i++) {res+= ((String(mac[i]>>4,HEX)));res+=((String(mac[i]&0xf,HEX)));}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,13 +237,22 @@ uint16_t httpHandler(Client& client, String request, uint8_t method, long conten
|
|||||||
debugSerial<<request<<endl;
|
debugSerial<<request<<endl;
|
||||||
if (method == HTTP_GET && request == (F("/")))
|
if (method == HTTP_GET && request == (F("/")))
|
||||||
{
|
{
|
||||||
|
|
||||||
ArduinoOTA.sendHttpResponse(client,301,false); // Send only HTTP header, no close socket
|
ArduinoOTA.sendHttpResponse(client,301,false); // Send only HTTP header, no close socket
|
||||||
client.println(
|
client.println(
|
||||||
"Location: http://lazyhome.ru/pwa?mac="+sysConf.getMACString()
|
#ifdef CORS
|
||||||
+"&ip="+Ethernet.localIP()//.toString()
|
//Redirect to cloud PWA application
|
||||||
+"&port="+ OTA_PORT
|
String(F("Location: "))+QUOTE(CORS)+String(F("/pwa"))
|
||||||
|
#else
|
||||||
|
String(F("Location: /index.html"))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+String(F("?mac="))+sysConf.getMACString()
|
||||||
|
+String(F("&ip="))+ toString( Ethernet.localIP())
|
||||||
|
+String(F("&port="))+ OTA_PORT
|
||||||
|
+ String(F("&name="))+deviceName
|
||||||
);
|
);
|
||||||
|
|
||||||
//response+=(F("&ip="));
|
//response+=(F("&ip="));
|
||||||
//todo response+=(Ethernet.localIP());
|
//todo response+=(Ethernet.localIP());
|
||||||
client.println();
|
client.println();
|
||||||
|
|||||||
@@ -415,6 +415,9 @@ for(n = 0; n < 4; n++) {
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String toString(const IPAddress& address){
|
||||||
|
return String() + address[0] + "." + address[1] + "." + address[2] + "." + address[3];
|
||||||
|
}
|
||||||
|
|
||||||
void printIPAddress(IPAddress ipAddress) {
|
void printIPAddress(IPAddress ipAddress) {
|
||||||
for (byte i = 0; i < 4; i++)
|
for (byte i = 0; i < 4; i++)
|
||||||
|
|||||||
@@ -74,3 +74,4 @@ bool executeCommand(aJsonObject* cmd, int8_t toggle, itemCmd _itemCmd, aJsonObje
|
|||||||
itemCmd mapInt(int32_t arg, aJsonObject* map);
|
itemCmd mapInt(int32_t arg, aJsonObject* map);
|
||||||
unsigned long millisNZ(uint8_t shift=0);
|
unsigned long millisNZ(uint8_t shift=0);
|
||||||
serialParamType str2SerialParam(char * str);
|
serialParamType str2SerialParam(char * str);
|
||||||
|
String toString(const IPAddress& address);
|
||||||
|
|||||||
Reference in New Issue
Block a user