-->
Page 1 of 1

Where is the readString function defined ?

PostPosted: Wed Mar 23, 2016 8:28 am
by Henning
Hello dear ESP8266 friends,

this week I made my first tries with an ESP12e Module and the Arduino IDE. I believe it`s a great thing.

I provided my Arduino IDE with "http://arduino.esp8266.com/stable/package_esp8266com_index.json" and started with this example:
http://www.instructables.com/id/Programming-a-HTTP-Server-on-ESP-8266-12E/step7/Listen-to-What-the-Browser-is-Sending-to-the-HTTP-/

It`s working fine ... but I have questions. The author is using functions like "client.readString()" . Therefore he only includes a header file named ESP8266WiFi.h. I can`t find this file on my computer. So I googled for it and found this collection:
https://github.com/sandeepmistry/esp8266-Arduino/tree/master/esp8266com/esp8266/libraries/ESP8266WiFi/src

But there is no readString() defined in any file ? From where does the author knows about the existence of the readString function ?

It seems, that only the readString function works properly. Trying the defined functions "int read()" or "read(uint8_t *buf, size_t size)" failed.

Can somebody point me to the valid header file(s) which I can use with my Arduino IDE, please ?

Friendly regards
Henning

Re: Where is the readString function defined ?

PostPosted: Thu Mar 24, 2016 4:04 am
by bbx10node
Assuming Windows, open a command line window and try

Code: Select allcd %userprofile%
dir/s ESP8266WiFi.h


This should show the directory with this file assuming it esists.

Re: Where is the readString function defined ?

PostPosted: Thu Mar 24, 2016 8:27 am
by martinayotte
WiFiClient is derived from Client, which is derived from Stream, which has the readString() method.
.arduino15/packages/esp8266/hardware/esp8266/2.1.0/cores/esp8266/Stream.h

Re: Where is the readString function defined ?

PostPosted: Sat Mar 26, 2016 4:54 am
by Henning
Thank you very much. I was wondering why the readString works and the read does not but I realized that the read function is none-blocking and that I have to wait for data using the available method.

(and I supressed c++ inheritance while exploring the new hardware, sorry)