Files
L'électron rare f55093d6fe
ESP-IDF CI / Host Tests (Unity) (push) Successful in 1m8s
CI / firmware-native (push) Successful in 2m57s
Rust Protection Tests / Cargo test (host) (push) Failing after 3m21s
ESP-IDF CI / ESP-IDF Build (v5.4) (push) Failing after 6m55s
ESP-IDF CI / Memory Budget Gate (push) Has been skipped
qa-cicd-environments / qa-kxkm-s3-build (push) Successful in 8m53s
qa-cicd-environments / qa-sim-host (push) Successful in 2m2s
qa-cicd-environments / qa-kxkm-s3-memory-budget (push) Successful in 11m17s
chore: import KXKM Batterie Parallelator
Context: the project archive (KXKM_Batterie_Parallelator-main) had
no git history locally; a fresh repository is needed to host it on
git.saillant.cc (electron/KXKM_Batterie_Parallelator).

Approach: initialize a new repo on branch main, stage the archive
content, and harden .gitignore before the first commit.

Changes:
- Import the full project tree: firmware/, firmware-idf/,
  firmware-rs/, iosApp/, kxkm-bmu-app/, kxkm-api/, hardware/,
  docs/, specs/, scripts/, models/, tests/
- Keep project dotfiles tracked despite the trailing '.*' ignore
  rule: .github/, .claude/, .superpowers/, .gitattributes,
  .markdownlint.json
- Extend .gitignore: firmware/src/credentials.h (local secrets,
  template kept), kxkm-bmu-app/**/build/ (66 MB compiled iOS
  framework), .remember/ (session data)

Impact: the project can now be maintained on the self-hosted Gitea
forge with a clean, secret-free initial history.
2026-07-04 12:32:28 +02:00

65 lines
2.3 KiB
JavaScript

// KXKM Batterie Parallelator — ESP-IDF Web UI
// WebSocket sur /ws (meme port), mutations POST avec token JSON
document.addEventListener("DOMContentLoaded", function() {
connectWebSocket();
});
function connectWebSocket() {
console.log("Connecting to WebSocket...");
const ws = new WebSocket('ws://' + location.host + '/ws');
ws.onopen = function() {
console.log("WebSocket connection opened");
const token = document.getElementById('token-input')?.value || '';
ws.send(JSON.stringify({ auth: token }));
};
ws.onmessage = function(event) {
console.log("WebSocket message received: ", event.data);
const data = JSON.parse(event.data);
updateBatteryDisplay(data);
};
ws.onerror = function(error) {
console.error("WebSocket error: ", error);
};
ws.onclose = function() {
console.log("WebSocket connection closed, reconnecting in 3s...");
setTimeout(connectWebSocket, 3000);
};
}
function updateBatteryDisplay(data) {
const table = document.querySelector("#batteryStatusTable tbody");
table.innerHTML = "";
data.batteryStatus.forEach(function(battery) {
const row = document.createElement("tr");
row.innerHTML =
'<td>Battery ' + battery.index + '</td>' +
'<td>' + battery.voltage + '</td>' +
'<td>' + battery.current + '</td>' +
'<td>' + battery.ampereHour + '</td>' +
'<td><span style="color:' + battery.ledStatus + ';">&#9679;</span></td>' +
'<td>' +
'<button onclick="switchBattery(' + battery.index + ', true)">Switch On</button> ' +
'<button onclick="switchBattery(' + battery.index + ', false)">Switch Off</button>' +
'</td>';
table.appendChild(row);
});
}
function switchBattery(index, state) {
console.log('Switching battery ' + index + ' to ' + (state ? 'on' : 'off'));
const token = document.getElementById('token-input')?.value || '';
fetch('/api/battery/switch_' + (state ? 'on' : 'off'), {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ battery: index, token: token })
})
.then(function(r) { return r.text(); })
.then(function(t) { console.log(t); })
.catch(function(e) { console.error(e); });
}