5 #include "IoTDeviceAddress.h"
9 // IoTUDP class for iotruntime
10 // Implemented based on IoTUDP.java that is used to wrap communication socket for UDP
12 // @author Rahmadi Trimananda <rahmadi.trimananda @ uci.edu>
18 // IoTUDP class properties
22 IPAddress strHostAddress;
31 IoTUDP(IoTDeviceAddress* iotDevAdd) {
33 strHostAddress = iotDevAdd->getAddress();
34 iSrcPort = iotDevAdd->getSourcePortNumber();
35 iDstPort = iotDevAdd->getDestinationPortNumber();
38 socket.begin(iSrcPort);
47 IPAddress getHostAddress() {
48 return strHostAddress;
57 int getDestinationPort() {
62 void setTimeOut(int interval) {
69 void sendData(const char* buffer, int bufferLen) {
71 unsigned short destinationPort = (unsigned short) iDstPort;
72 IPAddress ipFromBytes(strHostAddress);
73 socket.sendPacket(buffer, bufferLen, strHostAddress, destinationPort);
77 // Receive data packet
78 int receiveData(char* buffer, int iMaxDataLength) {
80 return socket.receivePacket(buffer, iMaxDataLength);