Jump to content

OTA PACKET PARSER: Difference between revisions

From Transight Wiki
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(b =>
   return hex.match(/.{1,2}/g).map(byte =>
     parseInt(b, 16).toString(2).padStart(8, '0')).join('');
     parseInt(byte, 16).toString(2).padStart(8, '0')).join('');
}
}


Line 59: Line 59:
}
}


function parseIMEIFromHex(hex) {
function parseIMEI(hex) {
   const imeiHex = hex.slice(6, 22); // 8 bytes = 16 hex characters
   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) {
     const byte = parseInt(imeiHex.slice(i, i + 2), 16);
     let byte = parseInt(imeiHex.slice(i, i + 2), 16);
     imei += ((byte >> 4) & 0x0F).toString() + (byte & 0x0F).toString();
     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);


   // Parsing Fields
   // Start parsing
   output("IMEI", parseIMEIFromHex(hex));
   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

OTA Packet Parser


Parsed Output:

FieldValue