Jump to content

OTA PACKET PARSER: Difference between revisions

From Transight Wiki
No edit summary
No edit summary
Line 4: Line 4:
   <title>OTA Packet Parser</title>
   <title>OTA Packet Parser</title>
   <style>
   <style>
     body { font-family: Arial, sans-serif; padding: 20px; }
     body { font-family: Arial, sans-serif; }
     textarea { width: 100%; height: 100px; font-family: monospace; margin-bottom: 10px; }
     textarea { width: 100%; height: 100px; font-family: monospace; }
     button {
     button {
       padding: 10px 20px; border-radius: 20px;
       padding: 10px 20px;
       font-weight: bold; background-color: #680022; color: white;
      border-radius: 20px;
       border: none; cursor: pointer;
       font-weight: bold;
      background-color: #680022;
      color: white;
       border: none;
      cursor: pointer;
    }
    button:hover {
      background-color: #4c0019;
     }
     }
    button:hover { background-color: #4c0019; }
     table { width: 100%; border-collapse: collapse; margin-top: 20px; }
     table { width: 100%; border-collapse: collapse; margin-top: 20px; }
     th, td { border: 1px solid #ccc; padding: 8px; }
     th, td { border: 1px solid #ccc; padding: 8px; text-align: left; }
     th { background-color: #680022; color: white; }
     th { background-color: #680022; color: white; }
   </style>
   </style>
Line 54: Line 60:


function parseIMEIFromHex(hex) {
function parseIMEIFromHex(hex) {
   const imeiHex = hex.slice(6, 22); // 8 bytes = 16 hex characters = bits 24–74
   const imeiHex = hex.slice(6, 22); // 8 bytes = 16 hex characters
   let imei = '';
   let imei = '';
   for (let i = 0; i < imeiHex.length; i += 2) {
   for (let i = 0; i < imeiHex.length; i += 2) {
Line 68: Line 74:
   resultBody.innerHTML = "";
   resultBody.innerHTML = "";


   if (!hex.startsWith("24")) {
   if (!hex || !hex.startsWith("24")) {
     alert("Packet must start with hex '24'");
     alert("Invalid packet");
     return;
     return;
   }
   }


   const bits = hexToBits(hex);
   const bits = hexToBits(hex);
  const getBits = (start, end) => bits.slice(start, end);
   const output = (label, value) => {
   const output = (label, value) => {
     const row = document.createElement("tr");
     const row = document.createElement("tr");
Line 81: Line 86:
   };
   };


   // Fields
  const getBits = (start, end) => bits.slice(start, end);
 
   // Parsing Fields
   output("IMEI", parseIMEIFromHex(hex));
   output("IMEI", parseIMEIFromHex(hex));
   output("Packet Type", bitsToInt(getBits(75, 80)));
   output("Packet Type", bitsToInt(getBits(75, 80)));
Line 99: Line 106:
   const h = Math.floor(Math.abs(offsetMinutes) / 60);
   const h = Math.floor(Math.abs(offsetMinutes) / 60);
   const m = Math.abs(offsetMinutes % 60);
   const m = Math.abs(offsetMinutes % 60);
   const tzSign = offsetMinutes >= 0 ? "+" : "-";
   const sign = offsetMinutes >= 0 ? "+" : "-";
   output("Timezone", `${offsetMinutes} mins = UTC${tzSign}${h}:${m.toString().padStart(2, '0')}`);
   output("Timezone", `${offsetMinutes} mins = UTC${sign}${h}:${m.toString().padStart(2, '0')}`);


   const localTime = new Date((dt + offsetMinutes * 60) * 1000)
   const localTime = new Date((dt + offsetMinutes * 60) * 1000)
Line 120: Line 127:
}
}
</script>
</script>
</body>
</body>
</html>
</html>

Revision as of 09:53, 21 July 2025

OTA Packet Parser

OTA Packet Parser


Parsed Output:

FieldValue