@@ -55,10 +55,10 @@ void MsgBroker::top() {
5555 for (int i = 0 ; i < MF_MSGTOPIC_LIST_SIZE; i++) {
5656 MsgTopicBase *t = topic_list[i];
5757 if (t) {
58- Serial.printf (" topic:%-12s freq:%4.0fHz gen:%8d subscribers:%d\n " , t->name . c_str () , t->generation / dt, (int )t->generation , t->subscriber_count ());
58+ Serial.printf (" topic:%-12s freq:%4.0fHz gen:%8d subscribers:%d\n " , t->name , t->generation / dt, (int )t->generation , t->subscriber_count ());
5959 for (int j = 0 ; j < MF_MSGSUB_LIST_SIZE; j++) {
6060 MsgSubscriptionBase *s = t->sub_list [j];
61- if (s) Serial.printf (" sub:%-10s freq:%4.0fHz gen:%8d pulls:%8d missed:%8d\n " , s->name . c_str () , s->pull_cnt / dt, (int )s->generation , (int )s->pull_cnt , (int )(t->generation - s->pull_cnt ));
61+ if (s) Serial.printf (" sub:%-10s freq:%4.0fHz gen:%8d pulls:%8d missed:%8d\n " , s->name , s->pull_cnt / dt, (int )s->generation , (int )s->pull_cnt , (int )(t->generation - s->pull_cnt ));
6262 }
6363 }
6464 }
@@ -76,9 +76,9 @@ void MsgBroker::reset_stats() {
7676// =============================================================================
7777// MsgTopicBase
7878// =============================================================================
79- MsgTopicBase::MsgTopicBase (String name, int len) {
80- Serial. printf ( " cr topic %s %d \n " , name. c_str (),len);Serial. flush ( );
81- this ->name = name ;
79+ MsgTopicBase::MsgTopicBase (const char * name, int len) {
80+ strncpy ( this -> name , name, sizeof ( this -> name ) - 1 );
81+ this ->name [ sizeof ( this -> name ) - 1 ] = 0 ;
8282 queue = xQueueCreate (1 , len);
8383 MsgBroker::add_topic (this );
8484}
@@ -95,7 +95,6 @@ void MsgTopicBase::publishFromISR(void *msg) {
9595 generation++;
9696}
9797
98-
9998bool MsgTopicBase::pull (void *msg) {
10099 return (xQueuePeek (queue, msg, 0 ) == pdPASS);
101100}
@@ -135,8 +134,9 @@ bool MsgSubscriptionBase::updated() {
135134 return (generation != topic->generation );
136135}
137136
138- MsgSubscriptionBase::MsgSubscriptionBase (String name, MsgTopicBase *topic) : topic{topic} {
139- this ->name = name;
137+ MsgSubscriptionBase::MsgSubscriptionBase (const char *name, MsgTopicBase *topic) : topic{topic} {
138+ strncpy (this ->name , name, sizeof (this ->name ) - 1 );
139+ this ->name [sizeof (this ->name ) - 1 ] = 0 ;
140140 topic->add_subscription (this );
141141}
142142
0 commit comments