App 2.11.0, server 2.3.0: live data straight to ABRP; settings regrouped
ABRP keeps getting live data while the car server is down: with an ABRP API key and user token set in the app (Live data tab, or abrp_api_key / abrp_token in the config file), the car sends the newest sample to ABRP itself at every upload. It tells the server the newest sample ABRP took (abrpSentUtc), and the server forwards only newer ones, so ABRP gets each sample once. Without credentials in the app the server forwards everything, as before. The credentials sit in encrypted storage, go in the request body, and neither they nor ABRP's answer are logged. Settings are grouped by what they are for: - Live data (was Upload): on/off, ABRP credentials, upload frequency. - Settings (replaces the Wi-Fi tab): full screen and voice key, usable capacity and manual SoH (were on Consumption), charging price (was on Charging), Wi-Fi. Charging and Live data get icons of their own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QLJfZQZeAKAwSqViTmLzki
This commit is contained in:
@@ -204,3 +204,23 @@ func jsonInt(v int64) string {
|
||||
b, _ := json.Marshal(v)
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func TestSamplesTheCarSentToAbrpAreNotForwardedAgain(t *testing.T) {
|
||||
samples := []TelemetrySample{{UTC: 100}, {UTC: 115}, {UTC: 130}}
|
||||
if got := notYetAtAbrp(samples, 0); len(got) != 3 {
|
||||
t.Fatalf("without abrpSentUtc everything is forwardable: %d", len(got))
|
||||
}
|
||||
if got := notYetAtAbrp(samples, 130); len(got) != 0 {
|
||||
t.Fatalf("the car sent the newest: %d left", len(got))
|
||||
}
|
||||
if got := notYetAtAbrp(samples, 115); len(got) != 1 || got[0].UTC != 130 {
|
||||
t.Fatalf("only the newer sample: %+v", got)
|
||||
}
|
||||
b, err := validateTelemetryBatch([]byte(`{"installationId":"`+testInstallation+`","abrpSentUtc":1790000000,"samples":[{"utc":1790000000}]}`), testNow)
|
||||
if err != nil || b.AbrpSentUTC != 1790000000 {
|
||||
t.Fatalf("abrpSentUtc not read: %v %d", err, b.AbrpSentUTC)
|
||||
}
|
||||
if _, err := validateTelemetryBatch([]byte(`{"installationId":"`+testInstallation+`","abrpSentUtc":"x","samples":[{"utc":1790000000}]}`), testNow); !isValidationError(err) {
|
||||
t.Fatal("a malformed abrpSentUtc was accepted")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user