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:
@@ -0,0 +1,40 @@
|
||||
package com.evsuite.abrp;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/** The direct ABRP request and its answer — pure JVM, nothing is sent. */
|
||||
public class AbrpApiTest {
|
||||
|
||||
@Test
|
||||
public void credentialsGoInTheBodyEncoded() throws Exception {
|
||||
String body = AbrpApi.formBody("key+1", "tok&en", "{\"utc\":1790000000,\"soc\":80}");
|
||||
assertEquals("api_key=key%2B1&token=tok%26en&tlm=%7B%22utc%22%3A1790000000%2C%22soc%22%3A80%7D", body);
|
||||
assertFalse(AbrpApi.SEND_URL.contains("?"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onlyAnOkStatusIsAccepted() {
|
||||
assertTrue(AbrpApi.accepted(new ServerHttp.Response(200, "{\"status\":\"ok\"}")));
|
||||
assertFalse(AbrpApi.accepted(new ServerHttp.Response(200, "{\"status\":\"error\",\"errors\":[\"bad token\"]}")));
|
||||
assertFalse(AbrpApi.accepted(new ServerHttp.Response(401, "{\"status\":\"ok\"}")));
|
||||
assertFalse(AbrpApi.accepted(new ServerHttp.Response(200, "not json")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void credentialsMustLookLikeCredentials() {
|
||||
assertTrue(AbrpConfig.isPlausible("0a1b2c3d-4e5f-6789"));
|
||||
assertFalse(AbrpConfig.isPlausible("short"));
|
||||
assertFalse(AbrpConfig.isPlausible("has a space in it"));
|
||||
assertFalse(AbrpConfig.isPlausible(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theSampleTimeIsReadFromItsJson() {
|
||||
assertEquals(1790000000L, TelemetryUploader.utcOf("{\"utc\":1790000000,\"soc\":5}"));
|
||||
assertEquals(0L, TelemetryUploader.utcOf("garbage"));
|
||||
}
|
||||
}
|
||||
@@ -87,4 +87,13 @@ public class ConfigImportTest {
|
||||
assertEquals("https://k.example", c.serverUrl);
|
||||
assertEquals("t", c.token);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void abrpCredentialsAreRead() {
|
||||
ConfigImport c = ConfigImport.parse("abrp_api_key = key-1234567890\nABRP_TOKEN = token-abcdefghij\n");
|
||||
assertEquals("key-1234567890", c.abrpApiKey);
|
||||
assertEquals("token-abcdefghij", c.abrpToken);
|
||||
assertFalse(c.isEmpty());
|
||||
assertEquals("token-2", ConfigImport.parse("abrp_user_token = token-2").abrpToken);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user