Use constants instead of static strings

This commit is contained in:
schinken 2017-03-11 11:39:51 +01:00
parent 3c78d20461
commit 6f2dd1b703
2 changed files with 6 additions and 7 deletions

View file

@ -19,13 +19,12 @@ float lastuSv = 0, currentuSv = 0;
void setup() {
WiFi.hostname(WIFI_HOSTNAME);
WiFi.mode(WIFI_STA);
Serial.begin(115200);
geigerCounterSerial.begin(BAUD_GEIGERCOUNTER);
delay(10);
WiFi.hostname(WIFI_HOSTNAME);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
@ -34,7 +33,7 @@ void setup() {
}
mqttClient.setClient(wifiClient);
mqttClient.setServer(mqttHost, 1883);
mqttClient.setServer(MQTT_HOST, 1883);
ArduinoOTA.setHostname(WIFI_HOSTNAME);
ArduinoOTA.setPassword(OTA_PASSWORD);
@ -69,7 +68,7 @@ void updateRadiationValues() {
void connectMqtt() {
while (!mqttClient.connected()) {
if (mqttClient.connect("geigercounter", MQTT_TOPIC_LAST_WILL, 1, true, "disconnected")) {
if (mqttClient.connect(WIFI_HOSTNAME, MQTT_TOPIC_LAST_WILL, 1, true, "disconnected")) {
mqttClient.publish(MQTT_TOPIC_LAST_WILL, "connected", true);
} else {
delay(1000);

View file

@ -15,7 +15,7 @@
#define BAUD_GEIGERCOUNTER 9600
const char* WIFI_HOSTNAME = "ESP-GeigerCounter";
const char* HOSTNAME = "ESP-GeigerCounter";
const char* WIFI_SSID = "----";
const char* WIFI_PASSWORD = "----";