Skip to content

Commit

Permalink
Added support for dpf clogging (2218E4)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimwhitelaw committed Feb 1, 2024
1 parent f42d005 commit ab3c60d
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions examples/ESP32_Custom/ESP32_Custom_ELMulator.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ const String milResponse = "4101830000"; // MIL response c
const String dtcResponse = "43010341\r\n43010123\r\n43010420"; // DTC response returning 3 DTC codes (multiline response)
const uint32_t odoResponse = 1234567; // Hardcode an odometer reading of 1234567
const String ethPercentResponse = "620052C6";
const String dpfCloggingResponse = "6218E4C6";

ELMulator ELMulator;

void setup()
{
Serial.begin(115200);
Serial.println("Starting ELMulator...");
ELMulator.init(deviceName);
ELMulator.init(deviceName);

// Register the specific PIDs we are going to handle.
// ELMulator will respond to SUPPORTED_PIDS request ("0101") with the appropriate value
Expand Down Expand Up @@ -82,23 +83,47 @@ void handlePIDRequest(const String &request)
}
}

else // Handle any other supported PID request
else if (ELMulator.isMode22(request)) // Mode 0x22 (extended info) service - Mfg-dependent and not defined in OBDII spec
{
uint8_t pidCode = ELMulator.getPidCode(request); // Extract the specific PID code from the request

Serial.print("Mode 22 PID: "); Serial.println(request.substring(2));

if (pidCode == 0x52) // Ethanol percent (mode 0x22)
if (ethPercentResponse.length())
if (request.substring(2).compareTo("52") == 0) // Ethanol percent
{
ELMulator.writeResponse(ethPercentResponse);
return;
if (ethPercentResponse.length())
{
ELMulator.writeResponse(ethPercentResponse);
return;
}
else
{
DEBUG("ETH % response is empty.");
ELMulator.writePidNotSupported();
return;
}
}
else

if (request.substring(2).compareTo("18E4") == 0) // DPF Clogging A-R Giulia
{
DEBUG("ETH % response is empty.");
ELMulator.writePidNotSupported();
return;
if (dpfCloggingResponse.length())
{
ELMulator.writeResponse(dpfCloggingResponse);
return;
}
else
{
DEBUG("DPF Clogging response is empty.");
ELMulator.writePidNotSupported();
return;
}
}

ELMulator.writePidNotSupported();
return;
}
else // Handle any other supported PID request
{
uint8_t pidCode = ELMulator.getPidCode(request); // Extract the specific PID code from the request

// Example response for 0x05 (Engine Coolant Temp) - returning a mock data value
if (pidCode == ENGINE_COOLANT_TEMP)
{
Expand Down

0 comments on commit ab3c60d

Please sign in to comment.