C
//File: startlightsexploit.ino
// This sketch utilises the dayProgression data point to find the exact moment of lights out, as the day time progression does not begin until after lights out in rolling starts, grid start and grid start with false check.
// The ESP32/ESP8266 can be connected to a servo motor that pushes the button mapped to the handbrake to let go at the exact time of lights out, giving the user an almost instant start with a quick servo
// You should begin running the script once the practice/qualifying ends and terminate it once you begin the race, I may make this automatic in a future update
// NOTE: I do not condone the use of this sketch outside of testing/private lobbies. Any penalties or reprimands received due to this exploit in public lobbies or sport mode solely lies on the user of the script.
//#include "Wifi.h" // ESP32 WiFi include
#include <ESP8266WiFi.h> // ESP8266 WiFi include
#include <GT7UDPParser.h>
#include <Servo.h>
const char *SSID = "Your WiFi SSID";
const char *Password = "Your WiFi Password";
const IPAddress ip(255, 255, 255, 255); // Insert your PS4/5 IP address here
Servo servo;
void startWiFi();
unsigned long previousT = 0;
const long interval = 500;
int32_t prevDay;
GT7_UDP_Parser gt7Telem;
Packet packetContent;
void setup()
{
Serial.begin(115200);
startWiFi();
gt7Telem.begin(ip);
gt7Telem.sendHeartbeat();
servo.attach(2); // gpio pin 2 (D4)
servo.write(180);
}
void loop()
{
unsigned long currentT = millis() / 10;
packetContent = gt7Telem.readData();
if (prevDay != packetContent.packetContent.dayProgression && packetContent.packetContent.dayProgression != 0 && prevDay != 0) {
servo.write(0);
Serial.println("Lights Out!");
}
if (currentT - previousT >= interval)
{ // Send heartbeat every 500ms
previousT = currentT;
gt7Telem.sendHeartbeat();
//Serial.println("Pckt sent");
}
prevDay = packetContent.packetContent.dayProgression;
}
void startWiFi()
{
WiFi.mode(WIFI_STA);
WiFi.begin(SSID, Password);
Serial.print("Attempting to connect to ");
Serial.println(SSID);
uint8_t i = 0;
while (WiFi.status() != WL_CONNECTED)
{
Serial.print('.');
delay(250);
if ((++i % 16) == 0)
{
Serial.println(F(" still trying to connect"));
}
}
Serial.print(F("Connection Successful | IP Address: "));
Serial.println(WiFi.localIP());
}