Compare commits

...

2 Commits

Author SHA1 Message Date
8994baad3c 2024-09-2400 2024-09-24 11:15:49 +02:00
18e2cc2eb9 2024-09-2304 2024-09-23 16:33:16 +02:00
2 changed files with 26 additions and 12 deletions

View File

@ -24,12 +24,12 @@ lib_deps =
build_flags = ${env.build_flags} build_flags = ${env.build_flags}
-DDEBUG=0 -DDEBUG=0
-DNOADS=0 -DNOADS=0
-DNAME=\"BLE_GATE\" -DNAME=\"BLE-Praesenz\"
-DSTASSID=\"MagentaWLAN-RGDO\" -DSTASSID=\"MagentaWLAN-RGDO\"
-DSTAPSK=\"93329248424922704583\" -DSTAPSK=\"93329248424922704583\"
-DGATEWAY=\"192.168.127.1\" -DGATEWAY=\"192.168.127.1\"
-DDNS=\"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_server=\"192.168.127.193\"
-Dmqtt_port=1883 -Dmqtt_port=1883

View File

@ -22,26 +22,28 @@ PubSubClient client(espClient);
#define mqtt_port 1883 #define mqtt_port 1883
//cf:d7:ab:1f:24:2c //cf:d7:ab:1f:24:2c
//String Adresse = "96:33:bb:bf:ff:ab"; // Bluetooth Adresse die zu Anwesenheitserkennung überwacht wird ET585 String Adresse = "96:33:bb:bf:ff:ab"; // Bluetooth Adresse die zu Anwesenheitserkennung überwacht wird ET585
String Adresse = "cf:d7:ab:1f:24:2c"; // Bluetooth Adresse die zu Anwesenheitserkennung überwacht wird Holy-IOT //String Adresse = "cf:d7:ab:1f:24:2c"; // Bluetooth Adresse die zu Anwesenheitserkennung überwacht wird Holy-IOT
const int RelaisPin = LED_BUILTIN; // Pin an dem Relais hängt const int RelaisPin = LED_BUILTIN; // Pin an dem Relais hängt
int Verzoegerung = 15; // Auschaltverzögerung wenn das Signal von BLE ibeacon fehlt int Verzoegerung = 30; // Auschaltverzögerung wenn das Signal von BLE ibeacon fehlt
int VerzoegerungZaeler = 0; int VerzoegerungZaeler = 0;
//long int ZZ = 0; //long int ZZ = 0;
Ticker Tic; Ticker Tic;
static BLEAddress *pServerAddress; static BLEAddress *pServerAddress;
BLEScan* pBLEScan ; BLEScan* pBLEScan ;
int scanTime = 10; //In seconds int scanTime = 5; //In seconds
long int Feldstaerke; long int Feldstaerke;
// WiFI // WiFI
IPAddress ip( 192, 168, 127, 241 ); // 10 bis 29 für feste IP IPAddress ip;
IPAddress gateway( 192, 168, 127, 1 ); IPAddress gateway;
IPAddress subnet( 255, 255, 255, 0 ); IPAddress subnet(255,255,255,0);
IPAddress dns(192, 168, 127, 1); // DNS-Server IPAddress dns;
IPAddress secondaryDNS(8, 8, 8, 8);
String hostname = NAME; String hostname = NAME;
const char *MyIP = KMYIP;
char msg[20]; char msg[20];
char clientName[30]; char clientName[30];
char topic[50]; char topic[50];
@ -96,8 +98,20 @@ static void setup_wifi() {
WiFi.persistent( false ); WiFi.persistent( false );
WiFi.setHostname(hostname.c_str()); //define hostname WiFi.setHostname(hostname.c_str()); //define hostname
WiFi.mode( WIFI_STA ); 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); WiFi.begin (STASSID, STAPSK);
while (WiFi.status() != WL_CONNECTED) { while (WiFi.status() != WL_CONNECTED) {