Skip to content

Commit 328a97b

Browse files
committed
Merge remote-tracking branch 'origin/wifi_leven_dev' into set_ip
Former-commit-id: 39cebba
2 parents e62288f + 3058cfb commit 328a97b

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
@@ -44,30 +44,43 @@ int CWifi::begin(const char* ssid, const char *passphrase) {
4444
/* passphrase is needed so a default one will be set */
4545
/* -------------------------------------------------------------------------- */
4646
uint8_t CWifi::beginAP(const char *ssid) {
47-
/* -------------------------------------------------------------------------- */
48-
return 0;
47+
/* -------------------------------------------------------------------------- */
48+
return beginAP(ssid,"",1);;
4949
}
5050

5151
/* -------------------------------------------------------------------------- */
5252
uint8_t CWifi::beginAP(const char *ssid, uint8_t channel) {
53-
/* -------------------------------------------------------------------------- */
54-
return 0;
53+
/* -------------------------------------------------------------------------- */
54+
return beginAP(ssid,"",channel);
5555
}
5656

5757
/* -------------------------------------------------------------------------- */
5858
uint8_t CWifi::beginAP(const char *ssid, const char* passphrase) {
59-
/* -------------------------------------------------------------------------- */
60-
return 0;
59+
/* -------------------------------------------------------------------------- */
60+
return beginAP(ssid, passphrase,1);
6161
}
6262

6363
/* -------------------------------------------------------------------------- */
6464
uint8_t CWifi::beginAP(const char *ssid, const char* passphrase, uint8_t channel) {
6565
/* -------------------------------------------------------------------------- */
66-
return 0;
66+
string res = "";
67+
modem.begin();
68+
modem.write(string(PROMPT(_MODE)),res, "%s%d\r\n" , CMD_WRITE(_MODE), 2);
69+
70+
if(!modem.write(string(PROMPT(_BEGINSOFTAP)),res, "%s%s,%s,%d\r\n" , CMD_WRITE(_BEGINSOFTAP), ssid, passphrase, channel)) {
71+
return WL_CONNECT_FAILED;
72+
}
73+
74+
if(atoi(res.c_str()) == 1) {
75+
return true;
76+
}
77+
78+
return false;
6779
}
6880

6981

7082

83+
7184
/* -------------------------------------------------------------------------- */
7285
void CWifi::config(IPAddress local_ip) {
7386
/* -------------------------------------------------------------------------- */
@@ -226,7 +239,19 @@ int8_t CWifi::scanNetworks() {
226239

227240
return (int8_t)access_points.size();
228241
}
229-
242+
243+
/* -------------------------------------------------------------------------- */
244+
IPAddress CWifi::softAPIP() {
245+
/* -------------------------------------------------------------------------- */
246+
string res = "";
247+
if(modem.write(string(PROMPT(_IPSOFTAP)),res, CMD(_IPSOFTAP))) {
248+
IPAddress local_IP;
249+
local_IP.fromString(res.c_str());
250+
return local_IP;
251+
}
252+
return IPAddress(0,0,0,0);
253+
}
254+
230255
/* -------------------------------------------------------------------------- */
231256
IPAddress CWifi::dnsIP(int n) {
232257
/* -------------------------------------------------------------------------- */

libraries/WiFiS3/src/WiFi.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ class CWifi {
161161

162162
IPAddress dnsIP(int n = 0);
163163

164+
/*
165+
* Get the interface the AP IP address.
166+
*
167+
* return: IP address value
168+
*/
169+
IPAddress softAPIP();
170+
164171
/*
165172
* Return the current SSID associated with the network
166173
*

0 commit comments

Comments
 (0)