@@ -176,21 +176,39 @@ int8_t CWifi::scanNetworks() {
176
176
return (int8_t )access_points.size ();
177
177
}
178
178
179
- /* -------------------------------------------------------------------------- */
179
+ /* -------------------------------------------------------------------------- */
180
180
IPAddress CWifi::localIP () {
181
- /* -------------------------------------------------------------------------- */
182
- return IPAddress (0 ,0 ,0 ,0 );
181
+ /* -------------------------------------------------------------------------- */
182
+ string res = " " ;
183
+ if (modem.write (string (PROMPT (_IPSTA)),res, " %s%d\r\n " , CMD_WRITE (_IPSTA), IP_ADDR)) {
184
+ IPAddress local_IP;
185
+ local_IP.fromString (res.c_str ());
186
+ return local_IP;
187
+ }
188
+ return IPAddress (0 ,0 ,0 ,0 );
183
189
}
184
190
185
191
/* -------------------------------------------------------------------------- */
186
192
IPAddress CWifi::subnetMask () {
187
- /* -------------------------------------------------------------------------- */
188
- return IPAddress (0 ,0 ,0 ,0 );
193
+ /* -------------------------------------------------------------------------- */
194
+ string res = " " ;
195
+ if (modem.write (string (PROMPT (_IPSTA)),res, " %s%d\r\n " , CMD_WRITE (_IPSTA), NETMASK_ADDR)) {
196
+ IPAddress subnetMask;
197
+ subnetMask.fromString (res.c_str ());
198
+ return subnetMask;
199
+ }
200
+ return IPAddress (0 ,0 ,0 ,0 );
189
201
}
190
202
191
203
/* -------------------------------------------------------------------------- */
192
204
IPAddress CWifi::gatewayIP () {
193
- /* -------------------------------------------------------------------------- */
205
+ /* -------------------------------------------------------------------------- */
206
+ string res = " " ;
207
+ if (modem.write (string (PROMPT (_IPSTA)),res, " %s%d\r\n " , CMD_WRITE (_IPSTA), GATEWAY_ADDR)) {
208
+ IPAddress gateway_IP;
209
+ gateway_IP.fromString (res.c_str ());
210
+ return gateway_IP;
211
+ }
194
212
return IPAddress (0 ,0 ,0 ,0 );
195
213
}
196
214
0 commit comments