Improve device and version detection
This commit is contained in:
@@ -97,6 +97,9 @@
|
||||
const errorMessage = $('error-message');
|
||||
const errorLog = $('error-log');
|
||||
const deviceStatus = $('device-status');
|
||||
const deviceUnknownWarning = $('device-unknown-warning');
|
||||
const deviceUnknownAck = $('device-unknown-ack');
|
||||
const deviceUnknownCheckbox = $('device-unknown-checkbox');
|
||||
const patchContainer = $('patch-container');
|
||||
const buildStatus = $('build-status');
|
||||
const existingTgzWarning = $('existing-tgz-warning');
|
||||
@@ -264,37 +267,66 @@
|
||||
});
|
||||
|
||||
// Auto connect -> show device info
|
||||
function displayDeviceInfo(info) {
|
||||
$('device-model').textContent = info.model;
|
||||
const serialEl = $('device-serial');
|
||||
serialEl.textContent = '';
|
||||
const prefixLen = info.serialPrefix.length;
|
||||
const u = document.createElement('u');
|
||||
u.textContent = info.serial.slice(0, prefixLen);
|
||||
serialEl.appendChild(u);
|
||||
serialEl.appendChild(document.createTextNode(info.serial.slice(prefixLen)));
|
||||
$('device-firmware').textContent = info.firmware;
|
||||
}
|
||||
|
||||
btnConnect.addEventListener('click', async () => {
|
||||
try {
|
||||
const info = await device.connect();
|
||||
|
||||
$('device-model').textContent = info.model;
|
||||
const serialEl = $('device-serial');
|
||||
serialEl.textContent = '';
|
||||
const prefixLen = info.serialPrefix.length;
|
||||
const u = document.createElement('u');
|
||||
u.textContent = info.serial.slice(0, prefixLen);
|
||||
serialEl.appendChild(u);
|
||||
serialEl.appendChild(document.createTextNode(info.serial.slice(prefixLen)));
|
||||
$('device-firmware').textContent = info.firmware;
|
||||
displayDeviceInfo(info);
|
||||
|
||||
if (info.isIncompatible) {
|
||||
deviceStatus.textContent =
|
||||
'You seem to have an incompatible Kobo software version installed. ' +
|
||||
'NickelMenu does not support it, and the custom patches are incompatible with this version.';
|
||||
deviceStatus.classList.add('error');
|
||||
btnDeviceNext.hidden = true;
|
||||
btnDeviceRestore.hidden = true;
|
||||
showStep(stepDevice);
|
||||
return;
|
||||
}
|
||||
|
||||
selectedPrefix = info.serialPrefix;
|
||||
|
||||
await availablePatchesReady;
|
||||
const match = availablePatches.find(p => p.version === info.firmware);
|
||||
|
||||
configureFirmwareStep(info.firmware, info.serialPrefix);
|
||||
|
||||
if (match) {
|
||||
await patchUI.loadFromURL('patches/' + match.filename);
|
||||
patchUI.render(patchContainer);
|
||||
updatePatchCount();
|
||||
patchesLoaded = true;
|
||||
configureFirmwareStep(info.firmware, info.serialPrefix);
|
||||
btnDeviceRestore.hidden = false;
|
||||
} else {
|
||||
btnDeviceRestore.hidden = true;
|
||||
}
|
||||
|
||||
deviceStatus.textContent = 'Your device has been recognized. You can continue to the next step!';
|
||||
btnDeviceRestore.hidden = !patchesLoaded || !firmwareURL;
|
||||
|
||||
deviceStatus.classList.remove('error');
|
||||
const isUnknownModel = info.model.startsWith('Unknown');
|
||||
if (isUnknownModel) {
|
||||
deviceStatus.textContent = '';
|
||||
deviceUnknownWarning.hidden = false;
|
||||
deviceUnknownAck.hidden = false;
|
||||
deviceUnknownCheckbox.checked = false;
|
||||
btnDeviceNext.disabled = true;
|
||||
} else {
|
||||
deviceStatus.textContent = 'Your device has been recognized. You can continue to the next step!';
|
||||
deviceUnknownWarning.hidden = true;
|
||||
deviceUnknownAck.hidden = true;
|
||||
deviceUnknownCheckbox.checked = false;
|
||||
btnDeviceNext.disabled = false;
|
||||
}
|
||||
btnDeviceNext.hidden = false;
|
||||
showStep(stepDevice);
|
||||
} catch (err) {
|
||||
@@ -308,6 +340,10 @@
|
||||
goToModeSelection();
|
||||
});
|
||||
|
||||
deviceUnknownCheckbox.addEventListener('change', () => {
|
||||
btnDeviceNext.disabled = !deviceUnknownCheckbox.checked;
|
||||
});
|
||||
|
||||
btnDeviceRestore.addEventListener('click', () => {
|
||||
if (!patchesLoaded) return;
|
||||
selectedMode = 'patches';
|
||||
@@ -329,10 +365,10 @@
|
||||
|
||||
// --- Step 2: Mode selection ---
|
||||
function goToModeSelection() {
|
||||
// In auto mode, disable custom patches if firmware isn't supported
|
||||
// In auto mode, disable custom patches if firmware or download URL isn't available
|
||||
const patchesRadio = $q('input[value="patches"]', stepMode);
|
||||
const patchesCard = patchesRadio.closest('.mode-card');
|
||||
const autoModeNoPatchesAvailable = !manualMode && !patchesLoaded;
|
||||
const autoModeNoPatchesAvailable = !manualMode && (!patchesLoaded || !firmwareURL);
|
||||
|
||||
const patchesHint = $('mode-patches-hint');
|
||||
if (autoModeNoPatchesAvailable) {
|
||||
|
||||
@@ -154,6 +154,7 @@ class KoboDevice {
|
||||
: serial.substring(0, 3);
|
||||
const model = KOBO_MODELS[serialPrefix] || 'Unknown Kobo (' + serial.substring(0, 4) + ')';
|
||||
const isSupported = SUPPORTED_FIRMWARE.includes(firmware);
|
||||
const isIncompatible = firmware.startsWith('5.');
|
||||
|
||||
return {
|
||||
serial,
|
||||
@@ -162,6 +163,7 @@ class KoboDevice {
|
||||
hardwareId,
|
||||
model,
|
||||
isSupported,
|
||||
isIncompatible,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ async function loadWasm() {
|
||||
|
||||
const go = new Go();
|
||||
const result = await WebAssembly.instantiateStreaming(
|
||||
fetch('../wasm/kobopatch.wasm?ts=1773771588'),
|
||||
fetch('../wasm/kobopatch.wasm?ts=1773916731'),
|
||||
go.importObject
|
||||
);
|
||||
go.run(result.instance);
|
||||
|
||||
Reference in New Issue
Block a user