@@ -661,18 +661,18 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
661
661
/* Clear the request flag. */
662
662
_ota_req = false ;
663
663
/* Transmit the cleared request flags to the cloud. */
664
- sendClearedOTARequestToCloud ( );
664
+ sendDevicePropertyToCloud ( " OTA_REQ " );
665
665
/* Call member function to handle OTA request. */
666
666
onOTARequest ();
667
667
/* If something fails send the OTA error to the cloud */
668
- sendOTAErrorToCloud ( );
668
+ sendDevicePropertyToCloud ( " OTA_ERROR " );
669
669
}
670
670
}
671
671
672
672
/* Check if we have received the OTA_URL property and provide
673
673
* echo to the cloud.
674
674
*/
675
- sendOTAUrlToCloud ( );
675
+ sendDevicePropertyToCloud ( " OTA_URL " );
676
676
677
677
#endif /* OTA_ENABLED */
678
678
@@ -782,61 +782,17 @@ void ArduinoIoTCloudTCP::sendDevicePropertiesToCloud()
782
782
}
783
783
784
784
#if OTA_ENABLED
785
- void ArduinoIoTCloudTCP::sendClearedOTARequestToCloud ( )
785
+ void ArduinoIoTCloudTCP::sendDevicePropertyToCloud (String const name )
786
786
{
787
- PropertyContainer ota_property_container;
788
- unsigned int last_ota_property_index = 0 ;
789
-
790
- std::list<String> ota_property_list {" OTA_REQ" };
791
- std::for_each (ota_property_list.begin (),
792
- ota_property_list.end (),
793
- [this , &ota_property_container ] (String const & name)
794
- {
795
- Property* p = getProperty (this ->_device_property_container , name);
796
- if (p != nullptr )
797
- addPropertyToContainer (ota_property_container, *p, p->name (), p->isWriteableByCloud () ? Permission::ReadWrite : Permission::Read);
798
- }
799
- );
800
-
801
- sendPropertyContainerToCloud (_deviceTopicOut, ota_property_container, last_ota_property_index);
802
- }
803
-
804
- void ArduinoIoTCloudTCP::sendOTAErrorToCloud ()
805
- {
806
- PropertyContainer ota_property_container;
807
- unsigned int last_ota_property_index = 0 ;
808
-
809
- std::list<String> ota_property_list {" OTA_ERROR" };
810
- std::for_each (ota_property_list.begin (),
811
- ota_property_list.end (),
812
- [this , &ota_property_container ] (String const & name)
813
- {
814
- Property* p = getProperty (this ->_device_property_container , name);
815
- if (p != nullptr )
816
- addPropertyToContainer (ota_property_container, *p, p->name (), p->isWriteableByCloud () ? Permission::ReadWrite : Permission::Read);
817
- }
818
- );
819
-
820
- sendPropertyContainerToCloud (_deviceTopicOut, ota_property_container, last_ota_property_index);
821
- }
822
-
823
- void ArduinoIoTCloudTCP::sendOTAUrlToCloud ()
824
- {
825
- PropertyContainer ota_property_container;
826
- unsigned int last_ota_property_index = 0 ;
827
-
828
- std::list<String> ota_property_list {" OTA_URL" };
829
- std::for_each (ota_property_list.begin (),
830
- ota_property_list.end (),
831
- [this , &ota_property_container ] (String const & name)
832
- {
833
- Property* p = getProperty (this ->_device_property_container , name);
834
- if (p != nullptr )
835
- addPropertyToContainer (ota_property_container, *p, p->name (), p->isWriteableByCloud () ? Permission::ReadWrite : Permission::Read);
836
- }
837
- );
787
+ PropertyContainer temp_device_property_container;
788
+ unsigned int last_device_property_index = 0 ;
838
789
839
- sendPropertyContainerToCloud (_deviceTopicOut, ota_property_container, last_ota_property_index);
790
+ Property* p = getProperty (this ->_device_property_container , name);
791
+ if (p != nullptr )
792
+ {
793
+ addPropertyToContainer (temp_device_property_container, *p, p->name (), p->isWriteableByCloud () ? Permission::ReadWrite : Permission::Read);
794
+ sendPropertyContainerToCloud (_deviceTopicOut, temp_device_property_container, last_device_property_index);
795
+ }
840
796
}
841
797
#endif
842
798
0 commit comments