Merged mqtt
This commit is contained in:
parent
aad35e20bd
commit
a270faa480
@ -39,7 +39,7 @@ build_flags =
|
||||
-D EMBED_HTML # If this is not used the html files needs to be on the file system (can be uploaded)
|
||||
-D USER_SSID=\""\"" # =\""myssid\""
|
||||
-D USER_SSID_PWD=\""\"" # =\""mypwd\""
|
||||
-D CFG_APPVER="\"0.5.2\""
|
||||
-D CFG_APPVER="\"0.5.3\""
|
||||
lib_deps = # Switched to forks for better version control.
|
||||
# Using local copy of this library
|
||||
#https://github.com/jrowberg/i2cdevlib.git#<document>
|
||||
@ -52,7 +52,7 @@ lib_deps = # Switched to forks for better version control.
|
||||
https://github.com/mp-se/OneWire#v2.3.6 # https://github.com/PaulStoffregen/OneWire
|
||||
https://github.com/mp-se/Arduino-Temperature-Control-Library#3.9.1 # https://github.com/milesburton/Arduino-Temperature-Control-Library
|
||||
https://github.com/mp-se/arduinoCurveFitting#v1.0.6 # https://github.com/Rotario/arduinoCurveFitting
|
||||
https://github.com/256dpi/arduino-mqtt
|
||||
https://github.com/mp-se/arduino-mqtt#v2.5.0 # https://github.com/256dpi/arduino-mqtt
|
||||
|
||||
[env:gravity-debug]
|
||||
upload_speed = ${common_env_data.upload_speed}
|
||||
|
@ -283,7 +283,7 @@ void PushTarget::sendMqtt(float angle, float gravity, float corrGravity,
|
||||
createIspindleFormat(doc, angle, gravity, corrGravity, temp, runTime);
|
||||
|
||||
WiFiClient client;
|
||||
MQTTClient mqtt(512); // Maximum message size
|
||||
MQTTClient mqtt(512); // Maximum message size
|
||||
|
||||
mqtt.begin(myConfig.getMqttUrl(), client);
|
||||
mqtt.connect(myConfig.getMDNS(), myConfig.getMqttUser(),
|
||||
@ -301,7 +301,8 @@ void PushTarget::sendMqtt(float angle, float gravity, float corrGravity,
|
||||
if (mqtt.publish(myConfig.getMqttTopic(), json)) {
|
||||
Log.notice(F("PUSH: MQTT publish successful" CR));
|
||||
} else {
|
||||
Log.error(F("PUSH: MQTT publish failed err=%d, ret=%d" CR), mqtt.lastError(), mqtt.returnCode());
|
||||
Log.error(F("PUSH: MQTT publish failed err=%d, ret=%d" CR),
|
||||
mqtt.lastError(), mqtt.returnCode());
|
||||
}
|
||||
|
||||
mqtt.disconnect();
|
||||
|
21
src/wifi.cpp
21
src/wifi.cpp
@ -87,11 +87,11 @@ bool WifiConnection::hasConfig() {
|
||||
// Check if there are stored WIFI Settings we can use.
|
||||
String ssid = WiFi.SSID();
|
||||
if (ssid.length()) {
|
||||
Log.notice(F("WIFI: Found credentials in EEPORM." CR));
|
||||
myConfig.setWifiSSID(WiFi.SSID());
|
||||
myConfig.setWifiPass(WiFi.psk());
|
||||
myConfig.saveFile();
|
||||
return true;
|
||||
Log.notice(F("WIFI: Found credentials in EEPORM." CR));
|
||||
myConfig.setWifiSSID(WiFi.SSID());
|
||||
myConfig.setWifiPass(WiFi.psk());
|
||||
myConfig.saveFile();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -109,7 +109,9 @@ String WifiConnection::getIPAddress() { return WiFi.localIP().toString(); }
|
||||
//
|
||||
// Additional method to detect double reset.
|
||||
//
|
||||
bool WifiConnection::isDoubleResetDetected() { return myDRD->detectDoubleReset(); }
|
||||
bool WifiConnection::isDoubleResetDetected() {
|
||||
return myDRD->detectDoubleReset();
|
||||
}
|
||||
|
||||
//
|
||||
// Stop double reset detection
|
||||
@ -171,16 +173,17 @@ void WifiConnection::connectAsync() {
|
||||
// Blocks until wifi connection has been found
|
||||
//
|
||||
bool WifiConnection::waitForConnection(int maxTime) {
|
||||
#if DEBUG_LEVEL == 6
|
||||
#if DEBUG_LEVEL == 6
|
||||
WiFi.printDiag(Serial);
|
||||
#endif
|
||||
int i = 0;
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(100);
|
||||
|
||||
if ( i % 10 ) Serial.print(".");
|
||||
if (i % 10) Serial.print(".");
|
||||
|
||||
if (i++ > (maxTime*10)) { // Try for maxTime seconds. Since delay is 100ms.
|
||||
if (i++ >
|
||||
(maxTime * 10)) { // Try for maxTime seconds. Since delay is 100ms.
|
||||
Log.error(F("WIFI: Failed to connect to wifi %d, aborting %s." CR),
|
||||
WiFi.status(), getIPAddress().c_str());
|
||||
WiFi.disconnect();
|
||||
|
Loading…
Reference in New Issue
Block a user