-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvin.cpp
More file actions
35 lines (28 loc) · 757 Bytes
/
Copy pathvin.cpp
File metadata and controls
35 lines (28 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "vin.h"
bool discoverVIN(COBD& obd, char* vinOut, size_t vinOutSize) {
LOGI("Discovering VIN...");
if (obd.getVIN(vinOut, vinOutSize)) {
if (strlen(vinOut) > 5) {
LOGI("✅ VIN Found: %s", vinOut);
return true;
}
}
LOGW("VIN failed. Forcing protocol settle...");
obd.uninit();
delay(2000);
if (obd.init()) {
LOGI("Link re-established. Polling VIN again...");
delay(1000);
int dummy;
obd.readPID(PID_RPM, dummy);
delay(500);
if (obd.getVIN(vinOut, vinOutSize)) {
LOGI("✅ VIN Found: %s", vinOut);
return true;
}
}
LOGW("⚠️ VIN unreachable. Falling back to VIN_SET.");
strncpy(vinOut, VIN_SET, vinOutSize);
vinOut[vinOutSize - 1] = '\0';
return false;
}