Simple UDP Client using the UIPEthernet library for ENC28J60 Ethernet boards.

Dependencies:   UIPEthernet

Revision:
3:6a6fe4ef95b9
Parent:
2:c69ad6e71f97
diff -r c69ad6e71f97 -r 6a6fe4ef95b9 main.cpp
--- a/main.cpp	Tue Sep 03 09:19:55 2019 +0000
+++ b/main.cpp	Sat Sep 07 18:12:05 2019 +0000
@@ -15,7 +15,7 @@
  */
 #include "mbed.h"
 #include "UipEthernet.h"
-
+ 
 // MAC address must be unique within the connected network. Modify as appropriate.
 const uint8_t   MAC[6] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 };
 UipEthernet     net(MAC, D11, D12, D13, D10);   // mosi, miso, sck, cs
@@ -23,7 +23,7 @@
 {
     uint32_t    secs;                           // Transmit Time-stamp seconds.
 } ntp_packet;
-
+ 
 /**
  * @brief
  * @note
@@ -38,25 +38,25 @@
         printf("Error connecting\n");
         return -1;
     }
-
+ 
     // Show the network address
     const char*     ip = net.get_ip_address();
     const char*     netmask = net.get_netmask();
     const char*     gateway = net.get_gateway();
-
+ 
     printf("IP address: %s\r\n", ip ? ip : "None");
     printf("Netmask: %s\r\n", netmask ? netmask : "None");
     printf("Gateway: %s\r\n\r\n", gateway ? gateway : "None");
-
+ 
     UdpSocket       socket(&net);
     SocketAddress   sockAddr;
     char            out_buffer[] = "time";
-
+ 
     if (socket.sendto("time.nist.gov", 37, out_buffer, sizeof(out_buffer)) < 0) {
         printf("Error sending data\n");
         return -1;
     }
-
+ 
     ntp_packet  in_data;
     socket.recvfrom(&sockAddr, &in_data, sizeof(ntp_packet));
     in_data.secs = ntohl(in_data.secs) - 2208988800;    // 1900-1970
@@ -64,9 +64,9 @@
     printf("Time = %s", ctime((const time_t*) &in_data.secs));
     printf("Time Server Address: %s\r\n", sockAddr.get_ip_address());
     printf("Time Server Port: %d\n\r", sockAddr.get_port());
-
+ 
     // Close the socket and bring down the network interface
     socket.close();
     net.disconnect();
     return 0;
-}
+}
\ No newline at end of file