2024-09-2400

This commit is contained in:
hans-jurgen 2024-09-24 11:15:49 +02:00
parent 18e2cc2eb9
commit 8994baad3c
2 changed files with 22 additions and 8 deletions

View File

@ -24,12 +24,12 @@ lib_deps =
build_flags = ${env.build_flags}
-DDEBUG=0
-DNOADS=0
-DNAME=\"BLE_GATE\"
-DNAME=\"BLE-Praesenz\"
-DSTASSID=\"MagentaWLAN-RGDO\"
-DSTAPSK=\"93329248424922704583\"
-DGATEWAY=\"192.168.127.1\"
-DDNS=\"192.168.127.1\"
-DKMYIP=\"192.168.127.42\"
-DKMYIP=\"192.168.127.241\"
-Dmqtt_server=\"192.168.127.193\"
-Dmqtt_port=1883

View File

@ -37,11 +37,13 @@ int scanTime = 5; //In seconds
long int Feldstaerke;
// WiFI
IPAddress ip( 192, 168, 127, 241 ); // 10 bis 29 für feste IP
IPAddress gateway( 192, 168, 127, 1 );
IPAddress subnet( 255, 255, 255, 0 );
IPAddress dns(192, 168, 127, 1); // DNS-Server
IPAddress ip;
IPAddress gateway;
IPAddress subnet(255,255,255,0);
IPAddress dns;
IPAddress secondaryDNS(8, 8, 8, 8);
String hostname = NAME;
const char *MyIP = KMYIP;
char msg[20];
char clientName[30];
char topic[50];
@ -96,8 +98,20 @@ static void setup_wifi() {
WiFi.persistent( false );
WiFi.setHostname(hostname.c_str()); //define hostname
WiFi.mode( WIFI_STA );
WiFi.config( ip, gateway, subnet, dns, dns );
if (!ip.fromString(MyIP)) { // try to parse into the IPAddress
Serial.println("UnParsable IP");
}
if (!dns.fromString(DNS)) { // try to parse into the IPAddress
Serial.println("UnParsable DNS");
}
if (!gateway.fromString(GATEWAY)) { // try to parse into the IPAddress
Serial.println("UnParsable GATEWAY");
}
//WiFi.config( ip, dns, gateway, subnet );
if (!WiFi.config(ip, gateway, subnet, dns, secondaryDNS))
{
Serial.println("STA Failed to configure");
}
WiFi.begin (STASSID, STAPSK);
while (WiFi.status() != WL_CONNECTED) {