Arduino - Concatanate Two String in MQTT

Hello
i am trying to combine two strings in two varibles (string class) and publish using client.publish. any tutorial or any example any one can give??? searched google for ages

Combining C strings - Sök (bing.com)

First try. The first find looks promising.

      String sTopic = "";
      sTopic.reserve( 35 );
      sTopic.concat( String(px_eData.SunRiseHr) + "," );
      sTopic.concat( String(px_eData.SunRiseMin) + "," );
      sTopic.concat( String(px_eData.SunSetHr) + "," );
      sTopic.concat( String(px_eData.SunSetMin) + "," );
      sTopic.concat( String(px_eData.DawnHr) + "," );
      sTopic.concat( String(px_eData.DawnMin) + "," );
      sTopic.concat( String(px_eData.TransitHr) + "," );
      sTopic.concat( String(px_eData.TransitMin) );
      xSemaphoreTake( sema_MQTT_KeepAlive, portMAX_DELAY );
      MQTTclient.publish( topicSRSSDDT, sTopic.c_str() );
      xSemaphoreGive( sema_MQTT_KeepAlive );

is there a much easier way???

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.