Skip to content

WiFiS3 library: allow selection of WIFI_MODE_APSTA mode #459

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libraries/WiFiS3/src/WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ int CWifi::begin(const char* ssid) {
}

/* -------------------------------------------------------------------------- */
int CWifi::begin(const char* ssid, const char *passphrase) {
int CWifi::begin(const char* ssid, const char *passphrase, uint8_t mode) {
/* -------------------------------------------------------------------------- */
string res = "";
modem.begin();
modem.write(string(PROMPT(_MODE)),res, "%s%d\r\n" , CMD_WRITE(_MODE), 1);
modem.write(string(PROMPT(_MODE)),res, "%s%d\r\n" , CMD_WRITE(_MODE), mode);

if(passphrase == nullptr) {
if(!modem.write(string(PROMPT(_BEGINSTA)),res, "%s%s\r\n" , CMD_WRITE(_BEGINSTA), ssid)) {
Expand Down Expand Up @@ -400,7 +400,7 @@ IPAddress CWifi::localIP() {
IPAddress local_IP(0,0,0,0);

if(modem.write(string(PROMPT(_MODE)),res, "%s" , CMD_READ(_MODE))) {
if(atoi(res.c_str()) == 1) {
if(atoi(res.c_str()) == 1 || atoi(res.c_str()) == 3) {
if(modem.write(string(PROMPT(_IPSTA)),res, "%s%d\r\n" , CMD_WRITE(_IPSTA), IP_ADDR)) {
local_IP.fromString(res.c_str());
}
Expand Down
9 changes: 5 additions & 4 deletions libraries/WiFiS3/src/WiFi.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ class CWifi {
/* Start WiFi connection with passphrase
* the most secure supported mode will be automatically selected
*
* @param `ssid` Pointer to the SSID string.
* @param `passphrase` Passphrase. Valid characters in a passphrase
* must be between ASCII 32-126 (decimal).
* param ssid: Pointer to the SSID string.
* param passphrase: Passphrase. Valid characters in a passphrase
* must be between ASCII 32-126 (decimal).
* param mode: WiFi mode: STA, AP or AP_STA (mixed)
*/
int begin(const char* ssid, const char *passphrase);
int begin(const char* ssid, const char *passphrase, uint8_t mode = 1);

/**
* @brief Starts a Wi-Fi Access Point with the specified SSID.
Expand Down
Loading