Completing Lifx driver that uses Particle cloud; Particle phone app provides a nice...
[iotcloud.git] / version2 / src / RPi / IoTUDP.h
index e9f50ca44c4cd4698a54f82e77c773667333d958..f53855330eaf5a3f755689b71eea74f3ae1dfc55 100644 (file)
@@ -3,7 +3,6 @@
 #include <iostream>
 
 #include "IoTDeviceAddress.h"
-#include "application.h"
 
 using namespace std;
 
@@ -20,7 +19,7 @@ class IoTUDP final
        private:
                //UDPSocket *socket;
                UDP socket;
-               uint8_t* strHostAddress;
+               IPAddress strHostAddress;
                int iSrcPort;
                int iDstPort;
                bool didClose;
@@ -36,7 +35,6 @@ class IoTUDP final
                        iDstPort = iotDevAdd->getDestinationPortNumber();
                        timeOut = 0;
 
-                       //socket = new UDPSocket(iSrcPort);
                        socket.begin(iSrcPort);
                        didClose = false;
                }
@@ -46,7 +44,7 @@ class IoTUDP final
                }
 
 
-               uint8_t* getHostAddress() {
+               IPAddress getHostAddress() {
                        return strHostAddress;
                }
 
@@ -69,20 +67,17 @@ class IoTUDP final
 
                // Send data packet
                void sendData(const char* buffer, int bufferLen) {
-               //void sendData(const void* buffer, int bufferLen) {
+
                        unsigned short destinationPort = (unsigned short) iDstPort;
-                       IPAddress ipFromBytes = strHostAddress;
-                       socket.sendPacket(buffer, bufferLen, ipFromBytes, destinationPort);
-                       //socket->sendTo(buffer, bufferLen, strHostAddress, destinationPort);
+                       IPAddress ipFromBytes(strHostAddress);
+                       socket.sendPacket(buffer, bufferLen, strHostAddress, destinationPort);
                }
 
 
                // Receive data packet
                int receiveData(char* buffer, int iMaxDataLength) {
-               //int receiveData(void* buffer, int iMaxDataLength) {
-                       //unsigned short destinationPort = (unsigned short) iDstPort;
+
                        return socket.receivePacket(buffer, iMaxDataLength);                    
-                       //return socket->recvFrom(buffer, iMaxDataLength, strHostAddress, destinationPort);
                }
 };
 #endif