示例#1
0
文件: tests.cpp 项目: PetRover/rTests
    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);
    }
示例#2
0
文件: tests.cpp 项目: PetRover/rTests
    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);
    }
示例#3
0
文件: tests.cpp 项目: PetRover/rTests
    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);
    }
示例#4
0
文件: tests.cpp 项目: PetRover/rTests
    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);
    }
示例#5
0
文件: tests.cpp 项目: PetRover/rTests
    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];
        }
    }