1 contributor
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>LoRaWAN MAC Command Decoder</title>
<style>
body {
font-family: sans-serif;
margin: 2em;
max-width: 600px;
}
label {
display: block;
margin-top: 1em;
font-weight: bold;
}
select, input[type="text"], button {
width: 100%;
padding: 0.5em;
margin-top: 0.3em;
font-size: 1em;
}
pre {
background: #f9f9f9;
padding: 1em;
border: 1px solid #ccc;
white-space: pre-wrap;
}
</style>
</head>
<body>
<h1>LoRaWAN MAC Command Decoder</h1>
<label for="direction">Direction</label>
<select id="direction">
<option value="0">Uplink</option>
<option value="1">Downlink</option>
</select>
<label for="payload">Hex Payload</label>
<input type="text" id="payload" placeholder="e.g. 0707b0d68c5006">
<button onclick="decode()">Decode</button>
<label>Decoded Output</label>
<pre id="output">(Decoded results will appear here)</pre>
<script src="maccommands.js"></script>
<script>
function decode() {
const dir = parseInt(document.getElementById("direction").value);
const payload = document.getElementById("payload").value.trim();
const out = document.getElementById("output");
if (!payload.match(/^[0-9a-fA-F]*$/)) {
out.textContent = "Invalid hex string.";
return;
}
try {
const result = macDecode(dir, payload);
out.textContent = JSON.stringify(result, null, 2);
} catch (err) {
out.textContent = "Error decoding: " + err.message;
}
}
</script>
</body>
</html>