branding
This commit is contained in:
parent
337c5e00a0
commit
300df03808
|
@ -2,7 +2,9 @@
|
||||||
#include <ESP8266MQTTMesh.h>
|
#include <ESP8266MQTTMesh.h>
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
|
|
||||||
|
// |----------------------------------|
|
||||||
|
// | SIWAT INC |
|
||||||
|
// |----------------------------------|
|
||||||
#define FIRMWARE_ID 0x1337
|
#define FIRMWARE_ID 0x1337
|
||||||
#define FIRMWARE_VER "0.1"
|
#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("ssid 1", "Password", NULL, 0),WIFI_CONN("ssid 2", "Another Password", NULL, 0),NULL,};
|
||||||
|
@ -15,19 +17,16 @@ String ID = String(ESP.getChipId());
|
||||||
unsigned long previousMillis = 0;
|
unsigned long previousMillis = 0;
|
||||||
const long interval = 5000;
|
const long interval = 5000;
|
||||||
int cnt = 0;
|
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).build();
|
||||||
// Note: All of the '.set' options below are optional. The default values can be
|
,
|
||||||
// found in ESP8266MQTTMeshBuilder.h
|
void callback(const char *topic, const char *msg); //define initial callback
|
||||||
ESP8266MQTTMesh mesh = ESP8266MQTTMesh::Builder(networks, mqtt_server, mqtt_port).setVersion(FIRMWARE_VER, FIRMWARE_ID).setMeshPassword(mesh_password).build();
|
|
||||||
|
|
||||||
void callback(const char *topic, const char *msg);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
delay(1000); //This is only here to make it easier to catch the startup messages. It isn't required
|
delay(1000);
|
||||||
mesh.setCallback(callback);
|
mesh.setCallback(callback);
|
||||||
mesh.begin();
|
mesh.begin();
|
||||||
|
|
||||||
|
@ -35,23 +34,13 @@ void setup() {
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
if (! mesh.connected())return;
|
||||||
|
|
||||||
if (! mesh.connected())
|
|
||||||
return;
|
|
||||||
|
|
||||||
unsigned long currentMillis = millis();
|
unsigned long currentMillis = millis();
|
||||||
|
|
||||||
if (currentMillis - previousMillis >= interval) {
|
if (currentMillis - previousMillis >= interval) {
|
||||||
|
mesh.publish("", msg.c_str());
|
||||||
String cntStr = String(cnt);
|
|
||||||
String msg = "hello from " + ID + " cnt: " + cntStr;
|
|
||||||
mesh.publish(ID.c_str(), msg.c_str());
|
|
||||||
previousMillis = currentMillis;
|
previousMillis = currentMillis;
|
||||||
cnt++;
|
cnt++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue