Ejemplo n.º 1
0
// Enable receiving of WONKA data
void FEHWONKA::Enable()
{
	_enabled = true;
	_irbeacon.DigitalOn();
    while( WaitForPacket() == 0x00);
	LCD.WriteLine("RPS Enabled Successfully");
    LCD.Clear();
}
Ejemplo n.º 2
0
unsigned int
    CHSNetwork::Connect(const char *pcAddress,
                        unsigned short usPort,
                        const char *pcPlayerName, const char *pcPassword)
{
    // The CHSNetwork cannot operate in both client and server mode.
    if (m_bServerMode)
    {
        return 0;
    }

    if (!InitNetwork())
    {
        return false;           // Unknown network problem.
    }

    // Allocate a CHSSocket.
    CHSSocket *pSocket = new CHSSocket;
    pSocket->SetCallbacks(NETRECEIVECALLBACK, NULL, NETCLOSECALLBACK);
    if (pSocket->Connect(pcAddress, usPort))
    {
        m_listSockets.push_back(pSocket);
        m_bClientMode = true;
        m_bInitialized = true;

        // Send a login packet.
        CHSPLogin cmdLogin;

        cmdLogin.m_pcPassword = (char *) pcPassword;
        cmdLogin.m_pcPlayerName = (char *) pcPlayerName;

        cmdLogin.SetPacketAddress((unsigned int) pSocket);

        SendPacket(cmdLogin);

        // Wait for the login response.
        if (WaitForPacket(PT_LOGIN_RESPONSE))
        {
            // The login response came back.  It should be the first on the list.
            CHSPacket *pPacket = GetPendingPacket();

            if (pPacket->GetPacketType() == PT_LOGIN_RESPONSE)
            {
                CHSPLoginResponse *cmdResponse =
                    static_cast < CHSPLoginResponse * >(pPacket);

                if (cmdResponse->m_bLoggedIn)
                {
                    return (unsigned int) pSocket;
                }
            }
        }
    }

    // Everything's in the toilet.
    return 0;
}