34
34
#endif
35
35
36
36
#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
37
- # include < algorithm>
38
37
# include " tls/utility/SHA256.h"
39
38
# include < stm32h7xx_hal_rtc_ex.h>
40
39
# include < WiFi.h>
41
40
#endif
42
41
43
42
#include " utility/ota/OTA.h"
44
43
#include " utility/ota/FlashSHA256.h"
45
-
44
+ # include < algorithm >
46
45
#include " cbor/CBOREncoder.h"
47
46
48
47
#include " utility/watchdog/Watchdog.h"
@@ -516,7 +515,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
516
515
/* Clear the request flag. */
517
516
_ota_req = false ;
518
517
/* Transmit the cleared error and request flags to the cloud. */
519
- sendPropertiesToCloud ();
518
+ sendOTAPropertiesToCloud ();
520
519
/* Call member function to handle OTA request. */
521
520
onOTARequest ();
522
521
}
@@ -563,12 +562,12 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
563
562
}
564
563
}
565
564
566
- void ArduinoIoTCloudTCP::sendPropertiesToCloud ( )
565
+ void ArduinoIoTCloudTCP::sendPropertyContainerToCloud (PropertyContainer & property_container )
567
566
{
568
567
int bytes_encoded = 0 ;
569
568
uint8_t data[MQTT_TRANSMIT_BUFFER_SIZE];
570
569
571
- if (CBOREncoder::encode (_property_container , data, sizeof (data), bytes_encoded, false ) == CborNoError)
570
+ if (CBOREncoder::encode (property_container , data, sizeof (data), bytes_encoded, false ) == CborNoError)
572
571
if (bytes_encoded > 0 )
573
572
{
574
573
/* If properties have been encoded store them in the back-up buffer
@@ -581,6 +580,29 @@ void ArduinoIoTCloudTCP::sendPropertiesToCloud()
581
580
}
582
581
}
583
582
583
+ void ArduinoIoTCloudTCP::sendPropertiesToCloud ()
584
+ {
585
+ sendPropertyContainerToCloud (_property_container);
586
+ }
587
+
588
+ void ArduinoIoTCloudTCP::sendOTAPropertiesToCloud ()
589
+ {
590
+ PropertyContainer ota_property_container;
591
+
592
+ std::list<String> const ota_property_list {" OTA_CAP" , " OTA_ERROR" , " OTA_SHA256" , " OTA_URL" , " OTA_REQ" };
593
+ std::for_each (ota_property_list.cbegin (),
594
+ ota_property_list.cend (),
595
+ [this , &ota_property_container ] (String const & name)
596
+ {
597
+ Property* p = getProperty (this ->_property_container , name);
598
+ if (p != nullptr )
599
+ addPropertyToContainer (ota_property_container, *p, p->name (), p->isWriteableByCloud () ? Permission::ReadWrite : Permission::Read);
600
+ }
601
+ );
602
+
603
+ sendPropertyContainerToCloud (ota_property_container);
604
+ }
605
+
584
606
void ArduinoIoTCloudTCP::requestLastValue ()
585
607
{
586
608
// Send the getLastValues CBOR message to the cloud
0 commit comments