 /** Called once at startup */
 void setup() {
 	////// INIT //////
+	// TODO: Get publishPeriodMs from EEPROM
+	publishPeriodMs = MQTT_PUBLISH_PERIOD_MS;
+	publishTs = 0;
+	updateConfigTs = 0;
+	connectCounter = 0;
+	firstPublish = false;
 
 	/// HW UART ///
 	Uart *hwUart = new HwUart({HW_UART_SPEED});

			Lpm::idle(MQTT_DISCONNECTED_IDLE_PERIOD_MS);
			networkWakeUp(NETWORK_WAKE_UP_DELAY_MS);
		} else {
			// Do the publish immediately after reconnect
			firstPublish = true;
			// Listen for configuration
			LOG_PRINTFLN("Waiting the configuration for %lu ms", MQTT_LISTEN_TIME_MS);
			mqtt->yield(MQTT_LISTEN_TIME_MS);
		}
	} else {
		// Connected

		if (rc != MqttClient::Error::SUCCESS) {
			LOG_PRINTFLN("ERROR, Connect, rc:%i", rc);
		} else {
			if (updateConfig()) {
				// Success
				updateConfigTs = time.millis();
				return;
			}
		}
	}
	// Failure => disconnect
	network->disconnect();
}

bool updateConfig() {
	bool res = false;
	if (mqtt->isConnected()) {
		const char* topic = MQTT_SUBSCRIBE_TOPIC_CFG;
		LOG_PRINTFLN("Subscribe to %s", topic);
		MqttClient::Error::type rc = mqtt->subscribe(topic, MQTT_SUBSCRIBE_QOS, processMessageConfig);
		if (rc != MqttClient::Error::SUCCESS) {
			LOG_PRINTFLN("ERROR, Subscribe, rc:%i", rc);
		} else {
			// Listen for configuration
			LOG_PRINTFLN("Waiting the configuration for %lu ms", MQTT_LISTEN_TIME_MS);
			mqtt->yield(MQTT_LISTEN_TIME_MS);
			rc = mqtt->unsubscribe(topic);
			if (rc != MqttClient::Error::SUCCESS) {
				LOG_PRINTFLN("ERROR, Unsubscribe, rc:%i", rc);
			} else {
				// Success
				res = true;
			}
		}
	}
	if (!res) {
		LOG_PRINTFLN("Drop connection");
		mqtt->disconnect();
	}
	return res;
}

void processMessageConfig(MqttClient::MessageData& md) {
