@@ -562,12 +562,12 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
562562 }
563563}
564564
565- void ArduinoIoTCloudTCP::sendPropertiesToCloud ( )
565+ void ArduinoIoTCloudTCP::sendPropertyContainerToCloud (PropertyContainer & property_container )
566566{
567567 int bytes_encoded = 0 ;
568568 uint8_t data[MQTT_TRANSMIT_BUFFER_SIZE];
569569
570- 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)
571571 if (bytes_encoded > 0 )
572572 {
573573 /* If properties have been encoded store them in the back-up buffer
@@ -580,11 +580,13 @@ void ArduinoIoTCloudTCP::sendPropertiesToCloud()
580580 }
581581}
582582
583- void ArduinoIoTCloudTCP::sendOTAPropertiesToCloud ()
583+ void ArduinoIoTCloudTCP::sendPropertiesToCloud ()
584584{
585- int bytes_encoded = 0 ;
586- uint8_t data[MQTT_TRANSMIT_BUFFER_SIZE];
585+ sendPropertyContainerToCloud (_property_container) ;
586+ }
587587
588+ void ArduinoIoTCloudTCP::sendOTAPropertiesToCloud ()
589+ {
588590 PropertyContainer ota_property_container;
589591
590592 std::list<String> const ota_property_list {" OTA_CAP" , " OTA_ERROR" , " OTA_SHA256" , " OTA_URL" , " OTA_REQ" };
@@ -598,17 +600,7 @@ void ArduinoIoTCloudTCP::sendOTAPropertiesToCloud()
598600 }
599601 );
600602
601- if (CBOREncoder::encode (ota_property_container, data, sizeof (data), bytes_encoded, false ) == CborNoError)
602- if (bytes_encoded > 0 )
603- {
604- /* If properties have been encoded store them in the back-up buffer
605- * in order to allow retransmission in case of failure.
606- */
607- _mqtt_data_len = bytes_encoded;
608- memcpy (_mqtt_data_buf, data, _mqtt_data_len);
609- /* Transmit the properties to the MQTT broker */
610- write (_dataTopicOut, _mqtt_data_buf, _mqtt_data_len);
611- }
603+ sendPropertyContainerToCloud (ota_property_container);
612604}
613605
614606void ArduinoIoTCloudTCP::requestLastValue ()
0 commit comments