Esempio n. 1
0
void espMultipleProcess(short numTimes)
{
    for(short processCount = 0; processCount<numTimes; ++processCount)
    {
        esp.process();
        delay(20);
    }
}
Esempio n. 2
0
HRESULT APIENTRY hkIDirect3DDevice9::EndScene()
{
	//Move our menu through keyboard import
	hacks.KeyboardInput();
	//Draws our menu with a ton of different colours
	hacks.DrawMenu(m_pD3Ddev);
	//Sending in what we want ON and OFF
	EspHack.Esp_Aimbot
	(
		hacks.hack[ESP_BOX_NAME].on, 
		hacks.hack[ESP_HEALTH].on,
		hacks.hack[ESP_DISTANCE].on,
		hacks.hack[SNAP_LINE].on,
		hacks.hack[AIMBOT_HK].on
	);

	EspHack.DrawMyHealth();
	return m_pD3Ddev->EndScene();
}
void WifiBegin(short isCiao) {
	espSerial.begin(9600);
	if(espSerial.ping()!=1) {
		espSerial.println("DBG: esp not found");
		while(1);
	}
	else {
		//espSerial.println("device found");
	}
	//put GPIO control here !!!
	esp.enable();
	delay(1000);
	esp.reset();
	delay(1000);
	while(!esp.ready());
	if (isCiao == 0)
		esp.wifiCb.attach(&wifiCb);

	espSerial.println("\nDBG: UnoWiFi Start");
}
CiaoData PassThroughRead(const char* connector, const char* hostname, String data, const char* method){


	//short mode = 0;

	if (!strcmp(connector, "rest")){
		//mode = 0;
		if (!strcmp(method, "GET")){
			return requestGET(hostname, data);
		}
		else if (!strcmp(method, "POST")){
			return requestPOST(hostname, data);
		}
		else{
			CiaoData ciao_data;
			ciao_data.msg_split[0]="";
			ciao_data.msg_split[1]="";
			ciao_data.msg_split[2]="Method Error";
			return ciao_data;
		}
	}
	else if (!strcmp(connector, "mqtt")){
		//mode = 1;
		CiaoData ciao_data;
		esp.process();
		check_topic(hostname);
		char topic[mqtt_topic.length()+1];
		mqtt_topic.toCharArray(topic,mqtt_topic.length()+1);
		if(mqtt_data_tmp != "" && !strcmp(hostname,topic)){
				mqtt_data = mqtt_data_tmp;
				ciao_data.msg_split[0]="mqtt";
				ciao_data.msg_split[1]= hostname;
				ciao_data.msg_split[2]= mqtt_data.c_str();
				mqtt_topic="";
				mqtt_data_tmp="";
		 }
		else{
				ciao_data.msg_split[0]="mqtt";
				ciao_data.msg_split[1]=hostname;
				ciao_data.msg_split[2]="";
		}
		return ciao_data;
	}
	else {
		CiaoData ciao_data;
		ciao_data.msg_split[0]="";
		ciao_data.msg_split[1]="";
		ciao_data.msg_split[2]="Protocol Error";
		return ciao_data;
	}
}
Esempio n. 5
0
HRESULT CD3DManager::Initialize()
{
	/*
	initialize Resources such as textures 
	(managed and unmanaged [D3DPOOL]), 
	vertex buffers, and other D3D rendering resources
	...
	m_pD3Ddev->CreateTexture(..., ..., &m_pD3Dtexture);
	*/
	
	//create our font, if you don't have this one choose another
	hacks.CreateFont(m_pD3Ddev, "Arial");
	//Send over our D3D device pointer
	EspHack.SetupDirect3D(m_pD3Ddev, &hacks.m_font);
	return S_OK;
}
Esempio n. 6
0
void bringUpWifi()
{
    unsigned triesBeforeChipReset = 2000;
    unsigned count = 0;
    while(!wifiConnected)
    {
        // Start by putting chip in known state
        esp.enable();
        delay(500);
        hardResetEspChip();
        delay(1000);
        esp.reset();
        delay(500);
        while(!esp.ready())
        {
            digitalWrite(HEART_BEAT_LED, HIGH);
            delay(1000);
            digitalWrite(HEART_BEAT_LED, LOW);
            delay(1000);
            if(count >= 3)
            {
                debugSerial.println("ARDUINO: Resetting ESP chip");
                esp.enable();
                delay(500);
                hardResetEspChip();
                delay(1000);
                esp.reset();
                delay(500);
                count = 0;
            }

            count++;
        }


        /*setup wifi*/
        debugSerial.println("ARDUINO: Setting up wifi");
        esp.wifiConnect(SSID,PASSWORD);
        // We should chill here until we get a wifi connection
        while(!wifiConnected && (count < triesBeforeChipReset) )
        {
            esp.process();
            delay(100);
            ++count;
        }
        count = 0;
    }
}
Esempio n. 7
0
void loop(void)
{

    if(!wifiConnected)
    {
        debugSerial.println("ARDUINO: Wifi down, bringing it up");
        bringUpWifi();

        espMultipleProcess(10);
        delay(1000);

    }

    if(!MqttClient::connected && wifiConnected)
    {
        debugSerial.println("ARDUINO: Mqtt down, bringing it up");
        bringUpMqtt();
        espMultipleProcess(10);
        delay(1000);
    }

    if(MqttClient::connected && !wifiConnected)
    {
        debugSerial.println("ARDUINO: Bad state. mqtt somehow connected and wifi isn't");
        debugSerial.println("ARDUINO: restarting state machine");
        wifiConnected = false;
        delay(1000);
    }

    // subscriptions!!!!
    if(wifiConnected && MqttClient::connected)
    {
        debugSerial.println("ARDUINO: All systems online!");
        // set subscriptions
        mqttClient.subscribe();
        espMultipleProcess(10);
        delay(1000);
    }

    while(wifiConnected && MqttClient::connected)
    {
        // Throw some clock cycles at the esp
        esp.process();

        buttonPressed = (PINC & 0x0F);

        if( buttonPressed )
        {
            // lastButtonPressed will be cleared after a time
            if( buttonPressed!=lastButtonPressed )
            {
                if( buttonPressed == BTN_1)
                {
                    ledsOff = !ledsOff;
                    forceLedUpdate = true;
                    debugSerial.println("Turning Button Leds");
                    debugSerial.println(ledsOff?"OFF":"ON");

                    //if( !sendCmd(e_cmdButton1) )
                    //{
                    //	debugSerial.println("Error sending e_cmdButton1");
                    //}
                }
                else if( buttonPressed == BTN_2 )
                {
                    if( !sendCmd(e_cmdButton2) )
                    {
                        debugSerial.println("ARDUINO: Error sending e_cmdButton2");
                    }
                }
                else if( buttonPressed == BTN_3 )
                {
                    if( !sendCmd(e_cmdButton3) )
                    {
                        debugSerial.println("ARDUINO: Error sending e_cmdButton3");
                    }
                }
                else if( buttonPressed == BTN_4 )
                {
                    if( !sendCmd(e_cmdButton4) )
                    {
                        debugSerial.println("ARDUINO: Error sending e_cmdButton4");
                    }
                }

                espMultipleProcess(5);
                delay(debounceDelay); //debounce delay
                // save lastButtonPressed to check against next time
                lastButtonPressed = buttonPressed;
                buttonPressed = 0x00;
            }
            else
            {
                // They pressed the same button again, restart the counter
                lastButtonPressExpireTimer = 0;
            }
        }
        if(lastButtonPressed)
        {
            ++lastButtonPressExpireTimer;
        }
        // After a while, we clear the lastButtonPressed
        // The point is to prevent a user holding a button
        if(lastButtonPressExpireTimer > lastButtonPressTimeout)
        {
            lastButtonPressed = 0x00;
            lastButtonPressExpireTimer = 0;
        }

        ++cyclesCount;

        if( (cyclesCount >= ledUpdateWaitCycles) || forceLedUpdate )
        {
            updateButtonLeds(ledsOff);
            cyclesCount = 0;
            forceLedUpdate = false;
        }
    }
}
void ArduinoWifiClass::connect(char* ssid,char* pwd){
	esp.wifiConnect(ssid, pwd);
}