@@ -555,6 +555,8 @@ ZtpResponse pointperfectTryZtpToken(String &ztpRequest)
555
555
strncpy (tempHolderPtr, (const char *)((*jsonZtp)[" privateKey" ]), MQTT_CERT_SIZE - 1 );
556
556
recordFile (" privateKey" , tempHolderPtr, strlen (tempHolderPtr));
557
557
558
+ free (tempHolderPtr); // Clean up. Done with tempHolderPtr
559
+
558
560
// Validate the keys
559
561
if (!checkCertificates ())
560
562
{
@@ -732,7 +734,10 @@ bool checkCertificates()
732
734
free (keyContents);
733
735
734
736
if (settings.debugPpCertificate )
735
- systemPrintln (" Stored certificates are valid!" );
737
+ {
738
+ systemPrintf (" Stored certificates are %svalid\r\n " , validCertificates ? " " : " NOT " );
739
+ }
740
+
736
741
return (validCertificates);
737
742
}
738
743
@@ -816,6 +821,7 @@ bool pointperfectUpdateKeys()
816
821
do
817
822
{
818
823
// Allocate the buffers
824
+ // Freed outside the do loop
819
825
if (online.psram == true )
820
826
{
821
827
certificateContents = (char *)ps_malloc (MQTT_CERT_SIZE);
@@ -829,8 +835,6 @@ bool pointperfectUpdateKeys()
829
835
830
836
if ((!certificateContents) || (!keyContents))
831
837
{
832
- if (certificateContents)
833
- free (certificateContents);
834
838
systemPrintln (" Failed to allocate content buffers!" );
835
839
break ;
836
840
}
@@ -858,6 +862,8 @@ bool pointperfectUpdateKeys()
858
862
// Configure the MQTT client
859
863
menuppMqttClient->setId (settings.pointPerfectClientID );
860
864
menuppMqttClient->onMessage (mqttCallback);
865
+ menuppMqttClient->setKeepAliveInterval (10 * 1000 );
866
+ menuppMqttClient->setConnectionTimeout ( 5 * 1000 );
861
867
862
868
// Attempt to the MQTT broker
863
869
systemPrintf (" Attempting to connect to MQTT broker: %s\r\n " , settings.pointPerfectBrokerHost );
@@ -933,6 +939,8 @@ bool pointperfectUpdateKeys()
933
939
menuppMqttClient = nullptr ;
934
940
}
935
941
942
+ secureClient.stop ();
943
+
936
944
// Free the content buffers
937
945
if (keyContents)
938
946
free (keyContents);
0 commit comments