#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "settings.h" #include #include wifi_conn networks[] = {WIFI_CONN(wifi_ssid, wifi_password, NULL, 0),NULL}; // |----------------------------------| // | SIWAT INC | // |----------------------------------| String ID = String(ESP.getChipId()); unsigned long previousMillis = 0; const long interval = 5000; int cnt = 0; ESP8266MQTTMesh mesh = ESP8266MQTTMesh::Builder(networks, mqtt_server, mqtt_port).setMqttAuth(mqtt_user, mqtt_password).setVersion(FIRMWARE_VER, FIRMWARE_ID).setMeshPassword(mesh_password).setMeshSSID(mesh_ssid).build(); void callback(const char *topic, const char *msg); void setup() { Serial.begin(115200); Serial.print("Loading . . ."); delay(1000); mesh.setCallback(callback); mesh.begin(); } void loop() { if (! mesh.connected())return; unsigned long currentMillis = millis(); if (currentMillis - previousMillis >= interval) { mesh.publish("/test","test"); previousMillis = currentMillis; cnt++; } } void callback(const char *topic, const char *msg) { Serial.print(topic); Serial.print(msg); }