-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
WiFi: Support for hidden networks and misc fixes. #874
Conversation
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?
We seem to have our own enum |
Hmm, okay. The enum doesn't look very Arduino-ish, but then that's a different problem 😅 |
Yes I noticed. They seem to be documented/used here, see printEncryptionType https://www.arduino.cc/reference/en/libraries/wifinina/wifi.scannetworks/ |
For WEP different connect parameters are required and the API should be like this https://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:
|
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. |
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 |
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. |
1277a11
to
e6c1d47
Compare
@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 |
e6c1d47
to
cfa61bc
Compare
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. |
Okay I'll implement the OPEN |
- Add support for connecting to hidden networks (issue arduino#855). - Implement `begin()` for OPEN security. - Deprecate WEP security (issue arduino#819). - Add sanity checks to all functions accepting network index from the user. Signed-off-by: iabdalkader <[email protected]>
cfa61bc
to
79d35ef
Compare
Updated, For reference, this is the WEP key function. Since all 4 keys are required, the key is repeated. int arduino::WiFiClass::begin(const char* ssid, uint8_t key_idx, const char* 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);
}
return begin(ssid, (const char *) buf, ENC_TYPE_WEP);
} |
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.