OTA PACKET PARSER: Difference between revisions
No edit summary |
No edit summary |
||
| Line 37: | Line 37: | ||
<script> | <script> | ||
function hexToBits(hex) { | function hexToBits(hex) { | ||
return hex.match(/.{1,2}/g).map( | return hex.match(/.{1,2}/g).map(byte => | ||
parseInt( | parseInt(byte, 16).toString(2).padStart(8, '0')).join(''); | ||
} | } | ||
| Line 59: | Line 59: | ||
} | } | ||
function | function parseIMEI(hex) { | ||
let imeiHex = hex.slice(6, 22); // bits 24–74 = 8 bytes = 16 hex chars | |||
let imei = ''; | let imei = ''; | ||
for (let i = 0; i < imeiHex.length; i += 2) { | for (let i = 0; i < imeiHex.length; i += 2) { | ||
let byte = parseInt(imeiHex.slice(i, i + 2), 16); | |||
imei += ((byte >> 4) & | imei += ((byte >> 4) & 0xF).toString() + (byte & 0xF).toString(); | ||
} | } | ||
return imei.replace(/^0+/, ''); | return imei.replace(/^0+/, ''); | ||
| Line 85: | Line 85: | ||
resultBody.appendChild(row); | resultBody.appendChild(row); | ||
}; | }; | ||
const getBits = (start, end) => bits.slice(start, end); | const getBits = (start, end) => bits.slice(start, end); | ||
// | // Start parsing | ||
output("IMEI", | output("IMEI", parseIMEI(hex)); | ||
output("Packet Type", bitsToInt(getBits(75, 80))); | output("Packet Type", bitsToInt(getBits(75, 80))); | ||
output("OTA Source", bitsToInt(getBits(80, 85))); | output("OTA Source", bitsToInt(getBits(80, 85))); | ||
Revision as of 09:55, 21 July 2025
OTA Packet Parser
Parsed Output:
| Field | Value |
|---|