UDP Revisited —
Quoting : “Network Basics: TCP/UDP Socket and Port Overview”, By Edward Tetz from Cisco Networking All-in-One For Dummies (Ref: http://www.dummies.com/how-to/content/network-basics-tcpudp-socket-and-port-overview.html)To manage the connection between application layer network protocols, TCP and UDP use ports and sockets. TCP and UDP operate at the host-to-host layer in the IP communication model and provide host-to-host communication services for the application layer protocol. This means an application layer protocol is on one IP host connecting to an application layer protocol on another IP host.In most situations, these host-to-host connections have a server process running on one host and a client process running on the other host. Examples of this host-to-host connection include a web browser connecting to a web server; or a Secure Copy Protocol (SCP) client (such as WinSCP) connecting to an SCP server.A port is a TCP or UDP connection point. Think of them as receptacles on an old-fashioned telephone switchboard. There are 65,536 (or 2^16) ports available for a host to manage connections, numbered from 0 to 65,535 for each TCP and UDP. When you establish an application server running on an IP host, you configure that server to be used (or bound to) a specific TCP or UDP port.By associating the application layer server to use a specific port, you have created a destination that a remote IP host can connect to.When the remote IP host connects to an application layer server, the connection the host makes is to a port operating on a specific IP host (identified by an IP address). This pairing of an IP address and a port as a connection endpoint is a socket.In that old-fashioned switchboard analogy, the socket has two connectors connected to each client’s phone: one is a receptacle, and the other is a plug. Think of these connectors as the ports, but because the port is associated with a phone, together they make a socket, such as the TCP or UDP port, when paired with an IP address is a socket.To make a phone connection for a client, the “operator” takes the plug for one client and connects it to the socket for the other client. With IP, the client application has a port that it operates on, so on the client host, there is an IP address and port for the client side of the connection; this is a socket.On the server side of the connection is an IP address for the server and a port to make a socket on the server host. To establish a connection between the client application layer and the server application layer is a virtual connection between these two sockets.This example will walk you thru the process of connecting to a website, such as Wiley. You would open your web browser (like Mozilla Firefox) and type www.wiley.com into the address bar. Your web browser uses a Domain Name System (DNS) server to look up the name www.wiley.com to identify its IP address is. For this example, the address is 192.0.2.100.Firefox makes a connection to the 192.0.2.100 address and to the port where the application layer web server is operating. Firefox knows what port to expect because it is a well-known port . The well-known port for a web server is TCP port 80.The destination socket that Firefox attempts to connect is written as socket:port, or in this example, 192.0.2.100:80. This is the server side of the connect, but the server needs to know where to send the web page you want to view in Mozilla Firefox, so you have a socket for the client side of the connection also.The client side connection is made up of your IP address, such as 192.168.1.25, and a randomly chosen dynamic port number. The socket associated with Firefox looks like 192.168.1.25:49175. Because web servers operate on TCP port 80, both of these sockets are TCP sockets, whereas if you were connecting to a server operating on a UDP port, both the server and client sockets would be UDP sockets.
Create UDP Server on Arduino —
In the previous UDP examples in this series, the UDP server was either a Processing App or python app running an a Mac which broadcasted a “Hello” string on the server ip:port, 10.0.1.64:6000 or 10.0.1.64:3333, and the client YJ57 UDP ip:port was set to 10.0.1.57:1023.
The purpose of this example is to set up the UDP server on a YellowJacket Arduino and send the UDP packets over wifi to a YellowJacket Arduino client. In this “unicast” example, both the server and client ip:ports are known in advance and are coded into the sketch.
In this example, the server will operate on the YJ56 rather than using Processing or python on a Mac. The YJ56 uses the ip:port 10.0.1.56:3333 to send a packet over wifi to a UDP client listening on ip:port 10.0.1.57:3333.
/* * UDPAppWifiSendString_V14_01 * 2016-04-25 * 84Park * * This sketch sends a UDP Unicast packet on server_port using a YJ WiShield. * * Compiled with WiShield_V14 library (ref: github.com/hamityanik/WiShield_user_contrib) and Arduino 1.6.5 * This code works 2016-04-25 with YJ56 board * Pre-calculated security_data[] inits in 6 seconds * * Example Output to Serial Monitor * * === Initializing WiShield UDP Server over Wifi === * * Local server ip:10,0,1,56 * Local server port:3333 * Remote client ip:10,0,1,57 * Remote client port:3333 * === Serving Data over Wifi === * * UDP Send: Hello from UDP Server * * UDP Send: Hello from UDP Server * * // Requires APP_SOCKAPP and APP_UDPAPP to be defined in apps-conf.h // APP_SOCKAPP - for the TCP sockets components of the sketch // APP_UDPAPP - for the UDP/DNS components of the sketch * * Adapted from: * UDPApp * This sketch sends a UDP packet on server_port using a WiFi shield. * */ #include <WiShield.h> extern "C" { #include "uip.h" } // Wireless configuration parameters ---------------------------------------- unsigned char local_ip[] = {10, 0, 1, 56}; // IP address of WiShield unsigned char gateway_ip[] = {10, 0, 1, 1}; // router or gateway IP address unsigned char subnet_mask[] = {255, 255, 255, 0}; // subnet mask for the local network u16_t dns_ip[] = {10, 0, 1, 1}; // DNS server addr char ssid[] = {"Network"}; // max 32 bytes unsigned char security_type = 5; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2; 4 - WPA Precalc; 5 - WPA2 Precalc // Depending on your security_type, uncomment the appropriate type of security_data // 0 - None (open) // const char security_data[] PROGMEM = {}; // 1 - WEP // UIP_WEP_KEY_LEN. 5 bytes for 64-bit key, 13 bytes for 128-bit key // Only supply the appropriate key, do not specify 4 keys and then try to specify which to use //const char security_data[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, }; // 2, 3 - WPA/WPA2 Passphrase // 8 to 63 characters which will be used to generate the 32 byte calculated key // Expect the g2100 to take 30 seconds to calculate the key from a passphrase // const char security_data[] PROGMEM = {"Network_Passcode"}; // 4, 5 - WPA/WPA2 Precalc // The 32 byte precalculate WPA/WPA2 key. This can be calculated in advance to save boot time //const prog_char security_data[] PROGMEM = { // 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, // 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1f, 0x1f, //}; // Calc the Precalc: // http://jorisvr.nl/wpapsk.html // The derived key will appear in the form as a sequence of 64 hexadecimal digits. /*0599967ce21000026c2cf439ea561c3d37abbf48085738cbe9b9a9ca093a6adb*/ const char security_data[] PROGMEM = { 0x05, 0x99, 0x96, 0x7c, 0xe2, 0x10, 0x00, 0x02, 0x6c, 0x2c, 0xf4, 0x39, 0xea, 0x56, 0x1c, 0x3d, 0x37, 0xab, 0xbf, 0x48, 0x08, 0x57, 0x38, 0xcb, 0xe9, 0xb9, 0xa9, 0xca, 0x09, 0x3a, 0x6a, 0xdb, }; // setup the wireless mode; infrastructure - connect to AP; adhoc - connect to another WiFi device //#define WIRELESS_MODE_INFRA 1 //#define WIRELESS_MODE_ADHOC 2 unsigned char wireless_mode = WIRELESS_MODE_INFRA; // End of wireless configuration parameters ---------------------------------------- uint16_t server_ip[] = {10, 0, 1, 56}; // IP address of this server uint16_t server_port = 3333; // server port to send from uint16_t dest_ip[] = {10, 0, 1, 57}; // IP address of client uint16_t dest_port = 3333; // destination client port to send to //char packetBuffer[255]; //buffer to hold outgoing packet //char ReplyBuffer[] = "acknowledged"; // a string to send back boolean connectAndSendUDP = true; // false; uip_ipaddr_t srvaddr; //--------------------------------------------------------------------------- void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); Serial.println ("\n=== Initializing WiShield UDP Server over Wifi ==="); Serial.print("\nLocal server ip:"); Serial.print(server_ip[0]); Serial.print(","); Serial.print (server_ip[1]); Serial.print(","); Serial.print (server_ip[2]); Serial.print(","); Serial.println (server_ip[3]); Serial.print("Local server port:"); Serial.print(server_port); Serial.print("\nRemote client ip:"); Serial.print(dest_ip[0]); Serial.print(","); Serial.print (dest_ip[1]); Serial.print(","); Serial.print (dest_ip[2]); Serial.print(","); Serial.println (dest_ip[3]); Serial.print("Remote client port:"); Serial.print(dest_port); WiFi.init(); Serial.println ("\n=== Serving Data over Wifi ===\n"); } void loop() { WiFi.run(); } extern "C" { // These uIP callbacks are unused for the purposes of this simple DNS example // but they must exist. void socket_app_init(void) { } void socket_app_appcall(void) { } /* c code trace */ void printx(char* data) { Serial.print(data); } /* c code trace */ void printlnx(char* data) { Serial.println(data); } }
The code which sends the packet to the client is in the local version of udpapp.c. The function “static void send_response(void)” was modified to send the packet “Hello from UDP Server\n”, and the function “static PT_THREAD(handle_connection(void))” was modified to just send rather than listen, receive, and respond to client requests.
/****************************************************************************** Filename: udpapp.c server for UDPAppWifiSendString_V14_01.ino Description: UDP app for the WiShield 1.0 ****************************************************************************** TCP/IP stack and driver for the WiShield 1.0 wireless devices Copyright(c) 2009 Async Labs Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Contact Information: <asynclabs@asynclabs.com> Author Date Comment --------------------------------------------------------------- AsyncLabs 07/11/2009 Initial version *****************************************************************************/ #include "uip.h" #include <string.h> #include "udpapp.h" #include "config_udp.h" #define STATE_INIT 0 #define STATE_LISTENING 1 #define STATE_HELLO_RECEIVED 2 #define STATE_NAME_RECEIVED 3 static struct udpapp_state s; void dummy_app_appcall(void) { } void udpapp_init(void) { uip_ipaddr_t addr; struct uip_udp_conn *c; //uip_ipaddr(&addr, 10,0,1,57); uip_ipaddr(&addr, dest_ip[0], dest_ip[1], dest_ip[2], dest_ip[3]); c = uip_udp_new(&addr, HTONS(server_port)); //c = uip_udp_new(&addr, HTONS(3333)); if(c != NULL) { uip_udp_bind(c, HTONS(dest_port)); // or, bind to a specified port //uip_udp_bind(c, HTONS(3333)); // or, bind to a specified port } s.state = STATE_INIT; PT_INIT(&s.pt); } static unsigned char parse_msg(void) { if (memcmp(uip_appdata, "Hello", 5) == 0) { return 1; } return 0; } static void send_request(void) { char str[] = "Hello. What is your name?\n"; memcpy(uip_appdata, str, strlen(str)); uip_send(uip_appdata, strlen(str)); } static void send_response(void) { char i = 0; char str[] = "Hello from UDP Server\n"; // send the data "str[]" memcpy(uip_appdata, str, strlen(str)); uip_send(uip_appdata, strlen(str)); printx("UDP Send: "); printx(str); printlnx(); /* while ( ( ((char*)uip_appdata)[i] != '\n') && i < 9) { s.inputbuf[i] = ((char*)uip_appdata)[i]; i++; } s.inputbuf[i] = '\n'; memcpy(uip_appdata, str, 6); memcpy(uip_appdata+6, s.inputbuf, i+1); uip_send(uip_appdata, i+7); */ } static PT_THREAD(handle_connection(void)) { PT_BEGIN(&s.pt); //s.state = STATE_NAME_SEND; s.state = STATE_HELLO_RECEIVED; /* do { PT_WAIT_UNTIL(&s.pt, uip_newdata()); if(uip_newdata() && parse_msg()) { s.state = STATE_HELLO_RECEIVED; uip_flags &= (~UIP_NEWDATA); break; } } while(s.state != STATE_HELLO_RECEIVED); do { send_request(); PT_WAIT_UNTIL(&s.pt, uip_newdata()); if(uip_newdata()) { s.state = STATE_NAME_RECEIVED; uip_flags &= (~UIP_NEWDATA); break; } } while(s.state != STATE_NAME_RECEIVED); */ send_response(); s.state = STATE_INIT; PT_END(&s.pt); } void udpapp_appcall(void) { handle_connection(); }
And the YJ57 UDP client sketch which receives the packet from YJ56 is as follows:
/* * UDPAppWifiRcvString_V14_01 * 2016-04-25 * 84Park * * This sketch receives a UDP Unicast packet on client dest_port using a YJ WiShield. * * Compiled with WiShield_V14 library (ref: github.com/hamityanik/WiShield_user_contrib) and Arduino 1.6.5 * This code works 2016-04-25 with YJ57 board * Pre-calculated security_data[] inits in 6 seconds * * Example Output to Serial Monitor * * * * * === Initializing WiShield UDP Client over Wifi === * * Server ip:10,0,1,56 * Server port:3333 * Client ip:10,0,1,57 * Client port:3333 * === Receiving Data over Wifi === * * UDP Receive: Hello from UDP Server * UDP Receive v1 strlen: 21 * UDP Receive: Hello from UDP Server * UDP Receive v1 strlen: 21 * * * // Requires APP_SOCKAPP and APP_UDPAPP to be defined in apps-conf.h // APP_SOCKAPP - for the TCP sockets components of the sketch // APP_UDPAPP - for the UDP/DNS components of the sketch * * Adapted from: * UDPApp * This sketch receives a UDP packet on client dest_port using a WiFi shield. * */ #include <WiShield.h> extern "C" { #include "uip.h" } // Wireless configuration parameters ---------------------------------------- unsigned char local_ip[] = {10, 0, 1, 57}; // IP address of WiShield unsigned char gateway_ip[] = {10, 0, 1, 1}; // router or gateway IP address unsigned char subnet_mask[] = {255, 255, 255, 0}; // subnet mask for the local network u16_t dns_ip[] = {10, 0, 1, 1}; // DNS server addr char ssid[] = {"Network"}; // max 32 bytes unsigned char security_type = 5; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2; 4 - WPA Precalc; 5 - WPA2 Precalc // Depending on your security_type, uncomment the appropriate type of security_data // 0 - None (open) // const char security_data[] PROGMEM = {}; // 1 - WEP // UIP_WEP_KEY_LEN. 5 bytes for 64-bit key, 13 bytes for 128-bit key // Only supply the appropriate key, do not specify 4 keys and then try to specify which to use //const char security_data[] PROGMEM = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, }; // 2, 3 - WPA/WPA2 Passphrase // 8 to 63 characters which will be used to generate the 32 byte calculated key // Expect the g2100 to take 30 seconds to calculate the key from a passphrase // const char security_data[] PROGMEM = {"Network_Passcode"}; // 4, 5 - WPA/WPA2 Precalc // The 32 byte precalculate WPA/WPA2 key. This can be calculated in advance to save boot time //const prog_char security_data[] PROGMEM = { // 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, // 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1f, 0x1f, //}; // Calc the Precalc: // http://jorisvr.nl/wpapsk.html // The derived key will appear in the form as a sequence of 64 hexadecimal digits. /*0599967ce21000026c2cf439ea561c3d37abbf48085738cbe9b9a9ca093a6adb*/ const char security_data[] PROGMEM = { 0x05, 0x99, 0x96, 0x7c, 0xe2, 0x10, 0x00, 0x02, 0x6c, 0x2c, 0xf4, 0x39, 0xea, 0x56, 0x1c, 0x3d, 0x37, 0xab, 0xbf, 0x48, 0x08, 0x57, 0x38, 0xcb, 0xe9, 0xb9, 0xa9, 0xca, 0x09, 0x3a, 0x6a, 0xdb, }; // setup the wireless mode; infrastructure - connect to AP; adhoc - connect to another WiFi device //#define WIRELESS_MODE_INFRA 1 //#define WIRELESS_MODE_ADHOC 2 unsigned char wireless_mode = WIRELESS_MODE_INFRA; // End of wireless configuration parameters ---------------------------------------- uint16_t server_ip[] = {10, 0, 1, 56}; // IP address of UDP server uint16_t server_port = 3333; // server port to send from uint16_t dest_ip[] = {10, 0, 1, 57}; // IP address of client uint16_t dest_port = 3333; // destination client port to send to //char packetBuffer[255]; //buffer to hold outgoing packet //char ReplyBuffer[] = "acknowledged"; // a string to send back boolean connectAndSendUDP = false; uip_ipaddr_t srvaddr; //--------------------------------------------------------------------------- void setup() { //Initialize serial and wait for port to open: Serial.begin(115200); Serial.println ("\n=== Initializing WiShield UDP Client over Wifi ==="); Serial.print("\nServer ip:"); Serial.print(server_ip[0]); Serial.print(","); Serial.print (server_ip[1]); Serial.print(","); Serial.print (server_ip[2]); Serial.print(","); Serial.println (server_ip[3]); Serial.print("Server port:"); Serial.print(server_port); Serial.print("\nClient ip:"); Serial.print(dest_ip[0]); Serial.print(","); Serial.print (dest_ip[1]); Serial.print(","); Serial.print (dest_ip[2]); Serial.print(","); Serial.println (dest_ip[3]); Serial.print("Client port:"); Serial.print(dest_port); WiFi.init(); Serial.println ("\n=== Receiving Data over Wifi ===\n"); } void loop() { WiFi.run(); } extern "C" { // These uIP callbacks are unused for the purposes of this simple DNS example // but they must exist. void socket_app_init(void) { } void socket_app_appcall(void) { } // printx functions print char arrays returned from c code to Serial Monitor /* c code trace */ void printx(char* data) { Serial.print(data); } /* c code trace */ void printlnx(char* data) { Serial.println(data); } }
The code which receives the packet from the server is in the local version of udpapp.c. The function parsemsg(), “static unsigned char parse_msg(void)”, was modified to parse the “Hello” from the incoming packet “Hello from UDP Server\n”. If there was a match, the whole packet was copied into the char array str[50] and a “\0” was added after the packet to terminate str after the characters that were copied. The sprintf function was used to convert length “i” into a char array “v1[]” and \0 terminated. Both str[] and v1[] were printed using the printx function to Serial Monitor. The functions send_request and send_response were not used.
/****************************************************************************** Filename: udpapp.c client for UDPAppWifiRcvString_V14_01.ino Description: UDP app for the WiShield 1.0 ****************************************************************************** TCP/IP stack and driver for the WiShield 1.0 wireless devices Copyright(c) 2009 Async Labs Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Contact Information: <asynclabs@asynclabs.com> Author Date Comment --------------------------------------------------------------- AsyncLabs 07/11/2009 Initial version *****************************************************************************/ #include "uip.h" #include <string.h> #include "udpapp.h" #include "config_udp.h" #define STATE_INIT 0 #define STATE_LISTENING 1 #define STATE_HELLO_RECEIVED 2 #define STATE_NAME_RECEIVED 3 static struct udpapp_state s; void dummy_app_appcall(void) { } void udpapp_init(void) { uip_ipaddr_t addr; struct uip_udp_conn *c; //uip_ipaddr(&addr, 10,0,1,57); //uip_ipaddr(&addr, dest_ip[0], dest_ip[1], dest_ip[2], dest_ip[3]); // server sends to client ip uip_ipaddr(&addr, server_ip[0], server_ip[1], server_ip[2], server_ip[3]); // client receives from server ip c = uip_udp_new(&addr, HTONS(dest_port)); //c = uip_udp_new(&addr, HTONS(3333)); if (c != NULL) { uip_udp_bind(c, HTONS(server_port)); // or, bind to a specified port //uip_udp_bind(c, HTONS(3333)); // or, bind to a specified port } s.state = STATE_INIT; PT_INIT(&s.pt); } static unsigned char parse_msg(void) { if (memcmp(uip_appdata, "Hello", 5) == 0) { int i = 0; char str[50]; // char array to hold incoming data char v1[5]; // char array to hold length(str) //s.state = STATE_HELLO_RECEIVED; // read the data "str[]" while ( ( ((char*)uip_appdata)[i] != '\n')) { str[i] = ((char*)uip_appdata)[i]; i++; } str[i] = '\0'; // terminate char string printx("UDP Receive: "); printx(str); printlnx(); sprintf(v1, "%d\0", i); // converts int to char[] array (length(str)) printx("UDP Receive strlen: "); printx(v1); printlnx(); // or // sprintf(v1, "%d\0", strlen(str)); // converts int to char[] array (length(str)) // printx("UDP Receive strlen: "); printx(v1); printlnx(); } return 0; } static void send_request(void) { char str[] = "Hello. What is your name?\n"; memcpy(uip_appdata, str, strlen(str)); uip_send(uip_appdata, strlen(str)); } static void send_response(void) { char i = 0; //char str[] = "Hello from UDP Server\n"; char str[] = "Send Hello"; // send the data "str[]" memcpy(uip_appdata, str, strlen(str)); uip_send(uip_appdata, strlen(str)); printx("UDP Send: "); printx(str); printlnx(); /* while ( ( ((char*)uip_appdata)[i] != '\n') && i < 9) { s.inputbuf[i] = ((char*)uip_appdata)[i]; i++; } s.inputbuf[i] = '\n'; memcpy(uip_appdata, str, 6); memcpy(uip_appdata+6, s.inputbuf, i+1); uip_send(uip_appdata, i+7); */ } static PT_THREAD(handle_connection(void)) { PT_BEGIN(&s.pt); parse_msg(); /* if (parse_msg()) { char str[20]; // char array to hold incoming data //s.state = STATE_NAME_SEND; s.state = STATE_HELLO_RECEIVED; // read the data "str[]" memcpy(str, uip_appdata, strlen(uip_appdata)); printx("UDP Receive: "); printx(str); printlnx(); printx("UDP Receive strlen: "); printx(strlen(uip_appdata)); printlnx(); } */ /* do { PT_WAIT_UNTIL(&s.pt, uip_newdata()); if(uip_newdata() && parse_msg()) { s.state = STATE_HELLO_RECEIVED; uip_flags &= (~UIP_NEWDATA); break; } } while(s.state != STATE_HELLO_RECEIVED); do { send_request(); PT_WAIT_UNTIL(&s.pt, uip_newdata()); if(uip_newdata()) { s.state = STATE_NAME_RECEIVED; uip_flags &= (~UIP_NEWDATA); break; } } while(s.state != STATE_NAME_RECEIVED); */ //send_response(); s.state = STATE_INIT; PT_END(&s.pt); } void udpapp_appcall(void) { handle_connection(); }
And the Serial Monitor display:
=== Initializing WiShield UDP Client over Wifi === Server ip:10,0,1,56 Server port:3333 Client ip:10,0,1,57 Client port:3333 === Receiving Data over Wifi === UDP Receive: Hello from UDP Server UDP Receive v1 strlen: 21 UDP Receive: Hello from UDP Server UDP Receive v1 strlen: 21
Summary: In these examples, a UDP server was implemented on YJ56 to send out a character string to a UDP client on YJ57, both using port 3333. The same character string was transmitted without stop, with no feedback from YJ57 to YJ56. Any packets that were not received or were received with errors were not checked or corrected. An identification substring (Hello) was used to verify that a valid packet was received by the client from the server, then the client acted on the received packet by printing it to Serial Monitor.
(May 2, 2016)
No comments:
Post a Comment