 #include <algorithm>
 #include <string>
 
-// Configuration parameters
+// ---------------------- Board Related Settings -------------------------------
+// NOTE: Make sure you set your Serial Monitor to the same speed.
+#define BAUD_RATE 115200  // Serial port Baud rate.
+
 // GPIO the IR LED is connected to/controlled by. GPIO 4 = D2.
 #define IR_LED 4  // <=- CHANGE_ME (optional)
 // define IR_LED 3  // For an ESP-01 we suggest you use RX/GPIO3/Pin 7.

#endif  // IR_RX

#if DEBUG
  // Use SERIAL_TX_ONLY so that the RX pin can be freed up for GPIO/IR use.
  Serial.begin(BAUD_RATE, SERIAL_8N1, SERIAL_TX_ONLY);
  while (!Serial)  // Wait for the serial connection to be establised.
    delay(50);
  Serial.println();
  debug("IRMQTTServer " _MY_VERSION_" has booted.");
#endif  // DEBUG

  setup_wifi();

const uint32_t kStatListenPeriodMs = 5 * 1000;  // mSeconds
#endif  // MQTT_ENABLE

#if DEBUG
bool isSerialGpioUsedByIr(void) {
  const uint8_t kSerialTxGpio = 1;  // The GPIO serial output is sent too.
                                    // Note: *DOES NOT* control Serial output.
  // Ensure we are not trodding on anything IR related.
#ifdef IR_RX
  if (IR_RX == kSerialTxGpio)
    return true;  // Serial port is in use by IR capture. Abort.
#endif  // IR_RX
  for (uint8_t i = 0; i < kSendTableSize; i++)
    if (gpioTable[i] == kSerialTxGpio)
      return true;  // Serial port is in use for IR sending. Abort.
  return false;  // Not in use as far as we can tell.
}
#endif  // DEBUG

// Debug messages get sent to the serial port.
void debug(String str) {
#if DEBUG
  if (isSerialGpioUsedByIr()) return;  // Abort.
  uint32_t now = millis();
  Serial.printf("%07u.%03u: %s\n", now / 1000, now % 1000, str.c_str());
#endif  // DEBUG
