Use standard payload files instead of hardcoded byte arrays
It's been 84 years...pull/74/head
parent
e0c077ff81
commit
bba919dbe5
|
@ -118,9 +118,6 @@
|
|||
|
||||
<div class="col-xs-6">
|
||||
<select class="pull-right" id="payloadSelect" onchange="onSelectChange()">
|
||||
<option value="Hekate" id="optionHekate" >Hekate 5.8.0</option>
|
||||
<option value="Atmosphere" id="optionFuseePrimary" >Atmosphère 1.3.2</option>
|
||||
<option value="uploaded" id="optionUpload" >Upload payload</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -161,9 +158,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="./payloads/hekate.js"></script>
|
||||
<script src="./payloads/fusee_ams.js"></script>
|
||||
<script src="./main.js"></script>
|
||||
</body>
|
||||
|
||||
|
|
85
main.js
85
main.js
|
@ -1,3 +1,51 @@
|
|||
function logOutput(...message) {
|
||||
document.getElementById("output").innerHTML = document.getElementById("output").innerHTML + message.join(" ") + "<br>";
|
||||
}
|
||||
|
||||
function clearLog() {
|
||||
document.getElementById("output").innerHTML = "";
|
||||
}
|
||||
|
||||
async function getPayloadList(){
|
||||
return fetch("payloads/payloads.json")
|
||||
.then((response) => {
|
||||
if(!response.ok)
|
||||
throw new Error(response.status);
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
return data.payloads;
|
||||
});
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const payloadSelect = document.getElementById("payloadSelect");
|
||||
|
||||
try {
|
||||
const payloadList = await getPayloadList();
|
||||
|
||||
payloadList.forEach((payload) => {
|
||||
const payloadOption = document.createElement("option");
|
||||
|
||||
payloadOption.value = payload.path;
|
||||
payloadOption.innerHTML = payload.name;
|
||||
|
||||
payloadSelect.appendChild(payloadOption);
|
||||
});
|
||||
} catch (error) {
|
||||
logOutput("There was a problem retreiving the payload list. HTTP error code: " + error)
|
||||
}
|
||||
})()
|
||||
|
||||
async function getPayload(payloadSrc){
|
||||
return fetch(payloadSrc)
|
||||
.then((response) => {
|
||||
if(!response.ok)
|
||||
throw new Error(response.status);
|
||||
return response.arrayBuffer();
|
||||
});
|
||||
}
|
||||
|
||||
const intermezzo = new Uint8Array([
|
||||
0x44, 0x00, 0x9F, 0xE5, 0x01, 0x11, 0xA0, 0xE3, 0x40, 0x20, 0x9F, 0xE5, 0x00, 0x20, 0x42, 0xE0,
|
||||
0x08, 0x00, 0x00, 0xEB, 0x01, 0x01, 0xA0, 0xE3, 0x10, 0xFF, 0x2F, 0xE1, 0x00, 0x00, 0xA0, 0xE1,
|
||||
|
@ -7,14 +55,10 @@ const intermezzo = new Uint8Array([
|
|||
0x5C, 0xF0, 0x01, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x01, 0x40
|
||||
]);
|
||||
|
||||
|
||||
|
||||
const RCM_PAYLOAD_ADDRESS = 0x40010000;
|
||||
const INTERMEZZO_LOCATION = 0x4001F000;
|
||||
const PAYLOAD_LOAD_BLOCK = 0x40020000;
|
||||
|
||||
|
||||
|
||||
function createRCMPayload(intermezzo, payload) {
|
||||
const rcmLength = 0x30298;
|
||||
|
||||
|
@ -78,24 +122,8 @@ function readFileAsArrayBuffer(file) {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function logOutput(...message) {
|
||||
document.getElementById("output").innerHTML = document.getElementById("output").innerHTML + message.join(" ") + "<br>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
function clearLog() {
|
||||
document.getElementById("output").innerHTML = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
let device;
|
||||
|
||||
|
||||
|
||||
async function launchPayload(payload) {
|
||||
await device.open();
|
||||
logOutput(`Connected to ${device.manufacturerName} ${device.productName}`);
|
||||
|
@ -135,7 +163,7 @@ async function launchPayload(payload) {
|
|||
document.getElementById("goButton").addEventListener("click", async () => {
|
||||
clearLog();
|
||||
var debugCheckbox = document.getElementById("shouldDebug");
|
||||
const payloadType = document.getElementById("payloadSelect").value;
|
||||
const payloadPath = document.getElementById("payloadSelect").value;
|
||||
|
||||
if(!debugCheckbox.checked) {
|
||||
|
||||
|
@ -150,13 +178,7 @@ document.getElementById("goButton").addEventListener("click", async () => {
|
|||
}
|
||||
|
||||
let payload;
|
||||
if (payloadType === "Hekate") {
|
||||
payload = hekate;
|
||||
|
||||
} else if (payloadType === "Atmosphere") {
|
||||
payload = fusee_ams;
|
||||
|
||||
} else if (payloadType === "uploaded") {
|
||||
if (payloadPath === "uploaded") {
|
||||
const file = document.getElementById("payloadUpload").files[0];
|
||||
if (!file) {
|
||||
alert("You need to upload a file, to use an uploaded file.");
|
||||
|
@ -166,9 +188,13 @@ document.getElementById("goButton").addEventListener("click", async () => {
|
|||
payload = new Uint8Array(await readFileAsArrayBuffer(file));
|
||||
|
||||
} else {
|
||||
logOutput("<span style='color:red'>You're trying to load a payload type that doesn't exist.</span>");
|
||||
try {
|
||||
payload = new Uint8Array(await getPayload(payloadPath));
|
||||
} catch (error) {
|
||||
logOutput("There was a problem retreiving the payload. HTTP error code: " + error)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(debugCheckbox.checked) {
|
||||
logOutput("Logging payload bytes...");
|
||||
|
@ -179,7 +205,6 @@ document.getElementById("goButton").addEventListener("click", async () => {
|
|||
}
|
||||
payloadToLog = payloadToLog;
|
||||
logOutput(payloadToLog);
|
||||
console.log(document.getElementById("payloadUpload").files[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"payloads": [
|
||||
{
|
||||
"name": "Atmosphère 1.5.3",
|
||||
"path": "payloads/ams-1.5.3.bin"
|
||||
},
|
||||
{
|
||||
"name": "Hekate v6.0.3",
|
||||
"path": "payloads/hekate-v6.0.3.bin"
|
||||
},
|
||||
{
|
||||
"name": "TegraExplorer 4.0.1-hotfix4",
|
||||
"path": "payloads/tegraexplorer-4.0.1-hotfix4.bin"
|
||||
},
|
||||
{
|
||||
"name": "Upload payload",
|
||||
"path": "uploaded"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue