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