Fixed mqtt issues
This commit is contained in:
parent
a83a74b5a4
commit
aad35e20bd
@ -226,7 +226,7 @@
|
|||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label for="mqtt-push" class="col-sm-2 col-form-label">MQTT Server:</label>
|
<label for="mqtt-push" class="col-sm-2 col-form-label">MQTT Server:</label>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<input type="url" maxlength="40" class="form-control" name="mqtt-push" id="mqtt-push">
|
<input type="text" maxlength="40" class="form-control" name="mqtt-push" id="mqtt-push">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
|
File diff suppressed because one or more lines are too long
@ -283,7 +283,7 @@ void PushTarget::sendMqtt(float angle, float gravity, float corrGravity,
|
|||||||
createIspindleFormat(doc, angle, gravity, corrGravity, temp, runTime);
|
createIspindleFormat(doc, angle, gravity, corrGravity, temp, runTime);
|
||||||
|
|
||||||
WiFiClient client;
|
WiFiClient client;
|
||||||
MQTTClient mqtt;
|
MQTTClient mqtt(512); // Maximum message size
|
||||||
|
|
||||||
mqtt.begin(myConfig.getMqttUrl(), client);
|
mqtt.begin(myConfig.getMqttUrl(), client);
|
||||||
mqtt.connect(myConfig.getMDNS(), myConfig.getMqttUser(),
|
mqtt.connect(myConfig.getMDNS(), myConfig.getMqttUser(),
|
||||||
@ -292,7 +292,7 @@ void PushTarget::sendMqtt(float angle, float gravity, float corrGravity,
|
|||||||
String json;
|
String json;
|
||||||
serializeJson(doc, json);
|
serializeJson(doc, json);
|
||||||
#if LOG_LEVEL == 6 && !defined(PUSH_DISABLE_LOGGING)
|
#if LOG_LEVEL == 6 && !defined(PUSH_DISABLE_LOGGING)
|
||||||
Log.verbose(F("PUSH: url %s." CR), serverPath.c_str());
|
Log.verbose(F("PUSH: url %s." CR), myConfig.getMqttUrl());
|
||||||
Log.verbose(F("PUSH: json %s." CR), json.c_str());
|
Log.verbose(F("PUSH: json %s." CR), json.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ void PushTarget::sendMqtt(float angle, float gravity, float corrGravity,
|
|||||||
if (mqtt.publish(myConfig.getMqttTopic(), json)) {
|
if (mqtt.publish(myConfig.getMqttTopic(), json)) {
|
||||||
Log.notice(F("PUSH: MQTT publish successful" CR));
|
Log.notice(F("PUSH: MQTT publish successful" CR));
|
||||||
} else {
|
} else {
|
||||||
Log.error(F("PUSH: MQTT publish failed" CR));
|
Log.error(F("PUSH: MQTT publish failed err=%d, ret=%d" CR), mqtt.lastError(), mqtt.returnCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
mqtt.disconnect();
|
mqtt.disconnect();
|
||||||
|
10
src/wifi.cpp
10
src/wifi.cpp
@ -83,6 +83,16 @@ WifiConnection::WifiConnection() {
|
|||||||
bool WifiConnection::hasConfig() {
|
bool WifiConnection::hasConfig() {
|
||||||
if (strlen(myConfig.getWifiSSID())) return true;
|
if (strlen(myConfig.getWifiSSID())) return true;
|
||||||
if (strlen(userSSID)) return true;
|
if (strlen(userSSID)) return true;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user