Hi,
I receive via my etherent board data, I am trying to send that data back out to a local server.
But although I can print it out, I cannot send it, I think its because pointers are involved,
If it helps I am using Arduino MQTT, although I don't think it matters as to my problem.
Please see API info at the end of this.
I get an error in the Arduino complier window saying "expected primary-expression before ')' token"
Hopefully you can help as I have tried for hours and still have no clue what is wrong?
regards
Gary
void callback(char* topic, byte* payload, unsigned int length) // Data that has been received from server.
{
payload[length] = '\0'; // Add a 'null' to the payload.
strPayload = String((char*)payload); // strPayload now holds the contents of the memory pointed to by payload
)
void Send_data_back_to_MQTT(void)
{
client.publish("sensor/001/mqtt_server_in", strPayload); // Fail = "expected primary-expression before ')' token"
Serial.print(strPayload); // Prints OK
}
In the API of MQTT these are the options of how to return data:
boolean publish (topic, payload)
Publishes a string message to the specified topic.
The payload must be a null-terminated string. The message is published at QoS 0 with the retain flag set to false.
Parameters
topic – the topic to publish to (char*)
payload – the message to publish (char*)
Returns
false – publish failed.
true – publish succeeded.
boolean publish (topic, payload, length)
Publishes a message to the specified topic.
The message is published at QoS 0 with the retain flag set to false.
Parameters
topic – the topic to publish to (char*)
payload – the message to publish (byte array)
length – the length of the message (byte)
Returns
false – publish failed.
true – publish succeeded.