@@ -332,27 +332,18 @@ IPAddress CWifi::localIP() {
332332 int attempts = 0 ;
333333 IPAddress local_IP (0 ,0 ,0 ,0 );
334334
335- do {
336- delay (100 );
337- if (modem.write (string (PROMPT (_MODE)),res, " %s" , CMD_READ (_MODE))) {
338- if (atoi (res.c_str ()) == 1 ) {
339- if (modem.write (string (PROMPT (_IPSTA)),res, " %s%d\r\n " , CMD_WRITE (_IPSTA), IP_ADDR)) {
340-
341- local_IP.fromString (res.c_str ());
342-
343- }
335+ if (modem.write (string (PROMPT (_MODE)),res, " %s" , CMD_READ (_MODE))) {
336+ if (atoi (res.c_str ()) == 1 ) {
337+ if (modem.write (string (PROMPT (_IPSTA)),res, " %s%d\r\n " , CMD_WRITE (_IPSTA), IP_ADDR)) {
338+ local_IP.fromString (res.c_str ());
344339 }
345- else if (atoi (res.c_str ()) == 2 ) {
346- if (modem.write (string (PROMPT (_IPSOFTAP)),res, CMD (_IPSOFTAP))) {
347-
348- local_IP.fromString (res.c_str ());
349- }
340+ }
341+ else if (atoi (res.c_str ()) == 2 ) {
342+ if (modem.write (string (PROMPT (_IPSOFTAP)),res, CMD (_IPSOFTAP))) {
343+ local_IP.fromString (res.c_str ());
350344 }
351345 }
352- attempts++;
353346 }
354- while (local_IP == IPAddress (0 ,0 ,0 ,0 ) && attempts < 50 );
355-
356347 return local_IP;
357348}
358349
0 commit comments