mirror of
https://github.com/workinghard/Cube4Fun.git
synced 2025-12-14 04:42:09 +00:00
Update CubeNetwork.cpp
Remove Poco
This commit is contained in:
@@ -27,16 +27,11 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif // win32
|
#endif // win32
|
||||||
|
|
||||||
//using Poco::Net::DialogSocket;
|
|
||||||
//using Poco::Net::SocketAddress;
|
|
||||||
//using Poco::Exception;
|
|
||||||
|
|
||||||
unsigned char buffer3D[64];
|
unsigned char buffer3D[64];
|
||||||
unsigned char receiveBuffer[32];
|
unsigned char receiveBuffer[32];
|
||||||
int bytesReceived;
|
int bytesReceived;
|
||||||
int i,x;
|
int i,x;
|
||||||
unsigned char color;
|
unsigned char color;
|
||||||
//DialogSocket ds;
|
|
||||||
int frameChange = 0;
|
int frameChange = 0;
|
||||||
int streamMode = 0; // 0 = off, 1 = frameStream, 2 = writeStream
|
int streamMode = 0; // 0 = off, 1 = frameStream, 2 = writeStream
|
||||||
TCPStream* stream;
|
TCPStream* stream;
|
||||||
@@ -100,8 +95,6 @@ bool frame1[3][64] = { {1,0,0,1,
|
|||||||
1,0,0,1,
|
1,0,0,1,
|
||||||
0,0,0,0}};
|
0,0,0,0}};
|
||||||
|
|
||||||
bool connectionEstablished = false;
|
|
||||||
|
|
||||||
void byte2uint32(unsigned char* bytes, u_int32_t msgLength) {
|
void byte2uint32(unsigned char* bytes, u_int32_t msgLength) {
|
||||||
unsigned char *vp = (unsigned char *)&msgLength;
|
unsigned char *vp = (unsigned char *)&msgLength;
|
||||||
bytes[0] = vp[0]; // int32 to byte array conversion
|
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
|
// let arduino knows what to expect
|
||||||
msgStartWrite(byteLength);
|
msgStartWrite(byteLength);
|
||||||
unsigned char myBuffer[4];
|
unsigned char myBuffer[4];
|
||||||
int ret = stream->receive(myBuffer,4);
|
long ret = stream->receive(myBuffer,4);
|
||||||
printf("received Length:\n");
|
printf("received Length:\n");
|
||||||
printf("0: %u\n", myBuffer[0]);
|
printf("0: %u\n", myBuffer[0]);
|
||||||
printf("1: %u\n", myBuffer[1]);
|
printf("1: %u\n", myBuffer[1]);
|
||||||
printf("2: %u\n", myBuffer[2]);
|
printf("2: %u\n", myBuffer[2]);
|
||||||
printf("3: %u\n", myBuffer[3]);
|
printf("3: %u\n", myBuffer[3]);
|
||||||
printf("ret: %u\n", ret);
|
printf("ret: %lu\n", ret);
|
||||||
|
|
||||||
// send bytes to write
|
// send bytes to write
|
||||||
stream->send(byteBuffer, byteLength);
|
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) {
|
bool CubeNetwork::openConnection(const char* ipAddr, unsigned int port) {
|
||||||
connectionEstablished = false;
|
bool connectionEstablished = false;
|
||||||
printf("Try to open the connection\n");
|
printf("Try to open the connection\n");
|
||||||
//std::string ipAddr_str(reinterpret_cast<const char*>(ipAddr));
|
//std::string ipAddr_str(reinterpret_cast<const char*>(ipAddr));
|
||||||
//Poco::UInt16 portNr = port;
|
//Poco::UInt16 portNr = port;
|
||||||
@@ -281,7 +274,6 @@ bool CubeNetwork::openConnection(const char* ipAddr, unsigned int port) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CubeNetwork::closeConnection() {
|
void CubeNetwork::closeConnection() {
|
||||||
connectionEstablished = false;
|
|
||||||
msgCloseFrameStream();
|
msgCloseFrameStream();
|
||||||
delete stream;
|
delete stream;
|
||||||
streamMode = 0;
|
streamMode = 0;
|
||||||
@@ -289,9 +281,8 @@ void CubeNetwork::closeConnection() {
|
|||||||
|
|
||||||
bool CubeNetwork::connected() {
|
bool CubeNetwork::connected() {
|
||||||
if (stream) {
|
if (stream) {
|
||||||
connectionEstablished = true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
connectionEstablished = false;
|
return false;
|
||||||
}
|
}
|
||||||
return connectionEstablished;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user