I did search but I cant see what Im doing wrong. I barely understand pointers and even less making use of them. In this case the use of mqtt libraries require it I believe.
Ive stripped down my code to the parts I cant get my head around and causing errors.
As far as I understand whats happening (although probably wrong)
-create a pointer (points to a memory address, not the value itself) and assign a value
Im not sure if the const means the memory address is constant or the content at that address is constant?
-pass the pointer into the function (deferencing? not sure what or why but this is what looking around for help tells me)
-in the function use the & symbol (I think this is how you use the value of the pointer, not the address?)
const char* iotpulsemeter_publish_topic1m = "home/iotpulsemeter/readings/1minute";
const char* iotpulsemeter_publish_topic15m = "home/iotpulsemeter/readings/15minute";
const char* iotpulsemeter_publish_topic1h = "home/iotpulsemeter/readings/1hour";
sendData(*iotpulsemeter_publish_topic1m, meterReading1m, "1m reading = ");
sendData(*iotpulsemeter_publish_topic15m, meterReading15m, "15m reading = ");
sendData(*iotpulsemeter_publish_topic1h, meterReading1h, "1h reading = ");
void sendData(char &publishDestination, double value, String serialData) {
Serial.print(serialData);
Serial.println(value);
client.publish(publishDestination, String(value).c_str());
pixelSet();
}
the result is
error: binding reference of type 'char&' to 'const char' discards qualifiers
But I dont know why.
Thanks
