Differences in getIP() syntax #5317
Replies: 1 comment
-
Posted at 2016-05-02 by @allObjects The way I understand this is: on ESP8266, Espruino has direct, synchronous and blocking access to the ip information, and therefore does not need to handle asynchronousity. An Espruino connecting to a ESP8266 has to go through the non-blocking, asynchronous serial send and receive interfaces and therefore has to use the callback to provide the information 'where to resume' with the response. I do not like to see different code for logically the same thing... unfortunately with MCs, hardware is so close to the application that differences in it must be (heart) felt... Just noticed that for Having to cater for two different interfaces for getIP() leads me again to use sort of a 'pico container'/sequence controller that manages serialization of asynchronous and regular calls. With such a construct, it is possible to have the very same application code after connecting. Without such a controller, the code could look like below where both wifi options share one and the same code for getting and printing the IP address (see lines 2..6 in third, shared code block): ESPRUINO on ESP8266:
ESPRUINO with ESP8266:
Shared application code that also handles getting the IP address:
Console output:
Notes:
Posted at 2016-05-02 by @gfwilliams Yes, @allObjects has it right. You can't have a sync getIP when running with a separate ESP8266. Collectively we spent days discussing Wifi for ESP8266, and made a huge wiki page where we agreed on an API that would work for both. Ultimately it got totally ignored when ESP8266 was implemented though, and sadly it's stuck since I have no time to fix it :) Posted at 2016-05-03 by @allObjects It was an interesting point @ClearMemory041063 brought up and a riddle to 'solve' with the least amount of different code... I enjoyed it. Posted at 2016-05-03 by ClearMemory041063 Thanks for all the discussion and tricks to make things work. Posted at 2016-05-05 by tve FYI, getIP on the esp8266 also accepts a callback function, so if you want to write portable code you can stick to the async callback:
I'm not sure why you feel this way. Some of the stuff specified on that page didn't work or didn't mesh with reality. I tried to stick to it, but some of it neither made sense nor was it consistent. Posted at 2016-05-05 by @allObjects Great to hear that Posted at 2016-05-05 by @gfwilliams @tve sorry - it wasn't aimed at you... you didn't start the wiki and do the initial implementation. That was the slightly frustrating part :) Since then you've sanitised it quite a lot. It's great that it takes an optional callback - that makes things a lot easier. It's a shame about the different argument types - but to be honest I should really update the other libraries to be more like the ESP8266 one in that respect. With the first |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-05-02 by ClearMemory041063
On an ESP8266 running v1.85
On an Espruino v1.85 board connected to an AT command ESP8266
Beta Was this translation helpful? Give feedback.
All reactions