Update, usingnow converting the solutiontype to char before calling the PrintXML function resolves my initial issue. If I use the code below, it seems to work forchew up a whilelot of memory, but after a few loops the program seems to stop responding. Ifis there anythingsomething obviously wrong with the code below? If I comment out this, As a workaround I'm just printing the rest ofXML tags using cl.print and the application runs fine, no hangupsmemory usage is stable.
void PrintXMLTag(EthernetClient cl, char* tag, char* val)
{
char tmp [100];
StrClear(tmp,100);
sprintf(tmp,"<%s>%s</%s>\n",tag,val,tag);
cl.print(tmp);
}
void XML_response(EthernetClient cl)
{
cl.println(F("<?xml version = \"1.0\" ?>"));
cl.println(F("<IO>"));
char z [2];
sprintf(z,"%d",digitalRead(FanSwitchPIN));
PrintXMLTag(cl,"fan",z);
PrintXMLTag(cl,"pingtime",PingTime);
PrintXMLTag(cl,"PingText",PingText);
char x [100];
dtostrf(humidity, 8, 1, x);
PrintXMLTag(cl,"humidity",x);
dtostrf(tempcelcius, 8, 1, x);
PrintXMLTag(cl,"tempcelcius",x);
cl.println(F("</IO>"));
}
// sets every element of str to 0 (clears array)
void StrClear(char *strtmp, char length)
{
for (int i = 0; i < length; i++100) {
str[i] = 0;
};
}