Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP8266 getIP() only returns station IP #722

Closed
nkolban opened this issue Nov 22, 2015 · 11 comments
Closed

ESP8266 getIP() only returns station IP #722

nkolban opened this issue Nov 22, 2015 · 11 comments
Assignees
Labels
enhancement ESP8266 This is only a problem on ESP8266 devices implemented

Comments

@nkolban
Copy link
Contributor

nkolban commented Nov 22, 2015

The function called getIP() only returns the station IP address. This is a problem because the ESP8266 can also be an access point. The suggestions here is to provide an optional argument to the function which can either be "station" or "accesspoint" to determine which IP address to return. The default if not specified should be "station".

@nkolban nkolban added the ESP8266 This is only a problem on ESP8266 devices label Nov 22, 2015
@martinayotte
Copy link

In ArduinoESP, to distinguish both IPs, the functions are named localIP() and softAPIP().

@gfwilliams
Copy link
Member

Odd - I thought there had been some discussion about this before, but I can't find it now - I think rakeshpai mentioned moving to a networkInterfaces object, but that does seem a bit overcomplicated.

I guess another option is to have one as the default, but to return both, so:

{ 
  ip : ...,
  mac : ...,
  ap : { ip : ... },
  station : { ip : ... }
}

But to be honest the other solutions are good as well. I guess there could be a getAPIP or something that only ESP8266 devices implemented.

PS. In the Wiki where we discussed getIP's implementation, it used a callback so that it could be compatible with other network interface types. For instance with AT commands (GSM, ESP8266 module) you don't want to block while waiting for serial data to be returned. Same would apply for CC3000 too, if TI's drivers weren't so bad! :)

@profra
Copy link

profra commented Nov 23, 2015

If station and AP are working both there are 2 IPs and 2 MACs... hence it would be more clear to ask them with two different functions... see reaction on AT command AT+CIFSR... picture...
https://espruino.microco.sm/api/v1/files/b4b12a58ea4823ec6fadd16911b7121fcf4770bf.png

@nkolban nkolban mentioned this issue Nov 24, 2015
@nkolban
Copy link
Contributor Author

nkolban commented Nov 24, 2015

Added a mac address to the returned data from getting the IP address. Added a second function called getAPIP() that gets the Access Point information.

@nkolban
Copy link
Contributor Author

nkolban commented Nov 24, 2015

The documentation update for the new getAPIP() function as well as the documentation that the mac address is now included in the results was omitted. This needs to be done before this issue should be closed.

@nkolban nkolban self-assigned this Nov 24, 2015
@nkolban
Copy link
Contributor Author

nkolban commented Nov 25, 2015

There appears to be a function called "networkPutAddressAsString" that formats a Mac address ... this looks like exactly what we need to reuse in this area ... see the following forum post for more details....

http://forum.espruino.com/conversations/278075/#comment12646517

This needs added.

@nkolban
Copy link
Contributor Author

nkolban commented Nov 26, 2015

The docs were updated to include getAPIP. In addition, the construction of the mac address string has now been changed to use the Espruino supplied string constructor.

gfwilliams added a commit that referenced this issue Nov 27, 2015
#722 Updated to used improved MAC address string construction.
tve pushed a commit to tve/Espruino that referenced this issue Nov 29, 2015
@tve tve closed this as completed Dec 5, 2015
@trusktr
Copy link

trusktr commented Jun 2, 2017

I think the Espruino WiFi docs are outdated? But getIP does give IP when not in AP mode.

@gfwilliams
Copy link
Member

I'm not sure I understand - but you're commenting on the wrong bug again. These bugs are for Espruino running on ESP8266 itself, and I think you're talking about Espruino WiFi?

Please could you ask on the Espruino forums? http://forum.espruino.com/microcosms/1083/

And maybe give a bit more information? Which docs? What does it return?

The Espruino WiFi docs say:

/* Get the Access point's IP and MAC address and call 
callback(err, { ip : ..., mac : ...}). If err isn't null,
it contains a string describing the error
*/
exports.getIP = function (callback) { ... }

@trusktr
Copy link

trusktr commented Jun 8, 2017

Hey, sorry for posting in the wrong place.

/* Get the Access point's IP and MAC address and call

Not only for access point mode (docs only mention getting the IP in access-point mode), but it seems to work also for when connecting to another WiFi access point (which doc doesn't mention).

@gfwilliams
Copy link
Member

Just fixed with espruino/EspruinoDocs@de48161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ESP8266 This is only a problem on ESP8266 devices implemented
Projects
None yet
Development

No branches or pull requests

6 participants