String to const char* payload in mqttClient.publish(
Posted: Sun Apr 30, 2017 2:53 am
I am using AsyncMqttClient and have a String payloadStr which ends up containing a two-word sentence e.g. "Open Open". I have spent several days trying to cast this into payload but have not asked the correct question of Google. I know
works and is processed by Node-Red correctly but
(plus many variations I have tried) returns an exit status
no matching function for call to 'AsyncMqttClient::publish(const char [19], int, bool, String&)
which I can't interpret. I understand payload.length computes itself when a string is passed so I have omitted this.
mqttClient.publish(MQTT_FEEDBACK_TOPIC, 0, true, "Open Open")
works and is processed by Node-Red correctly but
mqttClient.publish(MQTT_FEEDBACK_TOPIC, 0, true, payloadStr)
(plus many variations I have tried) returns an exit status
no matching function for call to 'AsyncMqttClient::publish(const char [19], int, bool, String&)
which I can't interpret. I understand payload.length computes itself when a string is passed so I have omitted this.