   while (!mqtt.connected()) {
     Serial.print("Attempting MQTT connection...");
     // Attempt to connect
-    if (mqtt.connect(hostName.c_str(), hostName.c_str(), 0, true, "offline")) {
+    if (mqtt.connect(mainTopic.c_str(), mainTopic.c_str(), 0, true, "offline")) {
       Serial.println("connected");
-      mqtt.publish(hostName.c_str(), "online", true);
-      mqtt.subscribe((hostName + "/set/+").c_str());
-      mqtt.subscribe((hostName + "/ota/+").c_str());
-      mqtt.subscribe((hostName + "/send/+").c_str());
+      mqtt.publish(mainTopic.c_str(), "online", true);
+      mqtt.subscribe((mainTopic + "/set/+").c_str());
+      mqtt.subscribe((mainTopic + "/ota/+").c_str());
+      mqtt.subscribe((mainTopic + "/send/+").c_str());
       mqtt.subscribe((rfTopic + "/send/+").c_str());
     } else {
       Serial.print("failed, rc=");

ESPiLight rf(TRANSMITTER_PIN);
SHAauth otaAuth(myOTA_PASSWD);

const String hostName = String("rfESP_")+String(ESP.getChipId(), HEX);;
const String rfTopic = "rf434";
boolean logMode = false;
boolean rawMode = false;

    mqtt.publish(topic.c_str(), message.c_str(), true);
  }
  if(logMode) {
    String topic = mainTopic + String("/log/") + String(status) + String('/') + protocol;
    mqtt.publish(topic.c_str(), message.c_str());
  }
}
