Skip to main content
2 of 2
deleted 2 characters in body
dda
  • 1.6k
  • 1
  • 12
  • 18

In response to your answer: why don't you think it is convenient? As you already noticed, you can use the enum values directly in your sketch.

Anyway, it is better to use a switch statement:

Serial.write("ODB State: ");
switch (odb.getState()) {
  case ODB_DISCONNECTED: 
    Serial.write("Disconnected");
    break;

  case OBD_CONNECTING:
    Serial.write("Connecting");
    break;

  case OBD_CONNECTED:
    Serial.write("Connected");
    break;

  case OBD_FAILED:
    Serial.write("Failed");
    break;

  default:
    // Error case
    break;
}
Serial.write("\n");

This way, whenever the enum is changed (e.g. added items), you automatically fall into the error state, so you know you have to adapter the code.

Michel Keijzers
  • 13k
  • 7
  • 43
  • 59