void testWifiReceiveStatus(const char* ipAddressLocal, const char* ipAddressRemote) { NetworkManager* ourNetworkManager = new NetworkManager; ourNetworkManager->initializeNewConnection("USBSocket", ipAddressLocal, ipAddressRemote, 1024, ConnectionInitType::CONNECT, ConnectionProtocol::TCP); NetworkChunk* chunk = new NetworkChunk; ourNetworkManager->getData("USBSocket", chunk); Status ourStatus(*chunk); }
void testWifiSendCommandNoMessage(const char* ipAddressLocal, const char* ipAddressRemote) { NetworkManager* ourNetworkManager = new NetworkManager; ourNetworkManager->initializeNewConnection("USBSocket", ipAddressLocal, ipAddressRemote, 1024, ConnectionInitType::CONNECT, ConnectionProtocol::TCP); //make and fill command with data Command *ourCommand = new Command; ourCommand->setCommandType(CommandType::DRIVE_BACKWARD); //turn command into NetworkChunk NetworkChunk* ourNetworkChunk = new NetworkChunk; *ourNetworkChunk = ourCommand->toNetworkChunk(); //send NetworkChunk ourNetworkManager->sendData("USBSocket", ourNetworkChunk); }
void testWifiSendText(const char* ipAddressLocal, const char* ipAddressRemote) { NetworkManager* ourNetworkManager = new NetworkManager; ourNetworkManager->initializeNewConnection("USBSocket", ipAddressLocal, ipAddressRemote, 1024, ConnectionInitType::CONNECT, ConnectionProtocol::TCP); //make and fill text with data Text *ourTextMessage = new Text; ourTextMessage->setLength(10); char message[100] = "YESSSSS!!!"; ourTextMessage->setTextMessage(message); //turn command into NetworkChunk NetworkChunk* ourNetworkChunk = new NetworkChunk; *ourNetworkChunk = ourTextMessage->toNetworkChunk(); //send NetworkChunk ourNetworkManager->sendData("USBSocket", ourNetworkChunk); }
void testWifiSendStatus(const char* ipAddressLocal, const char* ipAddressRemote) { NetworkManager* ourNetworkManager = new NetworkManager; ourNetworkManager->initializeNewConnection("USBSocket", ipAddressLocal, ipAddressRemote, 1024, ConnectionInitType::CONNECT, ConnectionProtocol::TCP); //make and fill status with data Status *ourStatus = new Status; ourStatus->setStatusType(StatusType::NOT_CHARGING); char message[100] = "YES!"; ourStatus->setStatusData(message); //turn status into NetworkChunk NetworkChunk* ourNetworkChunk = new NetworkChunk; *ourNetworkChunk = ourStatus->toNetworkChunk(); //send NetworkChunk ourNetworkManager->sendData("USBSocket", ourNetworkChunk); }
void testWifiReceiveText(const char* ipAddressLocal, const char* ipAddressRemote) { NetworkManager* ourNetworkManager = new NetworkManager; ourNetworkManager->initializeNewConnection("USBSocket", ipAddressLocal, ipAddressRemote, 1024, ConnectionInitType::CONNECT, ConnectionProtocol::TCP); NetworkChunk* chunk = new NetworkChunk; ourNetworkManager->getData("USBSocket", chunk); Text ourTextMessage(*chunk); //print out length/data of ourTextMessage int length = ourTextMessage.getLength(); VLOG(2) << "Length of our Message "<< length; for (int i=0; i < length; i++) { VLOG(2) << (ourTextMessage.getTextMessage())[i]; } }