Skip to content

Commit

Permalink
Use constants instead of static strings
Browse files Browse the repository at this point in the history
  • Loading branch information
schinken committed Mar 11, 2017
1 parent 3c78d20 commit 6f2dd1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions esp8266-geigercounter.ino
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion settings.h.example
Expand Up @@ -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 = "----";

Expand Down

0 comments on commit 6f2dd1b

Please sign in to comment.