@squawk
    Preparing search index...

    Function decodeModeSMessage

    • Decodes a raw Mode-S message into its typed, discriminated result.

      A downlink format value of 16 or higher always denotes a 112-bit (14 byte) long message; below 16 always denotes a 56-bit (7 byte) short message - this holds for every downlink format, decoded or not. Any bytes whose length does not match what its own downlink format implies is rejected before further decoding, since a mismatch means the buffer is truncated or corrupted (e.g. a bit-flipped DF field misreading a short reply as a long one) rather than a genuine message of that format.

      DF17/18 (extended squitter) messages are only decoded when their CRC is exactly zero - a non-zero CRC on a squitter means the message was corrupted in transit, and this package would rather report "not decodable" than return plausible-looking but wrong data. DF18 messages are further gated on the control field: only CF=0/1/2/5/6 (which share DF17's type-code-coded ME layout) are decoded - see MessageSource, which every decoded DF17/18 message carries so callers can tell a real, direct ICAO address from an anonymous or ground-derived one rather than losing that distinction after the gate. DF24 (Comm-D) is recognized but not decoded - see DecodedModeSMessage. DF19 (military extended squitter) and DF22 (military use) are reserved formats with no publicly documented payload and are not decoded, for the same reason as DF24.

      import { decodeModeSMessage } from '@squawk/mode-s';

      const decoded = decodeModeSMessage(rawMessageBytes);
      if (decoded?.kind === 'extendedSquitterPosition') {
      console.log(decoded.icaoHex, decoded.latCpr, decoded.lonCpr);
      }

      Parameters

      • bytes: Uint8Array

        Raw message bytes (7 or 14 bytes).

      Returns DecodedModeSMessage | undefined

      The decoded message, or undefined if bytes' length does not match its downlink format, the downlink format is unrecognized, not decoded by this package, or the message fails its CRC check.