code cleanup
This commit is contained in:
parent
300df03808
commit
1abc8bc03c
|
@ -18,18 +18,14 @@ 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();
|
ESP8266MQTTMesh mesh = ESP8266MQTTMesh::Builder(networks, mqtt_server, mqtt_port).setMqttAuth(mqtt_user, mqtt_password).setVersion(FIRMWARE_VER, FIRMWARE_ID).setMeshPassword(mesh_password).build();
|
||||||
,
|
void callback(const char *topic, const char *msg);
|
||||||
void callback(const char *topic, const char *msg); //define initial callback
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
mesh.setCallback(callback);
|
mesh.setCallback(callback);
|
||||||
mesh.begin();
|
mesh.begin();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,7 +33,7 @@ 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());
|
mesh.publish("/test","test");
|
||||||
previousMillis = currentMillis;
|
previousMillis = currentMillis;
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue