pimoroni / phew

MIT License
199 stars 42 forks source link

Update __init__.py #15

Closed Strikelab closed 1 year ago

Strikelab commented 1 year ago

show ip server address in REPL

Signed-off-by: Strikelab 97408664+Strikelab@users.noreply.github.com

Gadgetoid commented 1 year ago

Thank you, but this feels like something that should be consigned to user code. A library should (almost?) never use print directly (users who want clean REPL/serial output for some kind of serial API, for example, would see this as a problem).

Since I think network.WLAN(network.AP_INET) is singleton it's totally okay just to do:

import network
print(network.WLAN(network.STA_IF).ifconfig()[0])

In your code.

This shouldn't interfere with an established connection, and should get the IP address if a connection has been established.

I suppose a case could be made for a get_ip_address() function to hide this.

lowfatcode commented 1 year ago

@Gadgetoid I like your idea here to add a get_ip_address() method - this will be available shortly!