Example program that uses the mbed UbloxATCellularInterface or OnboardCellularInterface classes to perform simple sockets operations. This program can be used on the C027 and C030 boards, including the C030 N2xx version with a little editing.

Dependencies:   ublox-at-cellular-interface ublox-cellular-base ublox-cellular-base-n2xx ublox-at-cellular-interface-n2xx

Files at this revision

API Documentation at this revision

Comitter:
fahim.alavi@u-blox.com
Date:
Tue Feb 12 19:28:22 2019 +0500
Parent:
33:48101a4c3f14
Child:
36:f24c264ad2cd
Commit message:
R412M support added, library version updated, server link updated

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
ublox-at-cellular-interface.lib Show annotated file Show diff for this revision Revisions of this file
ublox-cellular-base.lib Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Feb 28 15:13:03 2018 +0000
+++ b/main.cpp	Tue Feb 12 19:28:22 2019 +0500
@@ -13,7 +13,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 #include "mbed.h"
 #include "UbloxATCellularInterface.h"
 #include "OnboardCellularInterface.h"
@@ -56,6 +55,7 @@
 #define APN         NULL
 #define USERNAME    NULL
 #define PASSWORD    NULL
+#define TCP_SERVER "os.mbed.com"
 
 // LEDs
 DigitalOut ledRed(LED1, 1);
@@ -177,13 +177,13 @@
     
     printf("Getting the IP address of \"developer.mbed.org\" and \"2.pool.ntp.org\"...\n");
     if ((interface->gethostbyname("2.pool.ntp.org", &udpServer) == 0) &&
-        (interface->gethostbyname("developer.mbed.org", &tcpServer) == 0)) {
+        (interface->gethostbyname(TCP_SERVER, &tcpServer) == 0)) {
         pulseEvent();
 
         udpServer.set_port(123);
+        tcpServer.set_port(80);
         printf("\"2.pool.ntp.org\" address: %s on port %d.\n", udpServer.get_ip_address(), udpServer.get_port());
-        printf("\"developer.mbed.org\" address: %s on port %d.\n", tcpServer.get_ip_address(), tcpServer.get_port());
-        tcpServer.set_port(80);
+        printf("\"os.mbed.com\" address: %s on port %d.\n", tcpServer.get_ip_address(), tcpServer.get_port());
 
         printf("Performing socket operations in a loop (until the user button is pressed on C030 or forever on C027)...\n");
         while (!buttonPressed) {
@@ -227,7 +227,7 @@
                 printf("Connecting socket to %s on port %d...\n", tcpServer.get_ip_address(), tcpServer.get_port());
                 if (sockTcp.connect(tcpServer) == 0) {
                     pulseEvent();
-                    printf("Connected, sending HTTP GET request to \"developer.mbed.org\" over socket...\n");
+                    printf("Connected, sending HTTP GET request to %s over socket...\n", TCP_SERVER);
                     strcpy (buf, "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\r\n\r\n");
                     // Note: since this is a short string we can send it in one go as it will
                     // fit within the default buffer sizes.  Normally you should call sock.send()
@@ -267,5 +267,4 @@
         printf("Unable to get IP address of \"developer.mbed.org\" or \"2.pool.ntp.org\".\n");
     }
 }
-
 // End Of File
--- a/mbed-os.lib	Wed Feb 28 15:13:03 2018 +0000
+++ b/mbed-os.lib	Tue Feb 12 19:28:22 2019 +0500
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#eaf6f8153d8b8c2d3136f288ca3c5d4fbc1ae18f
+https://github.com/ARMmbed/mbed-os/#57d8915a899a59999d7e2a9695e20a8a18cb54bd
\ No newline at end of file
--- a/ublox-at-cellular-interface.lib	Wed Feb 28 15:13:03 2018 +0000
+++ b/ublox-at-cellular-interface.lib	Tue Feb 12 19:28:22 2019 +0500
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/ublox/code/ublox-at-cellular-interface/#39264b492ce7
+https://developer.mbed.org/teams/ublox/code/ublox-at-cellular-interface/#2e8e1c573e18
--- a/ublox-cellular-base.lib	Wed Feb 28 15:13:03 2018 +0000
+++ b/ublox-cellular-base.lib	Tue Feb 12 19:28:22 2019 +0500
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/ublox/code/ublox-cellular-base/#e420232ee4e7
+https://developer.mbed.org/teams/ublox/code/ublox-cellular-base/#15f31e074d67