These are chat archives for esp8266/Arduino

7th
Mar 2016
Michael Miller
@Makuna
Mar 07 2016 02:49
char blah[50]; takes no init hit at all?
Michael Miller
@Makuna
Mar 07 2016 02:57

@porkyneal Well, yes. When you think dynamic change, think of using pointers to objects instead of objects. So you can just destroy the old one and create a new one. Make sure to stop the old one first. This is the preferred method follows (pseudo code)

MyTask* pMyTask = NULL;

// at some point
taskManager.StopTask( pMyTask );
delete pMyTask;
pMyTask = new MyTask(newTimeValue);
taskManager.StartTask(pMyTask);

But if you look, the member variable _timeInterval is protected so in the task it can change this. Make sure you still call taskManager.StopTask() first before changing it, and then call taskManager.StartTask() to get it going again. I may in the future lock those down.

Rohit Yermalkar
@romuye123
Mar 07 2016 03:29
for home automation projects, which is best mode to communicate the commands from android app to ESP ? TCP or UDP or anything else ? and why ?
Victor Tseng
@Palatis
Mar 07 2016 04:23
well, char blah[50] just modifies the stack pointer, no other overhead.
and this is often combined with all variables in the function, like you have char blah1[50], blah2[25]; int a, b, c; etc in your code, the compiler is smart enough to just sp+=83;.
as long as you don't specifie a default value...
c compilers just don't clear out variable contents by default.
Victor Tseng
@Palatis
Mar 07 2016 04:28
so you get whatever trash it was in the stack as the initial value.
i dunno, udp is unreliable, so you tell the switch to turn off a light with udp, it might just stay on because the packet is lost due to some mysterious reason.
althought this should be a really rare case.
Rohit Yermalkar
@romuye123
Mar 07 2016 04:31
but i believe UDP is faster over TCP ? correct ?
Victor Tseng
@Palatis
Mar 07 2016 04:32
it depends on how you define faster.
UDP is more like fire and forget
Rohit Yermalkar
@romuye123
Mar 07 2016 04:33
hmm you need to query again to get the status
Victor Tseng
@Palatis
Mar 07 2016 04:33
TCP confirms that you hit.
Rohit Yermalkar
@romuye123
Mar 07 2016 04:33

correct, was just going through a detailed blog

http://electronicdesign.com/iot/mqtt-and-coap-underlying-protocols-iot

Victor Tseng
@Palatis
Mar 07 2016 04:34
so if you have to query again, why not just go tcp?
imho for data that dont rely on integrity, use udp, otherwise tcp.
for example, you are streaming a video, one or two packet got problem wont ruin the entire video.
but if you are transfering some command to a switch, a packet loss probablly means the switch gonna malfunction.
Rohit Yermalkar
@romuye123
Mar 07 2016 04:40
hmmm understood
Michael Miller
@Makuna
Mar 07 2016 04:42
Tcp is a heavy load on a network if you have a ton of units on it, but your unlikely to have that in a house.
Rohit Yermalkar
@romuye123
Mar 07 2016 05:32
i am confused which protocol to use
d-anders
@d-anders
Mar 07 2016 06:06
If you don't know then go with TCP or even use http on top of it
d-anders
@d-anders
Mar 07 2016 06:12
Maybe look into websockets
Victor Tseng
@Palatis
Mar 07 2016 07:56
like each switch, light, vacuum, aircon is a single IoT unit?
dunno whats the purpose for a IoT vacuum tho
Aditya Tannu
@AdySan
Mar 07 2016 08:44
It would suck, pun intended. 😜
Harrison Mclean
@h4rm0n1c
Mar 07 2016 09:08
Maybe it notifies you when the bag is full?
Sends message back to home controller, home controller gives you geofenced notification when you're at the shops to buy more bags?
No, that's too much techno-wankery for a vacuum...
Michael Miller
@Makuna
Mar 07 2016 09:21
Master, I have collected a sock. Master the sock is big and makes sucking hard. Master, the sock is mewing.
Harrison Mclean
@h4rm0n1c
Mar 07 2016 10:34
Damned house elves...
Victor Tseng
@Palatis
Mar 07 2016 12:19
hmm what's a InstructionRetchErrorCause?
Fatal exception 2(InstructionRetchErrorCause):
I'm trying to update wifi credentials received from the WebServer
like, esp8266 on AP mode with a web server, and sta ssid and passphrase are pushed through that
the problem is ap and sta are using same phy, so connecting to other ap would change softap channel, too...
that's insane...
Harrison Mclean
@h4rm0n1c
Mar 07 2016 12:28
I'd say that's "Fetch", might be a spelling error since "R" is above the "F" key on QWERTY at least...
Victor Tseng
@Palatis
Mar 07 2016 12:42
hmm.......... anyway the stack dump ends up inside libpp.a
Fatal exception 9(LoadStoreAlignmentCause):
ohh changed.
feels like if there is an ongoing tcp then wifi.begin() would crash.
weird, i called server.close() before i actually do wifi.begin()
Harrison Mclean
@h4rm0n1c
Mar 07 2016 12:52
I think the networking stuff doesn't like running before wifi is up, at least, it makes sense to me that it would throw an exception at that, since you can't actually serve anything if you're not either running as an AP or as a STA.
Also, the esp8266 is pretty touchy, I guess that's what we get for a $2 mass produced SoC from China...
Victor Tseng
@Palatis
Mar 07 2016 12:54
dunno, I just store the pushed ssid & pass by myself and call ESP.reset()...
and do the stuff in setup().
i got my NodeMCU for $7!!!
Harrison Mclean
@h4rm0n1c
Mar 07 2016 12:55
Ah, I think there's also some issues with soft reset, I remember reading something about that.
Victor Tseng
@Palatis
Mar 07 2016 12:55
need another reseller maybe.
Harrison Mclean
@h4rm0n1c
Mar 07 2016 12:55
Nah, I get ESP-12E modules and make my own boards...
Victor Tseng
@Palatis
Mar 07 2016 12:55
dunno, maybe just do a while(true); and let wdt reset...
Harrison Mclean
@h4rm0n1c
Mar 07 2016 12:56
I think it was a matter of doing some housekeeping that allows it to work, but I can't remember where I read that...
Ivan himself has given a workaround.
Victor Tseng
@Palatis
Mar 07 2016 12:59
dunno, reading through what's the difference between ESP.reset() vs ESP.restart()

