@@ -562,12 +562,12 @@ void ArduinoIoTCloudTCP::handleMessage(int length)
562
562
}
563
563
}
564
564
565
- void ArduinoIoTCloudTCP::sendPropertiesToCloud ( )
565
+ void ArduinoIoTCloudTCP::sendPropertyContainerToCloud (PropertyContainer & property_container )
566
566
{
567
567
int bytes_encoded = 0 ;
568
568
uint8_t data[MQTT_TRANSMIT_BUFFER_SIZE];
569
569
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)
571
571
if (bytes_encoded > 0 )
572
572
{
573
573
/* If properties have been encoded store them in the back-up buffer
@@ -580,11 +580,13 @@ void ArduinoIoTCloudTCP::sendPropertiesToCloud()
580
580
}
581
581
}
582
582
583
- void ArduinoIoTCloudTCP::sendOTAPropertiesToCloud ()
583
+ void ArduinoIoTCloudTCP::sendPropertiesToCloud ()
584
584
{
585
- int bytes_encoded = 0 ;
586
- uint8_t data[MQTT_TRANSMIT_BUFFER_SIZE];
585
+ sendPropertyContainerToCloud (_property_container) ;
586
+ }
587
587
588
+ void ArduinoIoTCloudTCP::sendOTAPropertiesToCloud ()
589
+ {
588
590
PropertyContainer to_property_container;
589
591
PropertyContainer from_property_container = _property_container;
590
592
@@ -599,17 +601,7 @@ void ArduinoIoTCloudTCP::sendOTAPropertiesToCloud()
599
601
}
600
602
);
601
603
602
- if (CBOREncoder::encode (to_property_container, data, sizeof (data), bytes_encoded, false ) == CborNoError)
603
- if (bytes_encoded > 0 )
604
- {
605
- /* If properties have been encoded store them in the back-up buffer
606
- * in order to allow retransmission in case of failure.
607
- */
608
- _mqtt_data_len = bytes_encoded;
609
- memcpy (_mqtt_data_buf, data, _mqtt_data_len);
610
- /* Transmit the properties to the MQTT broker */
611
- write (_dataTopicOut, _mqtt_data_buf, _mqtt_data_len);
612
- }
604
+ sendPropertyContainerToCloud (to_property_container);
613
605
}
614
606
615
607
void ArduinoIoTCloudTCP::requestLastValue ()
0 commit comments