@@ -77,12 +77,18 @@ void BootNormal::setup() {
77
77
#if ASYNC_TCP_SSL_ENABLED
78
78
Interface::get ().getLogger () << " SSL is: " << Interface::get ().getConfig ().get ().mqtt .server .ssl .enabled << endl;
79
79
Interface::get ().getMqttClient ().setSecure (Interface::get ().getConfig ().get ().mqtt .server .ssl .enabled );
80
- if (Interface::get ().getConfig ().get ().mqtt .server .ssl .enabled && Interface::get ().getConfig ().get ().mqtt .server .ssl .hasFingerprint ) {
80
+ if (Interface::get ().getConfig ().get ().mqtt .server .ssl .enabled ){ // && Interface::get().getConfig().get().mqtt.server.ssl.hasFingerprint) {
81
+ #if defined(ESP8266)
81
82
char hexBuf[MAX_FINGERPRINT_STRING_LENGTH];
82
83
Helpers::byteArrayToHexString (Interface::get ().getConfig ().get ().mqtt .server .ssl .fingerprint , hexBuf, MAX_FINGERPRINT_SIZE);
83
84
Interface::get ().getLogger () << " Using fingerprint: " << hexBuf << endl;
84
85
Interface::get ().getMqttClient ().addServerFingerprint ((const uint8_t *)Interface::get ().getConfig ().get ().mqtt .server .ssl .fingerprint );
86
+ #elif defined(ESP32)
87
+ Interface::get ().getMqttClient ().setPsk (
88
+ Interface::get ().getConfig ().get ().mqtt .server .ssl .psk_ident ,
89
+ Interface::get ().getConfig ().get ().mqtt .server .ssl .psk );
85
90
}
91
+ #endif
86
92
#endif
87
93
88
94
Interface::get ().getMqttClient ().setMaxTopicLength (MAX_MQTT_TOPIC_LENGTH);
@@ -164,6 +170,7 @@ void BootNormal::loop() {
164
170
return ;
165
171
}
166
172
173
+ if (_otaOngoing) return ;
167
174
// here, we have notified the sketch we are ready
168
175
169
176
if (_mqttOfflineMessageId == 0 && Interface::get ().flaggedForSleep ) {
@@ -211,13 +218,20 @@ char* BootNormal::_prefixMqttTopic(PGM_P topic) {
211
218
}
212
219
213
220
bool BootNormal::_publishOtaStatus (int status, const char * info) {
221
+ static uint8_t count = 0 ;
222
+ ++count;
223
+
214
224
String payload (status);
215
225
if (info) {
216
226
payload.concat (F (" " ));
217
227
payload.concat (info);
218
228
}
219
-
220
- return Interface::get ().getMqttClient ().publish (_prefixMqttTopic (PSTR (" /$implementation/ota/status" )), 0 , true , payload.c_str ()) != 0 ;
229
+ if (count == 100 ){
230
+ count = 0 ;
231
+ return Interface::get ().getMqttClient ().publish (
232
+ _prefixMqttTopic (PSTR (" /$implementation/ota/status" )), 0 , true , payload.c_str ()) != 0 ;
233
+ }
234
+ return false ;
221
235
}
222
236
223
237
void BootNormal::_endOtaUpdate (bool success, uint8_t update_error) {
@@ -779,6 +793,13 @@ void BootNormal::_onMqttDisconnected(AsyncMqttClientDisconnectReason reason) {
779
793
}
780
794
781
795
void BootNormal::_onMqttMessage (char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index , size_t total) {
796
+ /*
797
+ Interface::get().getLogger() << F("BootNormal::_onMqttMessage") << endl;
798
+ Interface::get().getLogger() << "topic > " << topic << endl;
799
+ Interface::get().getLogger() << "len > " << len << endl;
800
+ Interface::get().getLogger() << "index > " << index << endl;
801
+ Interface::get().getLogger() << "total > " << total << endl;
802
+ */
782
803
if (total == 0 ) return ; // no empty message possible
783
804
784
805
if (index == 0 ) {
@@ -875,6 +896,13 @@ bool HomieInternals::BootNormal::__fillPayloadBuffer(char * topic, char * payloa
875
896
}
876
897
877
898
bool HomieInternals::BootNormal::__handleOTAUpdates (char * topic, char * payload, const AsyncMqttClientMessageProperties& properties, size_t len, size_t index , size_t total) {
899
+ /*
900
+ Interface::get().getLogger() << F("HomieInternals::BootNormal::__handleOTAUpdates...") << endl;
901
+ Interface::get().getLogger() << "0 > " << _mqttTopicLevels.get()[0] << endl;
902
+ Interface::get().getLogger() << "1 > " << _mqttTopicLevels.get()[1] << endl;
903
+ Interface::get().getLogger() << "2 > " << _mqttTopicLevels.get()[2] << endl;
904
+ Interface::get().getLogger() << "3 > " << _mqttTopicLevels.get()[3] << endl;
905
+ */
878
906
if (
879
907
_mqttTopicLevelsCount == 5
880
908
&& strcmp (_mqttTopicLevels.get ()[0 ], Interface::get ().getConfig ().get ().deviceId ) == 0
@@ -1047,6 +1075,7 @@ bool HomieInternals::BootNormal::__handleOTAUpdates(char* topic, char* payload,
1047
1075
}
1048
1076
return true ;
1049
1077
}
1078
+ Interface::get ().getLogger () << F (" HomieInternals::BootNormal::__handleOTAUpdates FALSE" ) << endl;
1050
1079
return false ;
1051
1080
}
1052
1081
0 commit comments