Skip to content

Commit 51ffb4f

Browse files
committed
web: add main static/index.html file
1 parent 86e9c86 commit 51ffb4f

File tree

1 file changed

+375
-0
lines changed

1 file changed

+375
-0
lines changed

static/index.html

Lines changed: 375 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,375 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>aa-proxy-rs</title>
6+
<style>
7+
{PICO_CSS}
8+
</style>
9+
</head>
10+
<body>
11+
<div align="right" style="padding-right: 1em">
12+
<small>build: {BUILD_DATE}, git: {GIT_DATE}-{GIT_HASH}</small>
13+
</div>
14+
<div style="text-align: center; margin-top: 1em">
15+
<h3>🛸 aa-proxy-rs configuration</h3>
16+
</div>
17+
<form id="config-form">
18+
<table>
19+
<tr>
20+
<td colspan="2" style="color: #fff; background-color: #202632">
21+
<strong>⚙️ GENERAL OPTIONS</strong>
22+
</td>
23+
</tr>
24+
<tr>
25+
<td><label for="logfile">logfile</label></td>
26+
<td>
27+
<input type="text" id="logfile" /><br />
28+
<small
29+
>Log file path, by default it is saved to <code>/var/log</code> in
30+
<code>tmpfs</code>/memory. If you want, you can change it e.g. to
31+
<code>/persist/aa-proxy-rs.log</code> and it will be saved to SD
32+
card (appended, not replaced).</small
33+
>
34+
</td>
35+
</tr>
36+
<tr>
37+
<td><label for="stats_interval">stats_interval</label></td>
38+
<td>
39+
<input type="number" id="stats_interval" /><br /><small>
40+
Interval of showing data transfer statistics in the log (0 =
41+
disabled) [seconds]</small
42+
>
43+
</td>
44+
</tr>
45+
<tr>
46+
<td><label for="timeout_secs">timeout_secs</label></td>
47+
<td>
48+
<input type="number" id="timeout_secs" /><br /><small>
49+
Data transfer timeout [seconds], after this idle time the session
50+
will be reconnected</small
51+
>
52+
</td>
53+
</tr>
54+
<tr>
55+
<td><label for="legacy">legacy</label></td>
56+
<td>
57+
<input type="checkbox" role="switch" id="legacy" /><br /><small
58+
>Enable legacy USB mode (some HeadUnits/cars needs this enabled
59+
for compatibility)</small
60+
>
61+
</td>
62+
</tr>
63+
<tr>
64+
<td><label for="wired">wired</label></td>
65+
<td>
66+
<input type="text" id="wired" /><br /><small
67+
>Enable wired USB connection to phone (VID:PID should be
68+
specified, zero is wildcard and can be used for single or both
69+
fields)<br />you can obtain it e.g. using `lsusb` after connecting
70+
phone,<br />and then use e.g. "18d1:0" which will handle specified
71+
phone vendor ID (Google Pixel in this example)</small
72+
>
73+
</td>
74+
</tr>
75+
<tr>
76+
<td><label for="dhu">dhu</label></td>
77+
<td>
78+
<input type="checkbox" role="switch" id="dhu" /><br /><small
79+
>Use a Google Android Auto Desktop Head Unit emulator instead of
80+
real HU device (will listen on TCP 5277 port)</small
81+
>
82+
</td>
83+
</tr>
84+
<tr>
85+
<td><label for="udc">udc</label></td>
86+
<td>
87+
<input type="text" id="udc" /><br /><small
88+
>UDC Controller name (used in special configurations)</small
89+
>
90+
</td>
91+
</tr>
92+
<tr>
93+
<td colspan="2" style="color: #fff; background-color: #202632">
94+
<strong>🐞 DEBUGGING</strong>
95+
</td>
96+
</tr>
97+
<tr>
98+
<td><label for="debug">debug</label></td>
99+
<td>
100+
<input
101+
type="checkbox"
102+
role="switch"
103+
id="debug"
104+
/><br /><small></small>
105+
</td>
106+
</tr>
107+
<tr>
108+
<td><label for="hexdump_level">hexdump_level</label></td>
109+
<td>
110+
<select id="hexdump_level">
111+
<option value="Disabled">Disabled</option>
112+
<option value="DecryptedInput">Decrypted Input</option>
113+
<option value="RawInput">Raw Input</option>
114+
<option value="DecryptedOutput">Decrypted Output</option>
115+
<option value="RawOutput">Raw Output</option>
116+
<option value="All">All</option>
117+
</select>
118+
</td>
119+
</tr>
120+
<tr>
121+
<td>
122+
<label for="disable_console_debug">disable_console_debug</label>
123+
</td>
124+
<td>
125+
<input
126+
type="checkbox"
127+
role="switch"
128+
id="disable_console_debug"
129+
/><br /><small
130+
>Disable debug level on console, save it only to logfile (helpful
131+
for <code>hexdump-level</code> option)</small
132+
>
133+
</td>
134+
</tr>
135+
<tr>
136+
<td colspan="2" style="color: #fff; background-color: #202632">
137+
<strong>📶 BLUETOOTH AND WIFI RELATED</strong>
138+
</td>
139+
</tr>
140+
<tr>
141+
<td><label for="advertise">advertise</label></td>
142+
<td>
143+
<input type="checkbox" role="switch" id="advertise" /><br /><small
144+
>BLE advertising</small
145+
>
146+
</td>
147+
</tr>
148+
<tr>
149+
<td><label for="btalias">btalias</label></td>
150+
<td>
151+
<input type="text" id="btalias" /><br /><small
152+
>BLE device name (how your bluetooth device is visible)<br />by
153+
default it is <code>WirelessAADongle-CPUSERIAL</code></small
154+
>
155+
</td>
156+
</tr>
157+
<tr>
158+
<td><label for="connect">connect</label></td>
159+
<td>
160+
<input type="text" id="connect" /><br /><small
161+
>Auto-connect to phone and initiate connection<br />empty
162+
string/no value: don't auto-connect,<br />zeros/wildcard: iterate
163+
over all previously connected devices,<br />set it to phone BT MAC
164+
address for connecting to this specific phone</small
165+
>
166+
</td>
167+
</tr>
168+
<tr>
169+
<td><label for="bt_timeout_secs">bt_timeout_secs</label></td>
170+
<td>
171+
<input type="number" id="bt_timeout_secs" /><br /><small
172+
>Bluetooth handshake timeout [seconds], this is for rare cases
173+
when the phone stops responding, to prevent the bluetooth
174+
handshake deadlock with inifite waiting and not restarting
175+
connection again</small
176+
>
177+
</td>
178+
</tr>
179+
<tr>
180+
<td><label for="iface">iface</label></td>
181+
<td>
182+
<input type="text" id="iface" /><br /><small
183+
>WLAN / Wi-Fi Hotspot interface (for obtaining IP and
184+
BSSID)</small
185+
>
186+
</td>
187+
</tr>
188+
<tr>
189+
<td><label for="hostapd_conf">hostapd_conf</label></td>
190+
<td>
191+
<input type="text" id="hostapd_conf" /><br /><small
192+
>hostapd.conf file location (used for obtaining AP SSID and WPA
193+
passphrase)</small
194+
>
195+
</td>
196+
</tr>
197+
<tr>
198+
<td><label for="keepalive">keepalive</label></td>
199+
<td>
200+
<input type="checkbox" role="switch" id="keepalive" /><br /><small
201+
>BT keep alive mode: BLE adapter doesn't power off after
202+
successful connection, so that the phone can remain connected
203+
(used in special configurations)</small
204+
>
205+
</td>
206+
</tr>
207+
<tr>
208+
<td colspan="2" style="color: #fff; background-color: #202632">
209+
<strong>🕵️‍♂️ MITM CONFIGURATION</strong>
210+
</td>
211+
</tr>
212+
<tr>
213+
<td><label for="mitm">mitm</label></td>
214+
<td><input type="checkbox" role="switch" id="mitm" /></td>
215+
</tr>
216+
<tr>
217+
<td><label for="dpi">dpi</label></td>
218+
<td><input type="number" id="dpi" /></td>
219+
</tr>
220+
<tr>
221+
<td>
222+
<label for="remove_tap_restriction">remove_tap_restriction</label>
223+
</td>
224+
<td>
225+
<input type="checkbox" role="switch" id="remove_tap_restriction" />
226+
</td>
227+
</tr>
228+
<tr>
229+
<td><label for="video_in_motion">video_in_motion</label></td>
230+
<td><input type="checkbox" role="switch" id="video_in_motion" /></td>
231+
</tr>
232+
<tr>
233+
<td><label for="disable_media_sink">disable_media_sink</label></td>
234+
<td>
235+
<input type="checkbox" role="switch" id="disable_media_sink" />
236+
</td>
237+
</tr>
238+
<tr>
239+
<td><label for="disable_tts_sink">disable_tts_sink</label></td>
240+
<td><input type="checkbox" role="switch" id="disable_tts_sink" /></td>
241+
</tr>
242+
<tr>
243+
<td><label for="developer_mode">developer_mode</label></td>
244+
<td><input type="checkbox" role="switch" id="developer_mode" /></td>
245+
</tr>
246+
<tr>
247+
<td colspan="2" style="color: #fff; background-color: #202632">
248+
<strong>🔌 MITM/EV ROUTING CONFIGURATION</strong>
249+
</td>
250+
</tr>
251+
<tr>
252+
<td><label for="ev">ev</label></td>
253+
<td><input type="checkbox" role="switch" id="ev" /></td>
254+
</tr>
255+
<tr>
256+
<td><label for="ev_battery_logger">ev_battery_logger</label></td>
257+
<td>
258+
<input type="text" id="ev_battery_logger" /><br /><small
259+
>Path to script executed when Android Auto session starts/stops
260+
and EV battery data is needed<br />Argument "start" or "stop" is
261+
appended automatically when invoked</small
262+
>
263+
</td>
264+
</tr>
265+
<tr>
266+
<td><label for="ev_battery_capacity">ev_battery_capacity</label></td>
267+
<td>
268+
<input type="number" id="ev_battery_capacity" /><br /><small
269+
>Traction battery capacity [Wh]</small
270+
>
271+
</td>
272+
</tr>
273+
<tr>
274+
<td><label for="ev_factor">ev_factor</label></td>
275+
<td>
276+
<input type="number" step="any" id="ev_factor" /><br /><small
277+
>Some unknown parameter - change this to have a correct range
278+
(u2->u3)</small
279+
>
280+
</td>
281+
</tr>
282+
</table>
283+
284+
<div style="text-align: center; margin-top: 1em">
285+
<button type="button" onclick="saveConfig()">Save</button>
286+
</div>
287+
</form>
288+
289+
<script>
290+
function setValue(id, value) {
291+
const el = document.getElementById(id);
292+
if (!el) return;
293+
294+
if (el.type === "checkbox") {
295+
el.checked = value;
296+
} else {
297+
if (
298+
typeof value === "object" &&
299+
value !== null &&
300+
"vid" in value &&
301+
"pid" in value
302+
) {
303+
el.value = `${value.vid.toString(16).toUpperCase()}:${value.pid.toString(16).toUpperCase()}`;
304+
} else {
305+
el.value = value ?? "";
306+
}
307+
}
308+
}
309+
310+
function getValue(id) {
311+
const el = document.getElementById(id);
312+
if (el.type === "checkbox") {
313+
return el.checked;
314+
} else if (el.type === "number") {
315+
return el.value ? parseFloat(el.value) : null;
316+
} else {
317+
return el.value;
318+
}
319+
}
320+
321+
async function loadConfig() {
322+
const res = await fetch("/config");
323+
const data = await res.json();
324+
for (const key in data) {
325+
if (document.getElementById(key)) {
326+
setValue(key, data[key]);
327+
}
328+
}
329+
}
330+
331+
async function saveConfig() {
332+
const config = {};
333+
const ids = [
334+
"advertise",
335+
"debug",
336+
"hexdump_level",
337+
"disable_console_debug",
338+
"legacy",
339+
"connect",
340+
"logfile",
341+
"stats_interval",
342+
"udc",
343+
"iface",
344+
"hostapd_conf",
345+
"btalias",
346+
"keepalive",
347+
"timeout_secs",
348+
"bt_timeout_secs",
349+
"mitm",
350+
"dpi",
351+
"remove_tap_restriction",
352+
"video_in_motion",
353+
"disable_media_sink",
354+
"disable_tts_sink",
355+
"developer_mode",
356+
"wired",
357+
"dhu",
358+
"ev",
359+
"ev_battery_logger",
360+
"ev_battery_capacity",
361+
"ev_factor",
362+
];
363+
ids.forEach((id) => (config[id] = getValue(id)));
364+
await fetch("/config", {
365+
method: "POST",
366+
headers: { "Content-Type": "application/json" },
367+
body: JSON.stringify(config),
368+
});
369+
alert("Configuration saved!");
370+
}
371+
372+
loadConfig();
373+
</script>
374+
</body>
375+
</html>

0 commit comments

Comments
 (0)