@@ -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
@@ -774,61 +774,17 @@ void ArduinoIoTCloudTCP::sendDevicePropertiesToCloud()
774
774
}
775
775
776
776
#if OTA_ENABLED
777
- void ArduinoIoTCloudTCP::sendClearedOTARequestToCloud ( )
777
+ void ArduinoIoTCloudTCP::sendDevicePropertyToCloud (String const name )
778
778
{
779
- PropertyContainer ota_property_container;
780
- unsigned int last_ota_property_index = 0 ;
781
-
782
- std::list<String> ota_property_list {" OTA_REQ" };
783
- std::for_each (ota_property_list.begin (),
784
- ota_property_list.end (),
785
- [this , &ota_property_container ] (String const & name)
786
- {
787
- Property* p = getProperty (this ->_device_property_container , name);
788
- if (p != nullptr )
789
- addPropertyToContainer (ota_property_container, *p, p->name (), p->isWriteableByCloud () ? Permission::ReadWrite : Permission::Read);
790
- }
791
- );
792
-
793
- sendPropertyContainerToCloud (_deviceTopicOut, ota_property_container, last_ota_property_index);
794
- }
795
-
796
- void ArduinoIoTCloudTCP::sendOTAErrorToCloud ()
797
- {
798
- PropertyContainer ota_property_container;
799
- unsigned int last_ota_property_index = 0 ;
800
-
801
- std::list<String> ota_property_list {" OTA_ERROR" };
802
- std::for_each (ota_property_list.begin (),
803
- ota_property_list.end (),
804
- [this , &ota_property_container ] (String const & name)
805
- {
806
- Property* p = getProperty (this ->_device_property_container , name);
807
- if (p != nullptr )
808
- addPropertyToContainer (ota_property_container, *p, p->name (), p->isWriteableByCloud () ? Permission::ReadWrite : Permission::Read);
809
- }
810
- );
811
-
812
- sendPropertyContainerToCloud (_deviceTopicOut, ota_property_container, last_ota_property_index);
813
- }
814
-
815
- void ArduinoIoTCloudTCP::sendOTAUrlToCloud ()
816
- {
817
- PropertyContainer ota_property_container;
818
- unsigned int last_ota_property_index = 0 ;
819
-
820
- std::list<String> ota_property_list {" OTA_URL" };
821
- std::for_each (ota_property_list.begin (),
822
- ota_property_list.end (),
823
- [this , &ota_property_container ] (String const & name)
824
- {
825
- Property* p = getProperty (this ->_device_property_container , name);
826
- if (p != nullptr )
827
- addPropertyToContainer (ota_property_container, *p, p->name (), p->isWriteableByCloud () ? Permission::ReadWrite : Permission::Read);
828
- }
829
- );
779
+ PropertyContainer temp_device_property_container;
780
+ unsigned int last_device_property_index = 0 ;
830
781
831
- sendPropertyContainerToCloud (_deviceTopicOut, ota_property_container, last_ota_property_index);
782
+ Property* p = getProperty (this ->_device_property_container , name);
783
+ if (p != nullptr )
784
+ {
785
+ addPropertyToContainer (temp_device_property_container, *p, p->name (), p->isWriteableByCloud () ? Permission::ReadWrite : Permission::Read);
786
+ sendPropertyContainerToCloud (_deviceTopicOut, temp_device_property_container, last_device_property_index);
787
+ }
832
788
}
833
789
#endif
834
790
0 commit comments