V2.17 230227 alle unbekannten Seiten Leiten auf die IP um
This commit is contained in:
130
ESPNTUhrPx.ino
130
ESPNTUhrPx.ino
@@ -1,4 +1,13 @@
|
|||||||
#define VERSION (char *) "V2.11"
|
#define VERSION (char *) "V2.17"
|
||||||
|
|
||||||
|
/*
|
||||||
|
V2.12 230205 neues SDK 8266; AP+Wifi Client; lokaleip eingebaut
|
||||||
|
V2.13 230206 Datum/Uhrzeit zeit auch KW an
|
||||||
|
V2.14 230208 AP+STA nur wenn Wifi verbunden ist sonst geht der AP nicht
|
||||||
|
V2.15 230212 Verbesserung AP_STA modus;Wlan auf 1 Connect beschränkt;
|
||||||
|
V2.16 230212 MaxConnect auf 2; Beacon auf 250ms
|
||||||
|
V2.17 230227 alle unbekannten Seiten Leiten auf die IP um
|
||||||
|
*/
|
||||||
|
|
||||||
// Pins for LED MATRIX
|
// Pins for LED MATRIX
|
||||||
#include <Ticker.h>
|
#include <Ticker.h>
|
||||||
@@ -10,7 +19,7 @@
|
|||||||
#define P_D 0
|
#define P_D 0
|
||||||
//#define P_E 0
|
//#define P_E 0
|
||||||
#define P_OE 2
|
#define P_OE 2
|
||||||
#define PxMATRIX_COLOR_DEPTH 3 // This is how many color levels the display shows - the more the slower the update
|
#define PxMATRIX_COLOR_DEPTH 2 // This is how many color levels the display shows - the more the slower the update
|
||||||
#define double_buffer // Creates a second buffer for backround drawing (doubles the required RAM)
|
#define double_buffer // Creates a second buffer for backround drawing (doubles the required RAM)
|
||||||
#define MATRIX_WIDTH 64
|
#define MATRIX_WIDTH 64
|
||||||
#define MATRIX_HEIGHT 32
|
#define MATRIX_HEIGHT 32
|
||||||
@@ -33,10 +42,25 @@
|
|||||||
IPAddress ip_local(192, 168, 13, 1);
|
IPAddress ip_local(192, 168, 13, 1);
|
||||||
IPAddress ip_gateway(192, 168, 13, 1);
|
IPAddress ip_gateway(192, 168, 13, 1);
|
||||||
IPAddress ip_subnet(255, 255, 255, 0);
|
IPAddress ip_subnet(255, 255, 255, 0);
|
||||||
|
char localip[16];
|
||||||
boolean APEnabled = false;
|
boolean APEnabled = false;
|
||||||
char ssid[30] = "THW Freifunk";
|
char ssid[30] = "THW Freifunk";
|
||||||
char pass[30] = "";
|
char pass[30] = "";
|
||||||
char appass[30] = "gibteskeins";
|
char appass[30] = "gibteskeins";
|
||||||
|
|
||||||
|
String toStringIp(IPAddress ip) {
|
||||||
|
String res = "";
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
res += String((ip >> (8 * i)) & 0xFF) + ".";
|
||||||
|
}
|
||||||
|
res += String(((ip >> 8 * 3)) & 0xFF);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void html_handle_notsuccess(AsyncWebServerRequest *request);
|
||||||
|
void html_handle_notsuccess(AsyncWebServerRequest *request){
|
||||||
|
request->send(200, "text/html", String("<a href='http://") + toStringIp(ip_local) + String("'>zur Konfigurationsseite</a><script> location.href = 'http://") + toStringIp(ip_local) + String("'; </script>"));
|
||||||
|
}
|
||||||
|
|
||||||
//permanenter Speicher
|
//permanenter Speicher
|
||||||
#include <ESP_EEPROM.h>
|
#include <ESP_EEPROM.h>
|
||||||
@@ -119,10 +143,10 @@ void LineV(uint8_t x, uint8_t y, uint8_t z, uint8_t red, uint8_t green, uint8_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
//eigene Schriften
|
//eigene Schriften
|
||||||
#include "D:\arduino\Projekte\_includes\char3x5.h"
|
#include <char3x5.h>
|
||||||
#include "D:\arduino\Projekte\_includes\char5x7.h"
|
#include <char5x7.h>
|
||||||
#include "D:\arduino\Projekte\_includes\char6x8.h"
|
#include <char6x8.h>
|
||||||
#include "D:\arduino\Projekte\_includes\char10x16.h"
|
#include <char10x16.h>
|
||||||
|
|
||||||
void doClearLEDsSeconds(int8_t ycorrection=0){
|
void doClearLEDsSeconds(int8_t ycorrection=0){
|
||||||
|
|
||||||
@@ -344,12 +368,6 @@ void drawSeconds(time_t t,int8_t ycorrection=0){
|
|||||||
|
|
||||||
void showTimeTactical(time_t t){
|
void showTimeTactical(time_t t){
|
||||||
uint16_t tmp = 0;
|
uint16_t tmp = 0;
|
||||||
uint8_t x = 0;
|
|
||||||
uint8_t y = 0;
|
|
||||||
|
|
||||||
uint8_t r = timeColor[0];
|
|
||||||
uint8_t g = timeColor[1];
|
|
||||||
uint8_t b = timeColor[2];
|
|
||||||
|
|
||||||
tmp = minute(t);
|
tmp = minute(t);
|
||||||
if(lastminutes != tmp){
|
if(lastminutes != tmp){
|
||||||
@@ -393,7 +411,7 @@ void drawDate(time_t t){
|
|||||||
uint8_t g = dateColor[1];
|
uint8_t g = dateColor[1];
|
||||||
uint8_t b = dateColor[2];
|
uint8_t b = dateColor[2];
|
||||||
uint8_t x = 2;
|
uint8_t x = 2;
|
||||||
uint8_t y = 3;
|
uint8_t y = 0;
|
||||||
|
|
||||||
UnixTime stamp(0);
|
UnixTime stamp(0);
|
||||||
stamp.getDateTime(t);
|
stamp.getDateTime(t);
|
||||||
@@ -455,9 +473,17 @@ void drawDate(time_t t){
|
|||||||
void showDateTime(time_t t){
|
void showDateTime(time_t t){
|
||||||
doClearLEDs();
|
doClearLEDs();
|
||||||
drawDate(t);
|
drawDate(t);
|
||||||
drawTime(t);
|
drawTime(t,-6);
|
||||||
if(withSeconds)
|
if(withSeconds)
|
||||||
drawSeconds(t);
|
drawSeconds(t,-6);
|
||||||
|
uint8_t kw = GetWeekNumber(year(t),month(t),day(t));
|
||||||
|
char str[6];
|
||||||
|
char kws[3];
|
||||||
|
itoa(kw,kws,10);
|
||||||
|
strcpy(str, "KW ");
|
||||||
|
strcat(str, kws);
|
||||||
|
|
||||||
|
show3x5(0,26,str,kwColor[0],kwColor[1],kwColor[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t clock_center_x = 16;
|
uint8_t clock_center_x = 16;
|
||||||
@@ -723,6 +749,9 @@ void setup() {
|
|||||||
strcpy(APName, "NTUhr VPx ");
|
strcpy(APName, "NTUhr VPx ");
|
||||||
strcat(APName, ChipID);
|
strcat(APName, ChipID);
|
||||||
|
|
||||||
|
|
||||||
|
WiFi.persistent(false);
|
||||||
|
WiFi.mode(WIFI_AP_STA);
|
||||||
WiFi.begin(ssid,pass);
|
WiFi.begin(ssid,pass);
|
||||||
WiFi.hostname(NetName);
|
WiFi.hostname(NetName);
|
||||||
int xc = 0;
|
int xc = 0;
|
||||||
@@ -733,7 +762,6 @@ void setup() {
|
|||||||
display_doupdate();
|
display_doupdate();
|
||||||
}
|
}
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
char localip[16];
|
|
||||||
char str[5];
|
char str[5];
|
||||||
IPAddress lip;
|
IPAddress lip;
|
||||||
lip = WiFi.localIP();
|
lip = WiFi.localIP();
|
||||||
@@ -764,14 +792,11 @@ void setup() {
|
|||||||
if(timenow > SECS_YR_2000){
|
if(timenow > SECS_YR_2000){
|
||||||
timenow += 1;
|
timenow += 1;
|
||||||
int Year;
|
int Year;
|
||||||
byte Month, Day, Hour, Minute, Second;
|
byte Month, Day, Hour;
|
||||||
setTime(timenow);
|
setTime(timenow);
|
||||||
Year = year(timenow);
|
Year = year(timenow);
|
||||||
Month = month(timenow);
|
|
||||||
Day = day(timenow);
|
Day = day(timenow);
|
||||||
Hour = hour(timenow);
|
Hour = hour(timenow);
|
||||||
Minute = minute(timenow);
|
|
||||||
Second = second(timenow);
|
|
||||||
if(isDayLight(Hour,Day,weekday(),Month))
|
if(isDayLight(Hour,Day,weekday(),Month))
|
||||||
timenow += (SECS_PER_HOUR * 2);
|
timenow += (SECS_PER_HOUR * 2);
|
||||||
else
|
else
|
||||||
@@ -793,18 +818,19 @@ void setup() {
|
|||||||
display_doupdate();
|
display_doupdate();
|
||||||
alwaysAccessPoint = true;
|
alwaysAccessPoint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(alwaysAccessPoint){
|
if(alwaysAccessPoint){
|
||||||
WiFi.disconnect();
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
delay(1000);
|
WiFi.disconnect();
|
||||||
ESP.eraseConfig();
|
delay(100);
|
||||||
delay(1000);
|
WiFi.mode(WIFI_OFF);
|
||||||
WiFi.mode(WIFI_OFF);
|
delay(100);
|
||||||
WiFi.mode(WIFI_AP);
|
WiFi.mode(WIFI_AP);
|
||||||
delay(1000);
|
}
|
||||||
|
|
||||||
|
delay(100);
|
||||||
WiFi.softAPConfig(ip_local, ip_gateway, ip_subnet);
|
WiFi.softAPConfig(ip_local, ip_gateway, ip_subnet);
|
||||||
//appass = ;
|
//appass = ;
|
||||||
APEnabled = WiFi.softAP(APName, appass,2,0,1);
|
APEnabled = WiFi.softAP(APName, appass,2,0,2,250);
|
||||||
if(!APEnabled)
|
if(!APEnabled)
|
||||||
display.drawPixelRGB888(3,0,255,0,0);
|
display.drawPixelRGB888(3,0,255,0,0);
|
||||||
else
|
else
|
||||||
@@ -818,17 +844,19 @@ void setup() {
|
|||||||
display_doupdate();
|
display_doupdate();
|
||||||
|
|
||||||
//für die automatische Umleitung
|
//für die automatische Umleitung
|
||||||
webServer.on("/generate_204", HTTP_GET, [](AsyncWebServerRequest *request){html_redirect(request);}); //Android captive portal.
|
/*webServer.on("/generate_204", HTTP_GET, [](AsyncWebServerRequest *request){html_root(request);}); //Android captive portal.
|
||||||
webServer.on("/fwlink", HTTP_GET, [](AsyncWebServerRequest *request){html_redirect(request);}); //Microsoft captive portal.
|
webServer.on("/fwlink", HTTP_GET, [](AsyncWebServerRequest *request){html_root(request);}); //Microsoft captive portal.
|
||||||
webServer.on("/connecttest.txt", HTTP_GET, [](AsyncWebServerRequest *request){html_redirect(request);}); //www.msftconnecttest.com
|
webServer.on("/connecttest.txt", HTTP_GET, [](AsyncWebServerRequest *request){html_root(request);}); //www.msftconnecttest.com
|
||||||
webServer.on("/hotspot-detect.html", HTTP_GET, [](AsyncWebServerRequest *request){html_redirect(request);}); //captive.apple.com
|
webServer.on("/hotspot-detect.html", HTTP_GET, [](AsyncWebServerRequest *request){html_root(request);}); //captive.apple.com
|
||||||
webServer.on("/success.txt", HTTP_GET, [](AsyncWebServerRequest *request){html_handle_success(request);}); //detectportal.firefox.com/sucess.txt
|
webServer.on("/success.txt", HTTP_GET, [](AsyncWebServerRequest *request){html_handle_success(request);}); //detectportal.firefox.com/sucess.txt
|
||||||
webServer.onNotFound([](AsyncWebServerRequest *request){html_redirect(request);});
|
webServer.on("/redirect", HTTP_GET, [](AsyncWebServerRequest *request){html_root(request);}); //Microsoft captive portal.*/
|
||||||
|
webServer.onNotFound([](AsyncWebServerRequest *request){html_handle_notsuccess(request);});
|
||||||
|
|
||||||
//eigene Seiten
|
//eigene Seiten
|
||||||
webServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request){html_root(request);});
|
webServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request){html_root(request);});
|
||||||
webServer.on("/do", HTTP_GET, [] (AsyncWebServerRequest *request) {html_do(request);});
|
webServer.on("/do", HTTP_GET, [] (AsyncWebServerRequest *request) {html_do(request);});
|
||||||
webServer.on("/poll", HTTP_GET, [] (AsyncWebServerRequest *request) {html_poll(request);});
|
webServer.on("/poll", HTTP_GET, [] (AsyncWebServerRequest *request) {html_poll(request);});
|
||||||
|
//webServer.on("/resetAP", HTTP_GET, [] (AsyncWebServerRequest *request) {html_resetAP(request);});
|
||||||
|
|
||||||
AsyncElegantOTA.begin(&webServer); // Start AsyncElegantOTA
|
AsyncElegantOTA.begin(&webServer); // Start AsyncElegantOTA
|
||||||
webServer.begin();
|
webServer.begin();
|
||||||
@@ -856,7 +884,7 @@ void loop(){
|
|||||||
Minute = minute(currentUNIXTime);
|
Minute = minute(currentUNIXTime);
|
||||||
Second = second(currentUNIXTime);
|
Second = second(currentUNIXTime);
|
||||||
WDay = weekday();
|
WDay = weekday();
|
||||||
if((isDayLight(Hour,Day,WDay,Month) != iDL) && ((Month == 10 & Hour >= 3) | (Month == 3))){
|
if((isDayLight(Hour,Day,WDay,Month) != iDL) && (((Month == 10) & (Hour >= 3)) | (Month == 3))){
|
||||||
if(iDL){
|
if(iDL){
|
||||||
doSetTime(currentUNIXTime - SECS_PER_HOUR);
|
doSetTime(currentUNIXTime - SECS_PER_HOUR);
|
||||||
}else{
|
}else{
|
||||||
@@ -887,6 +915,7 @@ void loop(){
|
|||||||
showAnalogTime(currentUNIXTime);
|
showAnalogTime(currentUNIXTime);
|
||||||
showAnalogDate(currentUNIXTime);
|
showAnalogDate(currentUNIXTime);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
display_doupdate();
|
display_doupdate();
|
||||||
@@ -1091,12 +1120,22 @@ void html_do(AsyncWebServerRequest *request) {
|
|||||||
request->send(200, "text/plain", "NOK");
|
request->send(200, "text/plain", "NOK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void html_resetAP(AsyncWebServerRequest *request) {
|
||||||
|
String s_value = "";
|
||||||
|
s_value.toCharArray(appass, 30);
|
||||||
|
EEPROM.put(151,appass);
|
||||||
|
EEPROM.commit();
|
||||||
|
request->send(200, "text/plain", "OK");
|
||||||
|
}
|
||||||
|
|
||||||
// Replaces placeholder with button section in your web page
|
// Replaces placeholder with button section in your web page
|
||||||
char * html_processor(const String& var){
|
char * html_processor(const String& var){
|
||||||
if(var == "VERSION"){
|
if(var == "VERSION"){
|
||||||
return VERSION;
|
return VERSION;
|
||||||
}else if(var == "ID"){
|
}else if(var == "ID"){
|
||||||
return ChipID;
|
return ChipID;
|
||||||
|
}else if(var == "LOCALIP"){
|
||||||
|
return localip;
|
||||||
}
|
}
|
||||||
return (char *) "not defined";
|
return (char *) "not defined";
|
||||||
}
|
}
|
||||||
@@ -1108,23 +1147,4 @@ String toggleState(int toggle){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String toStringIp(IPAddress ip) {
|
|
||||||
String res = "";
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
res += String((ip >> (8 * i)) & 0xFF) + ".";
|
|
||||||
}
|
|
||||||
res += String(((ip >> 8 * 3)) & 0xFF);
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void html_redirect(AsyncWebServerRequest *request){
|
|
||||||
AsyncWebServerResponse *response = request->beginResponse(302, "text/plain", ""); // Empty content inhibits Content-length header so we have to close the socket ourselves.
|
|
||||||
response->addHeader("Location", String("http://") + toStringIp(ip_local));
|
|
||||||
request->send(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
void html_handle_success(AsyncWebServerRequest *request){
|
|
||||||
request->send(200, "text/plain", "success");
|
|
||||||
}
|
|
||||||
1500
PxMatrix.h
1500
PxMatrix.h
File diff suppressed because it is too large
Load Diff
@@ -175,6 +175,7 @@ const char html_page_index[] PROGMEM = R"rawliteral(
|
|||||||
<h1>N-Tools Uhr VPx</h1>
|
<h1>N-Tools Uhr VPx</h1>
|
||||||
<h3>`VERSION`</h3>
|
<h3>`VERSION`</h3>
|
||||||
<h3>`ID`</h3>
|
<h3>`ID`</h3>
|
||||||
|
<span style='font-size: 0.7rem;'>lokale IP: `LOCALIP`</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="site" class="site">
|
<div id="site" class="site">
|
||||||
<div id="message"></div>
|
<div id="message"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user