I've been out of the Arduino world for a while, but recently came back to update a program that has been running successfully on a couple of Arduinos over the last year. The program is, at it's core, a webserver that accepts specially formatted URL parameters to toggle outputs on an off.
When I was originally writing the sketch, I had issues with space so I fell back to using the F() function to store text strings in flash. The problem I had encountered was that when attempting to send these strings back as part of a response to the web client, each character in the string was begin sent in a new Ethernet packet. With the help of some people here, I found/modified a "printProgStr" function that would allow me to send the strigns stored in flash memory in one packet, and not byte by byte. Here is that function:
void printProgStr (EthernetClient client, __FlashStringHelper * str)
{
char * p = (char *) str;
if (!p) return;
char buf [strlen_P (p) + 1];
byte i = 0;
char c;
while ((c = pgm_read_byte(p++)))
buf [i++] = c;
buf [i] = 0;
client.write(buf);
}
Note, "client" is the currently connected Ethernet client, as this fucntion is only called inside a "while (client.connected())" loop.
To use the function, my program would call something like:
printProgStr(client, F("HTTP/1.1 200 OK\nContent-Type: text/html\n")); //Send back HTTP 200 code
This compiles find in Arduino 1.0 (the latest available at the time I wrote this sketch), and the code uploaded to the Arduino runs as expected. However, now that I've gotten back into the Arduino world I figured I would update to Arduino 1.0.4. When I attempt to compile the code in 1.0.2 or above, I get
error: invalid conversion from 'const __FlashStringHelper*' to '__FlashStringHelper*'
I'm not clear on what the difference between a "const __FlashStringHelper" and a "__FlashStringHelper" is, nor do I understand what changed between 1.0 and 1.0.2 to make this no longer valid. Guidance appreciated.