These are chat archives for esp8266/Arduino

9th
May 2016
jasperachtbaan
@jasperachtbaan
May 09 2016 15:40
After installing the websocket_client, the websocket httpserver gives these errors when I try to compile
c:/tools/sming/Sming/SmingCore/Boards.h:17: undefined reference to `WebSocket::sendString(String const&)'
Anybody got any idea?
Martin Ayotte
@martinayotte
May 09 2016 15:58
@jasperachtbaan , unfortunately, this gitter chat is for Arduino ESP framework, not for Sming. There is another one called SmingHub/Sming for that.
gonsays
@gonsays
May 09 2016 18:10
hey guys, I want to do a LAN ip scanner with esp8266. The local ip can be aloccated as 192.168.1.1 to 192.168.1.255. Some routers start allocating from 192.168.1.1 and other routers start allocating from 192.168.1.100.
Can Arduino IDE read and write on .txt files?
FS function maybe
I'm a bit confused about the way to tell the ESP that the allocation interval is beginning in 1 or 100
being 255 ips I need to declare 255 ip strings
heavy
Martin Ayotte
@martinayotte
May 09 2016 18:16
Yes, you can read/write files using SPIFS functions.
gonsays
@gonsays
May 09 2016 18:28
I'll search it, thanks martin :)
martin, to declare the ip's to ping i'm using this: const char* ping_ip[] = {"192.168.1.1", "192.168.1.2", "192.168.1.3", "192.168.1.4", "192.168.1.5", "192.168.1.6", "192.168.1.7", "192.168.1.8", "192.168.1.9", "192.168.1.10"};
if I want to ping 255 ips, I have to declare the 255 values on a char array
can you recommend me another way to do it?
I think this way is too heavy
Michael Miller
@Makuna
May 09 2016 18:49
@gonsays You can store the strings in PROGMEM; but this is not how I would do it.
You should just have a constant for the prefix "192.168.1.", and then concatenate this with a itoa(octet); incrementing the last octet as a variable and passing it to itoa(). Further, you will find you made an assumption, as many routers use something other than 1 for the second to last octet so you will want to the same with it.
gonsays
@gonsays
May 09 2016 20:22
Thanks @Makuna !
gonsays
@gonsays
May 09 2016 20:39
what do you advise me to use instead of delay()? I've made some research and people tend NOT to use the delay function
instead of delay I would like to make the ESP sleep during 15 seconds, for example
gonsays
@gonsays
May 09 2016 21:01
@martinayotte I'm sorry to bother you again, but is it possible to DOWNLOAD a .txt from www.site.com/file.txt and then use SPIFFS function to read it? Or is it only to read/write locally?
Steve Nelson
@zenmanenergy
May 09 2016 21:44
I haven't worked on my esp code in a couple months. I just upgraded to the latest stable version and now I'm getting a lot of "exit status 1" compile errors. My .ino codebase has a bunch of tabs and that seems to be causing the errors. It's like the functions are out of order or something. any ideas?
it says:
exit status 1
'someFunctionInAnotherTab' was not declared in this scope
This error started when I upgraded to arduino 1.6.8 and v2.2.0 of the esp codebase.
Martin Ayotte
@martinayotte
May 09 2016 21:54
@gonsays , do you mean download a file from the internet and save it into SPIFFS and later read it locally ? Of course, it is doable.
@zenmanenergy , Yes, the IDE 1.6.8 has some problems with "forward declarations". Either you revert to 1.6.5, otherwise, you will have to place a copy of the function prototypes into a *.h and include it. (hoping this issue will be fixed in 1.6.9)
Steve Nelson
@zenmanenergy
May 09 2016 21:57
so I can just breakup my code using tabs anymore? *sigh
so I *can't rather
Martin Ayotte
@martinayotte
May 09 2016 21:58
I don't think it has any thing with tabs, simply that prototype need to be seen before calling the function.
Steve Nelson
@zenmanenergy
May 09 2016 22:00
as I understand the tabs in the ide, it copies the code onto the bottom of the file which is similar to putting functions declaration after the code that calls the function, so it's out of order. oh well, I'll just change things around.
Martin Ayotte
@martinayotte
May 09 2016 22:00
example, you have function void myfunc(int arg1) { Serial.println(arg1); }, then you need to add the prototype "void myfunc(int arg1);" at the top of the sketch
Steve Nelson
@zenmanenergy
May 09 2016 22:01
and you can't reorder the tabs afaik. I wonder if I put the setup() and loop() functions in a right most tab, if that would do it?
The tabs are a rather silly IDE interface, but they do allow for breaking up very long .ino files.
nope, that idea didn't work. the declarations are out of order like in your example.
thanks martin, i'll try the .h solution.
Michael Miller
@Makuna
May 09 2016 22:05
Yeah, I just use .h in the tabs, include them in them in the order you want in the INO. No problem ;-)
Martin Ayotte
@martinayotte
May 09 2016 22:06
As I said, it has nothing with tabs. It is the fact that pre-processor doesn't extract prototypes automagically like in 1.6.5. In plain C/C++, you always have to do that manually in a *.h.
Michael Miller
@Makuna
May 09 2016 22:07
@gonsays If you look at github/makuna/tasks you will see a library that helps you break up code and avoid using delays(); it includes sleep support abstracted from the details of the platform (well, almost, AVR and Esp8266 are so different here).
gonsays
@gonsays
May 09 2016 22:20
thanks for the info @Makuna :)
@martinayotte I'm using GET in order to obtain the page info, now I need to find some function to delimitate the string
I'm searching for it
client.readStringUntil('\r') reads me all the lines
Martin Ayotte
@martinayotte
May 09 2016 22:26
@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
May 09 2016 22:29
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
May 09 2016 22:31
As I said, try with '\n' ...
gonsays
@gonsays
May 09 2016 22:31
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
May 09 2016 22:40
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
May 09 2016 22:49
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
May 09 2016 23:07
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
May 09 2016 23:08
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
May 09 2016 23:09
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
May 09 2016 23:09
ohhh
yes
nice tip
Martin Ayotte
@martinayotte
May 09 2016 23:11
Good ! this will be even easier, simple need of a boolean "header_finished"
gonsays
@gonsays
May 09 2016 23:15
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