Skip to content

Commit 3058cfb

Browse files
committed
added beginAP and sofAPIP API
Former-commit-id: 07c5e12
1 parent ceb9585 commit 3058cfb

File tree

2 files changed

+40
-8
lines changed

2 files changed

+40
-8
lines changed

libraries/WiFiS3/src/WiFi.cpp

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,43 @@ int CWifi::begin(const char* ssid, const char *passphrase) {
4747
/* passphrase is needed so a default one will be set */
4848
/* -------------------------------------------------------------------------- */
4949
uint8_t CWifi::beginAP(const char *ssid) {
50-
/* -------------------------------------------------------------------------- */
51-
return 0;
50+
/* -------------------------------------------------------------------------- */
51+
return beginAP(ssid,"",1);;
5252
}
5353

5454
/* -------------------------------------------------------------------------- */
5555
uint8_t CWifi::beginAP(const char *ssid, uint8_t channel) {
56-
/* -------------------------------------------------------------------------- */
57-
return 0;
56+
/* -------------------------------------------------------------------------- */
57+
return beginAP(ssid,"",channel);
5858
}
5959

6060
/* -------------------------------------------------------------------------- */
6161
uint8_t CWifi::beginAP(const char *ssid, const char* passphrase) {
62-
/* -------------------------------------------------------------------------- */
63-
return 0;
62+
/* -------------------------------------------------------------------------- */
63+
return beginAP(ssid, passphrase,1);
6464
}
6565

6666
/* -------------------------------------------------------------------------- */
6767
uint8_t CWifi::beginAP(const char *ssid, const char* passphrase, uint8_t channel) {
6868
/* -------------------------------------------------------------------------- */
69-
return 0;
69+
string res = "";
70+
modem.begin();
71+
modem.write(string(PROMPT(_MODE)),res, "%s%d\r\n" , CMD_WRITE(_MODE), 2);
72+
73+
if(!modem.write(string(PROMPT(_BEGINSOFTAP)),res, "%s%s,%s,%d\r\n" , CMD_WRITE(_BEGINSOFTAP), ssid, passphrase, channel)) {
74+
return WL_CONNECT_FAILED;
75+
}
76+
77+
if(atoi(res.c_str()) == 1) {
78+
return true;
79+
}
80+
81+
return false;
7082
}
7183

7284

7385

86+
7487
/* -------------------------------------------------------------------------- */
7588
void CWifi::config(IPAddress local_ip) {
7689
/* -------------------------------------------------------------------------- */
@@ -175,7 +188,19 @@ int8_t CWifi::scanNetworks() {
175188

176189
return (int8_t)access_points.size();
177190
}
178-
191+
192+
/* -------------------------------------------------------------------------- */
193+
IPAddress CWifi::softAPIP() {
194+
/* -------------------------------------------------------------------------- */
195+
string res = "";
196+
if(modem.write(string(PROMPT(_IPSOFTAP)),res, CMD(_IPSOFTAP))) {
197+
IPAddress local_IP;
198+
local_IP.fromString(res.c_str());
199+
return local_IP;
200+
}
201+
return IPAddress(0,0,0,0);
202+
}
203+
179204
/* -------------------------------------------------------------------------- */
180205
IPAddress CWifi::localIP() {
181206
/* -------------------------------------------------------------------------- */

libraries/WiFiS3/src/WiFi.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,13 @@ class CWifi {
163163
*/
164164
IPAddress gatewayIP();
165165

166+
/*
167+
* Get the interface the AP IP address.
168+
*
169+
* return: IP address value
170+
*/
171+
IPAddress softAPIP();
172+
166173
/*
167174
* Return the current SSID associated with the network
168175
*

0 commit comments

Comments
 (0)