Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork219
WiFi: Support for hidden networks and misc fixes.#874
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
sebromero left a comment
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.
Good stuff, thanks Ibrahim. I suggest for the sake of portability und user friendliness to not expose non-arduino types to the user. Can we define our own enum for the security type?
iabdalkader commentedApr 22, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
We seem to have our own enum |
sebromero commentedApr 22, 2024
Hmm, okay. The enum doesn't look very Arduino-ish, but then that's a different problem 😅 |
iabdalkader commentedApr 22, 2024
Yes I noticed. They seem to be documented/used here, see printEncryptionType https://www.arduino.cc/reference/en/libraries/wifinina/wifi.scannetworks/ |
JAndrassy commentedApr 23, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
For WEP different connect parameters are required and the API should be like thishttps://www.arduino.cc/reference/en/libraries/wifi/wifi.begin/ I did this a few weeks ago, but then I didn't do a PR because:
|
iabdalkader commentedApr 23, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I implemented the missing
There's no AUTO encryption type, it's just an enum we've added, maybe it maps to something valid for ESP but it does not map to anything valid for WHD. Those are the valid security types in mbedos:https://os.mbed.com/docs/mbed-os/v6.16/mbed-os-api-doxy/group__netsocket.html#ga0bfcdf6a9abae30715b5e7f43ae4a0c5 And those are the actual security types they map to in the WHD driver (use on the Giga, Nicla, Portenta):https://github.com/ARMmbed/mbed-os/blob/7ae592dabe59e9f26a4ce56190af61fb8b46d10d/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp#L141 I tried unknown, the comments say you shouldn't but I did anyway and it does not work. So the encryption type must be specified when connecting. By default WPA/WPA2 will be used, if the network was network was not found in a scan. This should work for most cases, but it still gives the user the option to override if it does not. |
JAndrassy commentedApr 23, 2024
sorry it was NSAPI_SECURITY_UNKNOWN not AUTO here is how WEP is handled in WHD:https://github.com/ARMmbed/mbed-os/blob/7ae592dabe59e9f26a4ce56190af61fb8b46d10d/connectivity/drivers/emac/COMPONENT_WHD/interface/WhdSTAInterface.cpp#L329 |
iabdalkader commentedApr 23, 2024
It seems to expect a very specific key format, I'll take a look later. Although I'm not sure if WEP is worth the trouble, it's as secure as having no security at all. |
iabdalkader commentedApr 24, 2024
@JAndrassy I've formatted the WEP key in the same way that the driver expects, see:https://github.com/ARMmbed/mbed-os/blob/7ae592dabe59e9f26a4ce56190af61fb8b46d10d/connectivity/drivers/wifi/COMPONENT_WHD/wifi-host-driver/src/whd_wifi_api.c#L1115 |
facchinm commentedApr 24, 2024
I'm all in for removing WEP, if someone is still using it thinking there's any security he'd better leave the network open. |
iabdalkader commentedApr 24, 2024
Okay I'll implement the OPEN |
- Add support for connecting to hidden networks (issuearduino#855).- Implement `begin()` for OPEN security.- Deprecate WEP security (issuearduino#819).- Add sanity checks to all functions accepting network index from the user.Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
iabdalkader commentedApr 25, 2024
Updated, For reference, this is the WEP key function. Since all 4 keys are required, the key is repeated. intarduino::WiFiClass::begin(constchar* ssid,uint8_t key_idx,constchar* key) {// The low-level driver expects all 4 keys to be passed in a buffer with the following format:// <idx> <len> <key>, <idx> <len> <key>, etc..uint8_t buf[(2 +32) *4] = {0 };size_t keylen =min(32,strlen(key));size_t buflen = (keylen +2) *4;// Repeat the key.for (int i=0; i<buflen; i += (keylen +2)) { buf[i+0] = i / (keylen +2); buf[i+1] = keylen;memcpy(&buf[i+2], key, keylen); }returnbegin(ssid, (constchar *) buf, ENC_TYPE_WEP);} |
Uh oh!
There was an error while loading.Please reload this page.
begin()for OPEN security.Note that for hidden networks, the BSSID is Not available, since it was not found in a scan. However, it can still be retrieved with:
I'm not sure why we're not using that, maybe for portability ?
Also not that
uint8_t* BSSID(uint8_t* bssid);returns a reversed MAC (due to a legacy bug in Nina) howeveruint8_t* BSSID(uint8_t networkItem, uint8_t* bssid);does Not return a reversed MAC. I didn't change that.