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
+26 -7

No files matched your search

+20 -2
View File
@@ -17,6 +17,8 @@
- crankyoldgit - crankyoldgit
- Spudtater - Spudtater
- rickybrent - 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 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(); setup_wifi();
#else #else
//Begining ethernet connection in case of Arduino + W5100 //Begining ethernet connection in case of Arduino + W5100
Ethernet.begin(mac, ip); setup_ethernet();
#endif #endif
delay(1500); delay(1500);
@@ -150,8 +152,14 @@ void setup_wifi() {
// We start by connecting to a WiFi network // We start by connecting to a WiFi network
trc(F("Connecting to ")); trc(F("Connecting to "));
trc(wifi_ssid); 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.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) { while (WiFi.status() != WL_CONNECTED) {
delay(500); delay(500);
@@ -159,6 +167,16 @@ void setup_wifi() {
} }
trc(F("WiFi connected")); 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 #endif
void loop() void loop()
+6 -5
View File
@@ -12,10 +12,6 @@
Copyright: (c)1technophile Copyright: (c)1technophile
Contributors:
- crankyoldgit
- Spudtater
Permission is hereby granted, free of charge, to any person obtaining a copy of this software 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, and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
@@ -48,9 +44,14 @@ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT
#define wifi_password "wifi password" #define wifi_password "wifi password"
#else // for arduino + W5100 #else // for arduino + W5100
const byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0x54, 0x95 }; //W5100 ethernet shield mac adress 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 #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 //Addons management, comment the line if you don't use
//#define ZaddonDHT true //#define ZaddonDHT true