3434#endif
3535
3636#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
37- # include < algorithm>
3837# include " tls/utility/SHA256.h"
3938# include < stm32h7xx_hal_rtc_ex.h>
4039# include < WiFi.h>
4140#endif
4241
4342#include " utility/ota/OTA.h"
4443#include " utility/ota/FlashSHA256.h"
45-
44+ # include < algorithm >
4645#include " cbor/CBOREncoder.h"
4746
4847#include " utility/watchdog/Watchdog.h"
@@ -516,7 +515,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
516515 /* Clear the request flag. */
517516 _ota_req = false ;
518517 /* Transmit the cleared error and request flags to the cloud. */
519- sendPropertiesToCloud ();
518+ sendOTAPropertiesToCloud ();
520519 /* Call member function to handle OTA request. */
521520 onOTARequest ();
522521 }
@@ -563,12 +562,12 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
563562 }
564563}
565564
566- void ArduinoIoTCloudTCP::sendPropertiesToCloud ( )
565+ void ArduinoIoTCloudTCP::sendPropertyContainerToCloud (PropertyContainer & property_container )
567566{
568567 int bytes_encoded = 0 ;
569568 uint8_t data[MQTT_TRANSMIT_BUFFER_SIZE];
570569
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)
572571 if (bytes_encoded > 0 )
573572 {
574573 /* If properties have been encoded store them in the back-up buffer
@@ -581,6 +580,29 @@ void ArduinoIoTCloudTCP::sendPropertiesToCloud()
581580 }
582581}
583582
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+
584606void ArduinoIoTCloudTCP::requestLastValue ()
585607{
586608 // Send the getLastValues CBOR message to the cloud
0 commit comments