From f5454f346273015a10ff84661b2a3a21bb756363 Mon Sep 17 00:00:00 2001 From: workinghard Date: Tue, 30 Jun 2015 09:22:58 -0700 Subject: [PATCH] Update CubeNetwork.cpp Remove Poco --- Cube4Fun/src/CubeNetwork.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/Cube4Fun/src/CubeNetwork.cpp b/Cube4Fun/src/CubeNetwork.cpp index 5574175..8a91c68 100644 --- a/Cube4Fun/src/CubeNetwork.cpp +++ b/Cube4Fun/src/CubeNetwork.cpp @@ -27,16 +27,11 @@ #include #endif // win32 -//using Poco::Net::DialogSocket; -//using Poco::Net::SocketAddress; -//using Poco::Exception; - unsigned char buffer3D[64]; unsigned char receiveBuffer[32]; int bytesReceived; int i,x; unsigned char color; -//DialogSocket ds; int frameChange = 0; int streamMode = 0; // 0 = off, 1 = frameStream, 2 = writeStream TCPStream* stream; @@ -100,8 +95,6 @@ bool frame1[3][64] = { {1,0,0,1, 1,0,0,1, 0,0,0,0}}; -bool connectionEstablished = false; - void byte2uint32(unsigned char* bytes, u_int32_t msgLength) { unsigned char *vp = (unsigned char *)&msgLength; bytes[0] = vp[0]; // int32 to byte array conversion @@ -229,13 +222,13 @@ void CubeNetwork::sendBytes(const unsigned char* byteBuffer, unsigned int byteLe // let arduino knows what to expect msgStartWrite(byteLength); unsigned char myBuffer[4]; - int ret = stream->receive(myBuffer,4); + long ret = stream->receive(myBuffer,4); printf("received Length:\n"); printf("0: %u\n", myBuffer[0]); printf("1: %u\n", myBuffer[1]); printf("2: %u\n", myBuffer[2]); printf("3: %u\n", myBuffer[3]); - printf("ret: %u\n", ret); + printf("ret: %lu\n", ret); // send bytes to write stream->send(byteBuffer, byteLength); @@ -265,7 +258,7 @@ void CubeNetwork::updateFrame(const unsigned char * frameSequence, unsigned int } bool CubeNetwork::openConnection(const char* ipAddr, unsigned int port) { - connectionEstablished = false; + bool connectionEstablished = false; printf("Try to open the connection\n"); //std::string ipAddr_str(reinterpret_cast(ipAddr)); //Poco::UInt16 portNr = port; @@ -281,7 +274,6 @@ bool CubeNetwork::openConnection(const char* ipAddr, unsigned int port) { } void CubeNetwork::closeConnection() { - connectionEstablished = false; msgCloseFrameStream(); delete stream; streamMode = 0; @@ -289,9 +281,8 @@ void CubeNetwork::closeConnection() { bool CubeNetwork::connected() { if (stream) { - connectionEstablished = true; + return true; }else{ - connectionEstablished = false; + return false; } - return connectionEstablished; }