From f287e4ee95229ac451c6702c86930b6b8dfa2df3 Mon Sep 17 00:00:00 2001 From: Kirk Davis Date: Sat, 28 May 2016 20:36:18 -0600 Subject: [PATCH 1/3] Allow setting the hostname Allows setting the hostname if MY_ESP6266_HOSTNAME is defined. --- libraries/MySensors/core/MyGatewayTransportEthernet.cpp | 3 +++ libraries/MySensors/core/MyGatewayTransportMQTTClient.cpp | 3 +++ .../MySensors/examples/GatewayESP8266/GatewayESP8266.ino | 4 ++++ .../GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/libraries/MySensors/core/MyGatewayTransportEthernet.cpp b/libraries/MySensors/core/MyGatewayTransportEthernet.cpp index 4b70655..0cecce6 100644 --- a/libraries/MySensors/core/MyGatewayTransportEthernet.cpp +++ b/libraries/MySensors/core/MyGatewayTransportEthernet.cpp @@ -103,6 +103,9 @@ bool gatewayTransportInit() { #if defined(MY_ESP8266_SSID) // Turn off access point WiFi.mode (WIFI_STA); + #if defined(MY_ESP8266_HOSTNAME) + WiFi.hostname(MY_EPS8266_HOSTNAME); + #endif (void)WiFi.begin(MY_ESP8266_SSID, MY_ESP8266_PASSWORD); #ifdef MY_IP_ADDRESS WiFi.config(_ethernetGatewayIP, gateway, subnet); diff --git a/libraries/MySensors/core/MyGatewayTransportMQTTClient.cpp b/libraries/MySensors/core/MyGatewayTransportMQTTClient.cpp index a2c1d6c..326d349 100644 --- a/libraries/MySensors/core/MyGatewayTransportMQTTClient.cpp +++ b/libraries/MySensors/core/MyGatewayTransportMQTTClient.cpp @@ -167,6 +167,9 @@ bool gatewayTransportInit() { #if defined(MY_GATEWAY_ESP8266) // Turn off access point WiFi.mode (WIFI_STA); + #if defined(MY_ESP8266_HOSTNAME) + WiFi.hostname(MY_ESP8266_HOSTNAME); + #endif (void)WiFi.begin(MY_ESP8266_SSID, MY_ESP8266_PASSWORD); #ifdef MY_IP_ADDRESS WiFi.config(_clientIp, _gatewayIp, _subnetIp); diff --git a/libraries/MySensors/examples/GatewayESP8266/GatewayESP8266.ino b/libraries/MySensors/examples/GatewayESP8266/GatewayESP8266.ino index 803eb7d..142a1b4 100644 --- a/libraries/MySensors/examples/GatewayESP8266/GatewayESP8266.ino +++ b/libraries/MySensors/examples/GatewayESP8266/GatewayESP8266.ino @@ -86,6 +86,10 @@ // Enable UDP communication //#define MY_USE_UDP +// Set the hostname for the WiFi Client. This is the hostname +// it will pass to the DHCP server if not static. +// #define MY_ESP8266_HOSTNAME "sensor-gateway" + // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) //#define MY_IP_ADDRESS 192,168,178,87 diff --git a/libraries/MySensors/examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino b/libraries/MySensors/examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino index 60d052e..1e77c3c 100644 --- a/libraries/MySensors/examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino +++ b/libraries/MySensors/examples/GatewayESP8266MQTTClient/GatewayESP8266MQTTClient.ino @@ -88,6 +88,10 @@ #define MY_ESP8266_SSID "MySSID" #define MY_ESP8266_PASSWORD "MyVerySecretPassword" +// Set the hostname for the WiFi Client. This is the hostname +// it will pass to the DHCP server if not static. +// #define MY_ESP8266_HOSTNAME "mqtt-sensor-gateway" + // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) #define MY_IP_ADDRESS 192,168,178,87 From 2d9748d1a36126c658cb95c6b651828685c0df7d Mon Sep 17 00:00:00 2001 From: Kirk Davis Date: Sun, 29 May 2016 09:25:16 -0600 Subject: [PATCH 2/3] Include MY_ESP8266_HOSTNAME include the MY_ESP8266HOSTNAME in Keyword.txt for pull request #451 --- libraries/MySensors/keywords.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/MySensors/keywords.txt b/libraries/MySensors/keywords.txt index 2f9ef73..78adbfd 100644 --- a/libraries/MySensors/keywords.txt +++ b/libraries/MySensors/keywords.txt @@ -97,6 +97,7 @@ MY_GATEWAY_MAX_SEND_LENGTH LITERAL1 MY_GATEWAY_MAX_RECEIVE_LENGTH LITERAL1 MY_ESP8266_SSID LITERAL1 MY_ESP8266_PASSWORD LITERAL1 +MY_ESP8266_HOSTNAME LITERAL1 MY_IP_GATEWAY_ADDRESS LITERAL1 MY_IP_SUBNET_ADDRESS LITERAL1 MY_W5100_SPI_EN LITERAL1 From 76852c044c6103d830072082e4b5b00ed8845a4d Mon Sep 17 00:00:00 2001 From: Kirk Davis Date: Sun, 29 May 2016 10:23:04 -0600 Subject: [PATCH 3/3] Additional example for MY_ESP8266_HOSTNAME Additional example for pull request #451 This adds in comments and the MY_ESP8266_HOSTNAME definition. --- .../examples/GatewayESP8266OTA/GatewayESP8266OTA.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/MySensors/examples/GatewayESP8266OTA/GatewayESP8266OTA.ino b/libraries/MySensors/examples/GatewayESP8266OTA/GatewayESP8266OTA.ino index bb19188..142d058 100644 --- a/libraries/MySensors/examples/GatewayESP8266OTA/GatewayESP8266OTA.ino +++ b/libraries/MySensors/examples/GatewayESP8266OTA/GatewayESP8266OTA.ino @@ -85,6 +85,10 @@ #define MY_ESP8266_SSID "MySSID" #define MY_ESP8266_PASSWORD "MyVerySecretPassword" +// Set the hostname for the WiFi Client. This is the hostname +// it will pass to the DHCP server if not static. +// #define MY_ESP8266_HOSTNAME "sensor-ota-gateway" + // Enable UDP communication //#define MY_USE_UDP