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


Line 49: Line 49:
   const max = Math.pow(2, bits.length);
   const max = Math.pow(2, bits.length);
   return value >= max / 2 ? value - max : value;
   return value >= max / 2 ? value - max : value;
}
function bigIntFromBits(bits) {
  return BigInt('0b' + bits).toString();
}
}


Line 57: Line 61:
   }
   }
   return ascii;
   return ascii;
}
function parseIMEI(hex) {
  let imeiHex = hex.slice(6, 22); // bits 24–74 = 8 bytes = 16 hex chars
  let imei = '';
  for (let i = 0; i < imeiHex.length; i += 2) {
    let byte = parseInt(imeiHex.slice(i, i + 2), 16);
    imei += ((byte >> 4) & 0xF).toString() + (byte & 0xF).toString();
  }
  return imei.replace(/^0+/, '');
}
}


Line 85: Line 79:
     resultBody.appendChild(row);
     resultBody.appendChild(row);
   };
   };
   const getBits = (start, end) => bits.slice(start, end);
   const getBits = (start, end) => bits.slice(start, end);


   // Start parsing
   // Refer to telemetry parser logic — exact structure
   output("IMEI", parseIMEI(hex));
   output("IMEI", bigIntFromBits(getBits(25, 75)));
   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 10:00, 21 July 2025

OTA Packet Parser

OTA Packet Parser


Parsed Output:

FieldValue