Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
gonsays
@gonsays
client.readStringUntil('\r') reads me all the lines
Martin Ayotte
@martinayotte
@gonsays , beware that some web sites could also send all lines with \n only without \r.
You could also read one character at a time, and parse it yourself.
gonsays
@gonsays
thnks for the tip @martinayotte
yup, I'm not very familiar with buffers and parsing
:S
I'm trying to learn it. Right now, it gives me all the lines of the GET Request: while(client.available()) => String line = client.readStringUntil('\r');
it prints me all the lines, but I just want to get the last 4 lines or so
Martin Ayotte
@martinayotte
As I said, try with '\n' ...
gonsays
@gonsays
I'll try it
I'm going to test it now
with '\n' it gives me the string in one line, with '\r' it gives me several lines
maybe, I'm going to use a "for" instead of the "while" to try to save each line
instead of String line = client.readStringUntil('\r') I may use something like line[i]=client.readStringUntil('\r')
Martin Ayotte
@martinayotte
if '\n' gave you one line, then it is working. don't change the while(client.available()), it will fail getting the whole page.
Or, simply parse the whole thing after you got all the lines.
gonsays
@gonsays
yes, but the lines are not displayed in any array
while(client.available()){ String line = client.readStringUntil('\n'); Serial.print(line);}
as I understood it will only save the last line
after the GET Request
if I try to Serial.println(line) it will give me the last line of the GET Request
I would like to save them
How could I parse it with the while?
I'm trying to code a for loop for it, but if you say that it will fail, maybe i'll test another option, but I'm without ideas (besides the for loop)
Martin Ayotte
@martinayotte
I don't have to be rude, but maybe you have some C/C++ learning to do. What I suggest is : declare String lines[10]; early (before starting the reads) as well as lineNo = 0; , then read one line at a time with lines[lineNo++], when the reads are finished, process lines using for(int l = lineNo - 4; l <= lineNo, l++)
gonsays
@gonsays
yup, I've just tested that solution (using a for loop), it saves me the first 10 results and than it crashes (maybe because the string is full already)
also I've changed the while loop for the for loop -> i think this is the problem
I'll work on it, thank you very much for your help @martinayotte !
Martin Ayotte
@martinayotte
BTW, where the choice a 4 lines comes from ? if it is the whole body, but you want to discard the header, simply throw away the lines until first empty line.
gonsays
@gonsays
ohhh
yes
nice tip
Martin Ayotte
@martinayotte
Good ! this will be even easier, simple need of a boolean "header_finished"
gonsays
@gonsays
thanks for the tips @martinayotte , it's an honour to have your help :) I recognize your nickname from my esp8266 google search
on some issues
Stavros Korokithakis
@skorokithakis
hey guys, does anyone have a multiwifi+mqtt example?
liangzelang
@liangzelang
hey guys, who can help me to find how the project generate the .pioenvs file , espcially , there is LWIP file .and I really wonder how doer it generate. Hope some kind guys tell me.thank u. the code is there : https://github.com/dogmaphobic/mavesp8266.git
Ivan Grokhotkov
@igrr
Downloading files over HTTP is most easily done with HTTPClient
It even presents itself as a Stream, which can be later written into a file.
Gus Grubba
@dogmaphobic
@liangzelang You posted this question here and as an issue into my repo. I trully do not understant the question. Could you please elaborate?
Tony Rieker
@Ibuprofen
Has anyone had issues using the TX1/GPIO2 to send serial? If I use the same code on a teensy 3.1 i can successfully control the serial device, when using the esp (nodemcu or wemods d1 mini) I cannot. Unfortunately I don't have an oscilloscope
I'm wondering if maybe there is a pinmode or some setting for the ESP that I don't know about?
Gus Grubba
@dogmaphobic
Has anyone had issues using the TX1/GPIO2 to send serial?
I use it all the time for debugging. Just use Serial1.
Tony Rieker
@Ibuprofen
Gus, thanks. I am definitely using Serial1
Gus Grubba
@dogmaphobic
I never did anything special. I just connect it to the RX pin of a (3.3V) FTDI adapter along with GND.
Tony Rieker
@Ibuprofen
Thanks
Maybe I can have the esp talk to the teensy until I get it figured out
liangzelang
@liangzelang
@dogmaphobic you look at .pioenvs/esp12e/ESP8266WiFi ,in this folder ,there will be three folder :include,arch ,and lwip 。and I don't know how does this file generate。
Gus Grubba
@dogmaphobic
It’s built by the SCons build process. I still don’t understand the question. Are you asking how the build process works?