 }
 
 void mqttCallback(const char* topic_, const byte* payload_, unsigned int length) {
-  Serial.print("Message arrived [");
+  Serial.print(F("Message arrived ["));
   Serial.print(topic_);
-  Serial.print("] ");
+  Serial.print(F("] "));
   for (int i = 0; i < length; i++) {
     Serial.print((char)payload_[i]);
   }

  beatLED.on();
  // Loop until we're reconnected
  while (!mqtt.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (mqtt.connect(mainTopic.c_str(), mainTopic.c_str(), 0, true, "offline")) {
      Serial.println("connected");
      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((globalTopic + "/send/+").c_str());
    } else {
      Serial.print("failed, rc=");
      Serial.print(mqtt.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      beatLED.off();
      delay(500);

    beatLED.off();
    delay(500);
    beatLED.on();
    Serial.print(F("."));
  }

  Serial.println();
  Serial.println(F("WiFi connected"));
  Serial.println(F("IP address: "));
  Serial.println(WiFi.localIP());
}

void transmitt(const String &protocol, const char *message) {
  Serial.print(F("rf send "));
  Serial.print(message);
  Serial.print(F(" with protocol "));
  Serial.println(protocol);

  if (protocol == F("RAW")) {
    int rawpulses[MAXPULSESTREAMLENGTH];
    int rawlen = rf.stringToPulseTrain(message, rawpulses, MAXPULSESTREAMLENGTH);
    if (rawlen > 0) {
