GNSS

Dependents:   ublox-at-cellular-interface-ext

Fork of ublox-at-cellular-interface by u-blox

Revision:
6:63dad754c267
Parent:
5:f6706249d076
Child:
7:3b2ca10cc23a
--- a/UbloxATCellularInterface.cpp	Tue Jun 13 10:09:57 2017 +0100
+++ b/UbloxATCellularInterface.cpp	Thu Jun 15 14:04:26 2017 +0100
@@ -986,18 +986,25 @@
     set_pin(pin);
 }
 
+static int count = 0;
+
 // Get the IP address of a host.
 nsapi_error_t UbloxATCellularInterface::gethostbyname(const char *host,
                                                       SocketAddress *address,
                                                       nsapi_version_t version)
 {
     nsapi_error_t nsapi_error = NSAPI_ERROR_DEVICE_ERROR;
+    int at_timeout;
     char ipAddress[NSAPI_IP_SIZE];
 
+    count++;
     if (address->set_ip_address(host)) {
         nsapi_error = NSAPI_ERROR_OK;
     } else {
         LOCK();
+        // This interrogation can sometimes take longer than the usual 8 seconds
+        at_timeout = _at_timeout;
+        at_set_timeout(60000);
         memset (ipAddress, 0, sizeof (ipAddress)); // Ensure terminator
         if (_at->send("AT+UDNSRN=0,\"%s\"", host) &&
             _at->recv("+UDNSRN: \"%" u_stringify(NSAPI_IP_SIZE) "[^\"]\"", ipAddress) &&
@@ -1006,6 +1013,7 @@
                 nsapi_error = NSAPI_ERROR_OK;
             }
         }
+        at_set_timeout(at_timeout);
         UNLOCK();
     }