-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Esp32s2: Expose more network parameters #3484
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
Conversation
ap_rssi is a bound method, which I'm not keen on, but it works
still need to figure out the bound method business
… esp32s2-morenet
Forgot to make it a property!
… esp32s2-morenet
Forgot to add BSSID (and maybe regular SSID) so those are up next, and then this would be ready for review. |
This will be very useful! BSSID is super useful in networks with multiple APs with same SSID. Encryption type is another element commonly returned by Arduino and CircuitPython ESP32SPI, although if you are connected you already know it ;-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding these! Just a couple ideas/comments about the API. Code looks good, just want to make sure it's the API we want.
shared-bindings/wifi/Radio.c
Outdated
(mp_obj_t)&mp_const_none_obj }, | ||
}; | ||
|
||
//| ap_ssid: int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about re-using the Network object to represent the current network? I think it has all of the ap_
attributes you want here. Then you can just return None or a Network object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right, I'll try that. That'd avoid pulling out everything individually and would probably be nicer to interact with too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current network is usually represented as an ip_interface isn't it? See https://docs.python.org/3/library/ipaddress.html#ipaddress.ip_interface
The network object has the host bits and'ed away.
@astrobokonon Any update on this? |
@tannewt I haven't had a chance to circle back just yet, but I'm planning on carving out some time during the rest of this week/weekend! Still would like to get this done for sure. |
… esp32s2-morenet
Awesome! Thanks @astrobokonon |
still needs work and cleanup
@tannewt Ok, I think this is ready again. Just tested it and it worked as before, and it is indeed nicer and cleaner. I admit that makes me sorta want to do the same with all the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One bug I think. Good otherwise.
} | ||
|
||
// Make sure the interface is in STA mode | ||
if (self->sta_mode){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (self->sta_mode){ | |
if (!self->sta_mode){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! But this made me wonder why my tests worked at all. I don't see any reference to anything actually setting self->sta_mode
to True at any point...I'm just double checking to make sure I didn't goof up and remove that somewhere else or if it was just forgotten during start_station
.
@tannewt The bug you found did actually uncover another one ( Right now nothing will unset it, though. My guess is that won't really ever occur until an equivalent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, oops! Thanks for fixing it up.
When connected to an access point, this adds the following (super helpful, for me at least) information to
wifi.radio
:ap_rssi
: RSSIap_ssid
: SSIDap_bssid
: BSSID (usually it's MAC address)ipv4_gateway
: Gatewayipv4_subnet
: Subnetipv4_dns
: Primary DNSWhen not connected, these all just return
None
. I made sure RSSI is always the current one while walking around closer and farther from my AP in case someone wants to build a WiFi mapping toy robot, but I use it primarily for monitoring the current connection.