@@ -45,7 +45,7 @@ void BootNormal::setup() {
45
45
if (nodeMaxTopicLength > longestSubtopicLength) longestSubtopicLength = nodeMaxTopicLength;
46
46
47
47
for (Property* iProperty : iNode->getProperties ()) {
48
- size_t propertyMaxTopicLength = 1 + strlen (iNode->getId ()) + 1 + strlen (iProperty->getProperty ()) + 1 ;
48
+ size_t propertyMaxTopicLength = 1 + strlen (iNode->getId ()) + 1 + strlen (iProperty->getId ()) + 1 ;
49
49
if (iProperty->isSettable ()) propertyMaxTopicLength += 4 ; // /set
50
50
51
51
if (propertyMaxTopicLength > longestSubtopicLength) longestSubtopicLength = propertyMaxTopicLength;
@@ -477,7 +477,7 @@ void BootNormal::_advertise() {
477
477
strcat_P (subtopic.get (), PSTR (" /$properties" ));
478
478
String properties;
479
479
for (Property* iProperty : node->getProperties ()) {
480
- properties.concat (iProperty->getProperty ());
480
+ properties.concat (iProperty->getId ());
481
481
properties.concat (" ," );
482
482
}
483
483
if (node->getProperties ().size () >= 1 ) properties.remove (properties.length () - 1 );
@@ -508,14 +508,14 @@ void BootNormal::_advertise() {
508
508
{
509
509
HomieNode* node = HomieNode::nodes[_advertisementProgress.currentNodeIndex ];
510
510
Property* iProperty = node->getProperties ()[_advertisementProgress.currentPropertyIndex ];
511
- std::unique_ptr<char []> subtopic = std::unique_ptr<char []>(new char [1 + strlen (node->getId ()) + 1 +strlen (iProperty->getProperty ()) + 10 + 1 ]); // /nodeId/propId/$settable
511
+ std::unique_ptr<char []> subtopic = std::unique_ptr<char []>(new char [1 + strlen (node->getId ()) + 1 +strlen (iProperty->getId ()) + 10 + 1 ]); // /nodeId/propId/$settable
512
512
switch (_advertisementProgress.propertyStep ) {
513
513
case AdvertisementProgress::PropertyStep::PUB_NAME:
514
514
if (iProperty->getName () && (iProperty->getName ()[0 ] != ' \0 ' )) {
515
515
strcpy_P (subtopic.get (), PSTR (" /" ));
516
516
strcat (subtopic.get (), node->getId ());
517
517
strcat_P (subtopic.get (), PSTR (" /" ));
518
- strcat (subtopic.get (), iProperty->getProperty ());
518
+ strcat (subtopic.get (), iProperty->getId ());
519
519
strcat_P (subtopic.get (), PSTR (" /$name" ));
520
520
packetId = Interface::get ().getMqttClient ().publish (_prefixMqttTopic (subtopic.get ()), 1 , true , iProperty->getName ());
521
521
if (packetId != 0 ) _advertisementProgress.propertyStep = AdvertisementProgress::PropertyStep::PUB_SETTABLE;
@@ -528,9 +528,22 @@ void BootNormal::_advertise() {
528
528
strcpy_P (subtopic.get (), PSTR (" /" ));
529
529
strcat (subtopic.get (), node->getId ());
530
530
strcat_P (subtopic.get (), PSTR (" /" ));
531
- strcat (subtopic.get (), iProperty->getProperty ());
531
+ strcat (subtopic.get (), iProperty->getId ());
532
532
strcat_P (subtopic.get (), PSTR (" /$settable" ));
533
533
packetId = Interface::get ().getMqttClient ().publish (_prefixMqttTopic (subtopic.get ()), 1 , true , " true" );
534
+ if (packetId != 0 ) _advertisementProgress.propertyStep = AdvertisementProgress::PropertyStep::PUB_RETAINED;
535
+ } else {
536
+ _advertisementProgress.propertyStep = AdvertisementProgress::PropertyStep::PUB_RETAINED;
537
+ }
538
+ break ;
539
+ case AdvertisementProgress::PropertyStep::PUB_RETAINED:
540
+ if (!iProperty->isRetained ()) {
541
+ strcpy_P (subtopic.get (), PSTR (" /" ));
542
+ strcat (subtopic.get (), node->getId ());
543
+ strcat_P (subtopic.get (), PSTR (" /" ));
544
+ strcat (subtopic.get (), iProperty->getId ());
545
+ strcat_P (subtopic.get (), PSTR (" /$retained" ));
546
+ packetId = Interface::get ().getMqttClient ().publish (_prefixMqttTopic (subtopic.get ()), 1 , true , " false" );
534
547
if (packetId != 0 ) _advertisementProgress.propertyStep = AdvertisementProgress::PropertyStep::PUB_DATATYPE;
535
548
} else {
536
549
_advertisementProgress.propertyStep = AdvertisementProgress::PropertyStep::PUB_DATATYPE;
@@ -541,7 +554,7 @@ void BootNormal::_advertise() {
541
554
strcpy_P (subtopic.get (), PSTR (" /" ));
542
555
strcat (subtopic.get (), node->getId ());
543
556
strcat_P (subtopic.get (), PSTR (" /" ));
544
- strcat (subtopic.get (), iProperty->getProperty ());
557
+ strcat (subtopic.get (), iProperty->getId ());
545
558
strcat_P (subtopic.get (), PSTR (" /$datatype" ));
546
559
packetId = Interface::get ().getMqttClient ().publish (_prefixMqttTopic (subtopic.get ()), 1 , true , iProperty->getDatatype ());
547
560
if (packetId != 0 ) _advertisementProgress.propertyStep = AdvertisementProgress::PropertyStep::PUB_UNIT;
@@ -554,7 +567,7 @@ void BootNormal::_advertise() {
554
567
strcpy_P (subtopic.get (), PSTR (" /" ));
555
568
strcat (subtopic.get (), node->getId ());
556
569
strcat_P (subtopic.get (), PSTR (" /" ));
557
- strcat (subtopic.get (), iProperty->getProperty ());
570
+ strcat (subtopic.get (), iProperty->getId ());
558
571
strcat_P (subtopic.get (), PSTR (" /$unit" ));
559
572
packetId = Interface::get ().getMqttClient ().publish (_prefixMqttTopic (subtopic.get ()), 1 , true , iProperty->getUnit ());
560
573
if (packetId != 0 ) _advertisementProgress.propertyStep = AdvertisementProgress::PropertyStep::PUB_FORMAT;
@@ -569,7 +582,7 @@ void BootNormal::_advertise() {
569
582
strcpy_P (subtopic.get (), PSTR (" /" ));
570
583
strcat (subtopic.get (), node->getId ());
571
584
strcat_P (subtopic.get (), PSTR (" /" ));
572
- strcat (subtopic.get (), iProperty->getProperty ());
585
+ strcat (subtopic.get (), iProperty->getId ());
573
586
strcat_P (subtopic.get (), PSTR (" /$format" ));
574
587
packetId = Interface::get ().getMqttClient ().publish (_prefixMqttTopic (subtopic.get ()), 1 , true , iProperty->getFormat ());
575
588
if (packetId != 0 ) sent = true ;
@@ -1053,7 +1066,7 @@ bool HomieInternals::BootNormal::__handleNodeProperty(char * topic, char * paylo
1053
1066
1054
1067
Property* propertyObject = nullptr ;
1055
1068
for (Property* iProperty : homieNode->getProperties ()) {
1056
- if (strcmp (property, iProperty->getProperty ()) == 0 ) {
1069
+ if (strcmp (property, iProperty->getId ()) == 0 ) {
1057
1070
propertyObject = iProperty;
1058
1071
break ;
1059
1072
}
0 commit comments