@@ -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,6 +218,10 @@ char* BootNormal::_prefixMqttTopic(PGM_P topic) {
211
218
}
212
219
213
220
bool BootNormal::_publishOtaStatus (int status, const char * info) {
221
+ long randNumber = random (10 );
222
+ if (randNumber < 8 )
223
+ return false ;
224
+
214
225
String payload (status);
215
226
if (info) {
216
227
payload.concat (F (" " ));
@@ -779,6 +790,13 @@ void BootNormal::_onMqttDisconnected(AsyncMqttClientDisconnectReason reason) {
779
790
}
780
791
781
792
void BootNormal::_onMqttMessage (char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index , size_t total) {
793
+ /*
794
+ Interface::get().getLogger() << F("BootNormal::_onMqttMessage") << endl;
795
+ Interface::get().getLogger() << "topic > " << topic << endl;
796
+ Interface::get().getLogger() << "len > " << len << endl;
797
+ Interface::get().getLogger() << "index > " << index << endl;
798
+ Interface::get().getLogger() << "total > " << total << endl;
799
+ */
782
800
if (total == 0 ) return ; // no empty message possible
783
801
784
802
if (index == 0 ) {
@@ -875,6 +893,13 @@ bool HomieInternals::BootNormal::__fillPayloadBuffer(char * topic, char * payloa
875
893
}
876
894
877
895
bool HomieInternals::BootNormal::__handleOTAUpdates (char * topic, char * payload, const AsyncMqttClientMessageProperties& properties, size_t len, size_t index , size_t total) {
896
+ /*
897
+ Interface::get().getLogger() << F("HomieInternals::BootNormal::__handleOTAUpdates...") << endl;
898
+ Interface::get().getLogger() << "0 > " << _mqttTopicLevels.get()[0] << endl;
899
+ Interface::get().getLogger() << "1 > " << _mqttTopicLevels.get()[1] << endl;
900
+ Interface::get().getLogger() << "2 > " << _mqttTopicLevels.get()[2] << endl;
901
+ Interface::get().getLogger() << "3 > " << _mqttTopicLevels.get()[3] << endl;
902
+ */
878
903
if (
879
904
_mqttTopicLevelsCount == 5
880
905
&& strcmp (_mqttTopicLevels.get ()[0 ], Interface::get ().getConfig ().get ().deviceId ) == 0
@@ -1047,6 +1072,7 @@ bool HomieInternals::BootNormal::__handleOTAUpdates(char* topic, char* payload,
1047
1072
}
1048
1073
return true ;
1049
1074
}
1075
+ Interface::get ().getLogger () << F (" HomieInternals::BootNormal::__handleOTAUpdates FALSE" ) << endl;
1050
1076
return false ;
1051
1077
}
1052
1078
0 commit comments