Hi forum,
I'm new to Arduino, and I'm using the IDE with the ESP8266.
I'm trying to let the ESP serve a PNG file for a browser. For this I have created the entire HTTP response including the binary data for the PNG in a char array. I quickly discovered that I cannot use client.print() since this will stop sending data when it encounters a null character (like a null terminated string) and the PNG data does contain nulls. I converted the char array to string when I used client.print().
Then I found client.write() which should take a buf and len: client.write(buf, len). But this won't compile.
What am I doing wrong?
Code example:
char testdata[] = {'T','e','s','t'};
client.write(testdata, 4)
Compiler error:
In file included from C:\Users\Martin\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\ESP8266WiFi\src/ESP8266WiFi.h:32:0,
from WiFi_print_http.ino:1:
C:\Users\Martin\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\ESP8266WiFi\src/WiFiClient.h: In instantiation of 'size_t WiFiClient::write(T&, size_t) [with T = char [4]; size_t = unsigned int]':
WiFi_print_http.ino:140:23: required from here
C:\Users\Martin\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\ESP8266WiFi\src/WiFiClient.h:113:36: error: request for member 'available' in 'source', which is of non-class type 'char [4]'
size_t left = source.available();
^
C:\Users\Martin\AppData\Roaming\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries\ESP8266WiFi\src/WiFiClient.h:117:5: error: request for member 'read' in 'source', which is of non-class type 'char [4]'
source.read(buffer.get(), will_send);
^
Error compiling.