-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Update WiFiScan
example to show more useful data
#7378
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
@P-R-O-C-H-Y & @PilnyTomas Please help with the review. |
if (n == 0) { | ||
Serial.println("no networks found"); | ||
} else { | ||
Serial.print(n); | ||
Serial.println(" networks found"); | ||
Serial.println("Nr | SSID | RSSI | CH | Encryption"); |
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.
Suggest changing this to accommodate 32 character SSID maximum to:
Serial.println( " # | SSID | RSSI | CH | Encryption" );
Suggest adding the following after the above to "pretty up" the output table:
Serial.println( "---------------------------------------------------------------" );
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 will also suggest to add BSSID
column to differentiate between APs with the same SSID
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.
@me-no-dev Should I increase the column size? The limitation was on purpose because it is easier to read a table row without a huge space between the columns. Most SSIDs were shorter than 15 chars on my test setup.
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.
Since this is an example, I recommend printing the whole SSID. I agree a shorter SSID field looks better, but that can be customized for each application. This is the header I use for printing WiFi list (debug use only):
Serial.println(" # SSID BSSID RSSI Ch Authmode Rate" );
Serial.println("-----------------------------------------------------------------------------------" );
I print the full SSID with sprintf(ptr, "%32s ", AP->ssid[0] != 0 ? (const char *)AP->ssid : "<hidden>");
.
* Add channel to output. * Add type of encryption to output. * Format output as table. * Update outdated example description. * Add `scanDelete()` as hint to free memory.
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 vote for accommodating the longer RSSIs
This is what it looks like for 32-char RSSI
4 networks found
Nr | SSID | RSSI | CH | Encryption
1 | Foo | -34 | 4 | WPA2
2 | 0123456789abcdef0123456789abcdef | -34 | 11 | WPA2
3 | Bar | -76 | 4 | WPA2
4 | 42 | -87 | 4 | WPA2
Tip - use std::string (variable_white_space_length, ' ') to pad table dynamically - see it used here
That's interesting. IMHO the field width specifier in printf/sprintf is even easier to use. |
Description of Change
Update
WiFiScan
example to show more useful data.Since this example is part of the Arduino library I avoided to add IDF specific code.
Tests scenarios
Related links
Closes #7377