I have a method that looks as follows which is being run on an ATMEGA328P:
String Input::ReturnInputObjectFromValuesArray(const String& valuesArray, const String& miscDetailsToAppend) const
{
// start wrapper
String outputString = "{";
// print input number since these will be separated on send possibly
outputString += "\"" + String(INPUT_NUMBER_KEY) + "\":" + String(this->InputIndexInTotalInputs) + ",";
outputString += "\"" + String(INPUT_VALUES_KEY) + "\":" + valuesArray;
outputString += "}";
return outputString;
}
When this outputs, it seems to ignore that line right when I try to add any of the parameter values which are string constants by reference as shown. If I comment out/remove the + valuesArray it runs fine. The output just returns an empty string once the addition is attempted.
I should also note that if I add a Serial.println(valuesArray); anywhere, it'll print perfectly fine so the value is definitely there. I also tried outputString.concat(valuesArray) but that returns false meaning that it failed.
I've also tried separating out the additions rather than doing them all inline as I've read that adding different types in the same line can be risky.
Am I performing this addition incorrectly/is there a better way to do it? I'm open to any suggestions if there are better ways to attempt this. Thanks in advance.