SENA HD132x Series User Manual
Page 50

HD132x Series User Manual
50
The sample program for this function has been implemented in UDP (User Datagram Protocol).
When the HelloDevice sends its MAC address, local port and IP address to the IP address of the data
server through UDP 514 port, the sample program receives and displays the information. For setup of
data server parameters, refer to Section 4.4.2.
The HelloDevice transmits data that consist of a total of 14 bytes, and the form is as follows:
“OK” (2 Byte)+ MAC address(6 Byte) + Local port(2 Byte) + IP address(4 Byte)
Below is a source sample of the data server.
/**************************************************************************
UDP-based data server sample program
HelloDevice notifying message format
: total 14 bytes data
: The number in the parenthesis means the byte size...
'O'(1)+'K'(1)+ MAC address(6) + local port number(2) + IP address(4)
e.g.
4f-4b-00-01-95-04-04-01-17-71-c0-a1-a8-0f
**************************************************************************/
#include
#include
#include
// Global Variable definition
WSADATA lpWSAData;
// Socket data structure
SOCKADDR_IN
addrFrom;
int
sock ;
// Socket
int byte_received ;
// byte received
struct sockaddr_in addr ;
// My IP address