Add advanced network parameters

#31
This commit is contained in:
1technophile committed 2017-03-25 21:25:23 +01:00
1 parent afe9af8904
commit f39422d23c
2 files changed
+27 -8

No files matched your search

+21 -3
View File
@@ -17,6 +17,8 @@
- crankyoldgit
- Spudtater
- rickybrent
- ekim from Home assistant forum
- ronvl from Home assistant forum
IMPORTANT NOTE: On arduino connect IR emitter pin to D9 , comment #define IR_USE_TIMER2 and uncomment #define IR_USE_TIMER1 on library <library>IRremote/IRremoteInt.h so as to free pin D3 for RF RECEIVER PIN
@@ -123,7 +125,7 @@ void setup()
setup_wifi();
#else
//Begining ethernet connection in case of Arduino + W5100
Ethernet.begin(mac, ip);
setup_ethernet();
#endif
delay(1500);
@@ -150,15 +152,31 @@ void setup_wifi() {
// We start by connecting to a WiFi network
trc(F("Connecting to "));
trc(wifi_ssid);
IPAddress ip_adress(ip);
IPAddress gateway_adress(gateway);
IPAddress subnet_adress(subnet);
IPAddress dns_adress(dns);
WiFi.begin(wifi_ssid, wifi_password);
WiFi.config(ip_adress,gateway_adress,subnet_adress); //Uncomment this line if you want to use advanced network config
trc("OpenMQTTGateway ip adress: ");
Serial.println(WiFi.localIP());
while (WiFi.status() != WL_CONNECTED) {
delay(500);
trc(F("."));
}
trc(F("WiFi connected"));
}
#else
void setup_ethernet() {
Ethernet.begin(mac, ip); //Comment and uncomment the following line if you want to use advanced network config
//Ethernet.begin(mac, ip, dns, gateway, subnet);
trc("My IP address is: ");
trc(String(Ethernet.localIP()));
trc(F("Ethernet connected"));
}
#endif
void loop()
+6 -5
View File
@@ -11,10 +11,6 @@
- publish MQTT data to a different topic related to received IR signal
Copyright: (c)1technophile
Contributors:
- crankyoldgit
- Spudtater
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
@@ -48,9 +44,14 @@ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT
#define wifi_password "wifi password"
#else // for arduino + W5100
const byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0x54, 0x95 }; //W5100 ethernet shield mac adress
const byte ip[] = { 192, 168, 1, 95 }; //W5100 ethernet shield ip adress
#endif
const byte ip[] = { 192, 168, 1, 99 }; //ip adress
// Advanced network config (optional) if you want to use these parameters uncomment line 158 and 172 of OpenMQTTGateway.ino
const byte gateway[] = { 192, 168, 1, 1 }; //ip adress
const byte dns[] = { 192, 168, 1, 1 }; //ip adress
const byte subnet[] = { 255, 255, 255, 0 }; //ip adress
//Addons management, comment the line if you don't use
//#define ZaddonDHT true