extern "C" void real_system_restart_local();
void EspClass::reset(void)
{
real_system_restart_local();
}

void EspClass::restart(void)
{
system_restart();
esp_yield();
}

can't really tell...
Lars Englund
@larsenglund
Mar 07 2016 13:33
I've implemented sending queries and receiving answers for those queries with ESP8266mDNS now but I'm not sure what the best way is to give the user acccess to the answers.. Right now the queryService method takes a callback function and will call that once for each parsed answer as it is parsed (so from _parsePacket()). An alternative is to build a list of answers and just set a flag and let the user poll for answers, but that has the drawback of eating up RAM to store all answers (even ones the user might not care about).
Should I just go with the callback route? Or will there be problems if the callback from _parsePacket() takes to long?
Also, note that the goal here is not to give the user access to all details of a packet but to give a simple way to ask for a service and just get back zero, one or more {hostname, ip and port} for that service
Me No Dev
@me-no-dev
Mar 07 2016 13:46
you can implement it blocking like the DNS or AP search methods
that is probably what the users will expect
and return linked objects containing each response
Lars Englund
@larsenglund
Mar 07 2016 14:32
With a default timeout of say 500ms? Still has the drawback of allocating a bunch of ram and leaving responsability to the user to free it..
Lars Englund
@larsenglund
Mar 07 2016 16:44
But as you say It's good to keep it similar to DNS and AP so thats what i'll do
Victor Tseng
@Palatis
Mar 07 2016 17:07
dunno, working with esp826y these days, I felt I just went into a synchronized world...
like almost every network calls are blocking...
Me No Dev
@me-no-dev
Mar 07 2016 17:10
there is an asyncronous way to do it all but it's danegrous to be used by many users
Victor Tseng
@Palatis
Mar 07 2016 17:13
like, i have a webserver, which does WiFi.startScan() and return the result to the client, I can't just say "okay, you're scanning, we'll come back latet after the scan results available! next!"
omg did i just use s/foo/bar/g to modify the message?
didnt expect that to happen...
really geeky
Me No Dev
@me-no-dev
Mar 07 2016 17:14
you can. just not using the regular API. As a matter of fact I have done some simple implementation in a sketch of exactly what you are saying
dig into the library source to see how it's done
Victor Tseng
@Palatis
Mar 07 2016 17:15
i dunno, looks like the webserver can only handle one client at a time
Me No Dev
@me-no-dev
Mar 07 2016 17:16
that is the included web server which is synchronous
but there is another one
Victor Tseng
@Palatis
Mar 07 2016 17:16
pfod something?
Victor Tseng
@Palatis
Mar 07 2016 17:16
gj
thx, will look into that.
Victor Tseng
@Palatis
Mar 07 2016 17:27
do i just call server.begin() and forget? no more server.handleClients()?
Me No Dev
@me-no-dev
Mar 07 2016 17:29
yes
it's asynchronous so no need to call anything in the loop
it will call you when a request is parsed
but beware :)
no yield or delay in the callbacks
also no calls to functions that use them
do your thing quickly and let the response go
Lars Englund
@larsenglund
Mar 07 2016 17:36
@Palatis I've been developing some backends with node.js lately and in that sphere synchronous is a curse word :)
So my instinct is to develop asynchronous..
RrodriguezM
@RrodriguezM
Mar 07 2016 19:15
i'm using Esp8266 with arduino and i want to sleep the ESP with the CH_PD pin directly with the arduino anyone know how to do it ?
Victor Tseng
@Palatis
Mar 07 2016 22:23
is there some sort of a library that works similar to Android Looper?
like a main looper with a message queue, you push stuff to be processed into it, and the looper loops through them?