Skip to content

Commit 559bdba

Browse files
committed
Merge remote-tracking branch 'origin/wifi_leven_dev' into set_ip
Former-commit-id: 64731b6
2 parents 416b625 + ceb9585 commit 559bdba

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

libraries/WiFiS3/src/WiFi.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,21 +203,39 @@ int8_t CWifi::scanNetworks() {
203203
return (int8_t)access_points.size();
204204
}
205205

206-
/* -------------------------------------------------------------------------- */
206+
/* -------------------------------------------------------------------------- */
207207
IPAddress CWifi::localIP() {
208-
/* -------------------------------------------------------------------------- */
209-
return IPAddress(0,0,0,0);
208+
/* -------------------------------------------------------------------------- */
209+
string res = "";
210+
if(modem.write(string(PROMPT(_IPSTA)),res, "%s%d\r\n" , CMD_WRITE(_IPSTA), IP_ADDR)) {
211+
IPAddress local_IP;
212+
local_IP.fromString(res.c_str());
213+
return local_IP;
214+
}
215+
return IPAddress(0,0,0,0);
210216
}
211217

212218
/* -------------------------------------------------------------------------- */
213219
IPAddress CWifi::subnetMask() {
214-
/* -------------------------------------------------------------------------- */
215-
return IPAddress(0,0,0,0);
220+
/* -------------------------------------------------------------------------- */
221+
string res = "";
222+
if(modem.write(string(PROMPT(_IPSTA)),res, "%s%d\r\n" , CMD_WRITE(_IPSTA), NETMASK_ADDR)) {
223+
IPAddress subnetMask;
224+
subnetMask.fromString(res.c_str());
225+
return subnetMask;
226+
}
227+
return IPAddress(0,0,0,0);
216228
}
217229

218230
/* -------------------------------------------------------------------------- */
219231
IPAddress CWifi::gatewayIP() {
220-
/* -------------------------------------------------------------------------- */
232+
/* -------------------------------------------------------------------------- */
233+
string res = "";
234+
if(modem.write(string(PROMPT(_IPSTA)),res, "%s%d\r\n" , CMD_WRITE(_IPSTA), GATEWAY_ADDR)) {
235+
IPAddress gateway_IP;
236+
gateway_IP.fromString(res.c_str());
237+
return gateway_IP;
238+
}
221239
return IPAddress(0,0,0,0);
222240
}
223241

libraries/WiFiS3/src/WiFi.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ class CAccessPoint {
2323
string encryption_mode;
2424
};
2525

26-
26+
enum{
27+
IP_ADDR = 0,
28+
GATEWAY_ADDR,
29+
NETMASK_ADDR
30+
} ip_type;
2731

2832

2933
class CWifi {

0 commit comments

Comments
 (0)