-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Adding softAP SSID & PSK query API #4138
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
Changes from 14 commits
e5c6259
3b79cb4
04d96d9
6501ba4
9f3e1bd
1d74009
0f6979f
3ecd00f
bff42fd
0339f5e
dcf64e1
a62c5ab
60b4a1d
3a80358
641d6c5
a2fe942
0309ded
6ca28ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,3 +339,33 @@ String ESP8266WiFiAPClass::softAPmacAddress(void) { | |
sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); | ||
return String(macStr); | ||
} | ||
|
||
/** | ||
* Get the configured(Not-In-Flash) softAP SSID name. | ||
* @return String SSID. | ||
*/ | ||
String ESP8266WiFiAPClass::softAPSSID() const { | ||
struct softap_config config; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation in this function is different from nearby functions |
||
wifi_softap_get_config(&config); | ||
char* name = reinterpret_cast<char*>(config.ssid); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just
String(char*) will anyway search for the last \0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK sorry I did not see the hidden-outdated comment. |
||
char ssid[sizeof(config.ssid) + 1]; | ||
memcpy(ssid, name, sizeof(config.ssid)); | ||
ssid[sizeof(config.ssid)] = '\0'; | ||
|
||
return String(ssid); | ||
} | ||
|
||
/** | ||
* Get the configured(Not-In-Flash) softAP PSK or PASSWORD. | ||
* @return String psk. | ||
*/ | ||
String ESP8266WiFiAPClass::softAPPSK() const { | ||
struct softap_config config; | ||
wifi_softap_get_config(&config); | ||
char* pass = reinterpret_cast<char*>(config.password); | ||
char psk[sizeof(config.password) + 1]; | ||
memcpy(psk, pass, sizeof(config.password)); | ||
psk[sizeof(config.password)] = '\0'; | ||
|
||
return String(psk); | ||
} |
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.
How is this function different from IPAddress::fromString(), found here? If they serve equivalent purpose, I'd rather not duplicate.
Uh oh!
There was an error while loading. Please reload this page.
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.
@devyte
So sorry for late reply.
You say we should modify
bool IPAddress::fromString(const char *address)
function for adding validate support ? without duplicateBecause current IPAddress public API doesn't support validating IPV4 as string
Uh oh!
There was an error while loading. Please reload this page.
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.
@devyte
My suggestion:
1.Adding a private validating method:
static bool IPAddress::isValid(const char* arg, size_t len);
2.Adding correspond public method:
static bool IPAddress::isValid(const String& ip);
3.Reuse method of 1 inside 2 and
bool IPAddress::fromString(const char *address)
functionThere 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.
@IMAN4K said:
Are you saying that the following does not validate a string?
bool isvalid = IPAddress().fromString("17604123874106239");
Uh oh!
There was an error while loading. Please reload this page.
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.
@devyte
Yes that's correct, my mistake!
But we need to make an object for every validation.
It's better with a public static member(with good api name
isValid
rather thanfromString
), then every where in code:if (IPAddress::isValid(...)) ...
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 object constructed is 4 bytes in size, essentially one int, which is a temporary instantiated on the stack and immediately destroyed, so that's not a problem (btw, destruction is trivial).
What I suggest is a static convenience method like you propose, but something like this:
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.
Ok.
I'll make changes very soon.