Merge pull request #4 in WAT/waterishos-generation-2-rev-1.0 from development to master

* commit '4310f55d05a0a05d0356e7aedbf6bc117e3b312f':
  add debug serial print
  uplaod first error free source
  add wifi library and code diagnostic
  code cleanup
  branding
This commit is contained in:
Siwat Sirichai 2019-08-21 13:27:17 +00:00
commit d4330672e8
1 changed files with 38 additions and 36 deletions

View File

@ -1,61 +1,63 @@
#include <ESP8266mDNS.h>
#include <ESP8266mDNS_Legacy.h>
#include <LEAmDNS.h>
#include <LEAmDNS_lwIPdefs.h>
#include <LEAmDNS_Priv.h>
#include <BearSSLHelpers.h>
#include <CertStoreBearSSL.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiAP.h>
#include <ESP8266WiFiGeneric.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266WiFiScan.h>
#include <ESP8266WiFiSTA.h>
#include <ESP8266WiFiType.h>
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <WiFiClientSecureAxTLS.h>
#include <WiFiClientSecureBearSSL.h>
#include <WiFiServer.h>
#include <WiFiServerSecure.h>
#include <WiFiServerSecureAxTLS.h>
#include <WiFiServerSecureBearSSL.h>
#include <WiFiUdp.h>
#include <ESP8266WiFiMesh.h>
#include <NetworkInfo.h>
#include <TransmissionResult.h>
#include <TypeConversionFunctions.h>
#include "settings.h" #include "settings.h"
#include <ESP8266MQTTMesh.h> #include <ESP8266MQTTMesh.h>
#include <FS.h> #include <FS.h>
wifi_conn networks[] = {WIFI_CONN(wifi_ssid, wifi_password, NULL, 0),NULL};
// |----------------------------------|
#define FIRMWARE_ID 0x1337 // | SIWAT INC |
#define FIRMWARE_VER "0.1" // |----------------------------------|
wifi_conn networks[] = {WIFI_CONN("ssid 1", "Password", NULL, 0),WIFI_CONN("ssid 2", "Another Password", NULL, 0),NULL,};
String ID = String(ESP.getChipId()); 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).setMeshSSID(mesh_ssid).build();
// 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();
void callback(const char *topic, const char *msg); 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 Serial.print("Loading . . .");
delay(1000);
mesh.setCallback(callback); mesh.setCallback(callback);
Serial.print("Callback set done");
mesh.begin(); mesh.begin();
Serial.print("Mesh Started");
} }
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("/test","test");
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++;
} }
} }
void callback(const char *topic, const char *msg) { void callback(const char *topic, const char *msg) {
Serial.print(topic); Serial.print(topic);
Serial.print(msg); Serial.print(msg);