Jump to content

OTA PACKET PARSER: Difference between revisions

From Transight Wiki
No edit summary
No edit summary
Line 5: Line 5:
   <style>
   <style>
     body { font-family: Arial, sans-serif; padding: 20px; }
     body { font-family: Arial, sans-serif; padding: 20px; }
     textarea { width: 100%; height: 100px; font-family: monospace; }
     textarea { width: 100%; height: 100px; font-family: monospace; margin-bottom: 10px; }
     button {
     button {
       padding: 10px 20px; border-radius: 20px;
       padding: 10px 20px; border-radius: 20px;
Line 21: Line 21:
<h2>OTA Packet Parser</h2>
<h2>OTA Packet Parser</h2>
<textarea id="hexInput" placeholder="Paste OTA packet hex here..."></textarea><br>
<textarea id="hexInput" placeholder="Paste OTA packet hex here..."></textarea><br>
<button id="parseBtn">Parse OTA Packet</button>
<button onclick="parseOTAPacket()">Parse OTA Packet</button>


<h3>Parsed Output:</h3>
<h3>Parsed Output:</h3>
Line 53: Line 53:
}
}


function parseIMEIFromHex(hex, bitStart, bitEnd) {
function parseIMEIFromHex(hex) {
  const byteStart = bitStart / 8;
   const imeiHex = hex.slice(6, 22); // 8 bytes = 16 hex characters = bits 24–74
  const byteEnd = bitEnd / 8;
   const imeiHex = hex.slice(byteStart * 2, byteEnd * 2); // 2 hex chars per byte
   let imei = '';
   let imei = '';
   for (let i = 0; i < imeiHex.length; i += 2) {
   for (let i = 0; i < imeiHex.length; i += 2) {
     const byte = imeiHex.slice(i, i + 2);
     const byte = parseInt(imeiHex.slice(i, i + 2), 16);
     const firstDigit = (parseInt(byte, 16) & 0xF0) >> 4;
     imei += ((byte >> 4) & 0x0F).toString() + (byte & 0x0F).toString();
    const secondDigit = parseInt(byte, 16) & 0x0F;
    imei += firstDigit.toString() + secondDigit.toString();
   }
   }
   return imei.replace(/^0+/, '');
   return imei.replace(/^0+/, '');
Line 85: Line 81:
   };
   };


   // ✅ Corrected IMEI bit range: 24–74
   // Fields
  const imei = parseIMEIFromHex(hex, 24, 74);
   output("IMEI", parseIMEIFromHex(hex));
   output("IMEI", imei);
 
   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)));
Line 125: Line 119:
   output("Response", bitsToAscii(respBits));
   output("Response", bitsToAscii(respBits));
}
}
 
</script>
</body>
</body>
</html>
</html>

Revision as of 09:44, 21 July 2025

OTA Packet Parser

OTA Packet Parser


Parsed Output:

FieldValue