diff --git a/waterishos-gen2-mesh/waterishos-gen2-mesh.ino b/waterishos-gen2-mesh/waterishos-gen2-mesh.ino index c122ded..5287242 100644 --- a/waterishos-gen2-mesh/waterishos-gen2-mesh.ino +++ b/waterishos-gen2-mesh/waterishos-gen2-mesh.ino @@ -1,61 +1,63 @@ +#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 - - -#define FIRMWARE_ID 0x1337 -#define FIRMWARE_VER "0.1" -wifi_conn networks[] = {WIFI_CONN("ssid 1", "Password", NULL, 0),WIFI_CONN("ssid 2", "Another Password", NULL, 0),NULL,}; - +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; - -// Note: All of the '.set' options below are optional. The default values can be -// found in ESP8266MQTTMeshBuilder.h -ESP8266MQTTMesh mesh = ESP8266MQTTMesh::Builder(networks, mqtt_server, mqtt_port).setVersion(FIRMWARE_VER, FIRMWARE_ID).setMeshPassword(mesh_password).build(); - +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); - delay(1000); //This is only here to make it easier to catch the startup messages. It isn't required + Serial.print("Loading . . ."); + delay(1000); mesh.setCallback(callback); + Serial.print("Callback set done"); mesh.begin(); - + Serial.print("Mesh Started"); } void loop() { - - - if (! mesh.connected()) - return; - + if (! mesh.connected())return; unsigned long currentMillis = millis(); - if (currentMillis - previousMillis >= interval) { - - String cntStr = String(cnt); - String msg = "hello from " + ID + " cnt: " + cntStr; - mesh.publish(ID.c_str(), msg.c_str()); + mesh.publish("/test","test"); previousMillis = currentMillis; cnt++; - } - } - - - void callback(const char *topic, const char *msg) { Serial.print(topic); Serial.print(msg);