"""
UNI Protocol output definitions.

Created on 26 Jan 2026

Information sourced from public domain Unicore UM980 Interface Specifications © 2023, Unicore
https://www.ardusimple.com/wp-content/uploads/2023/04/Unicore-Reference-Commands-Manual-For-N4-High-Precision-Products_V2_EN_R1.4-1.pdf

:author: semuadmin (Steve Smith)
"""

# pylint: disable=too-many-lines, fixme

from pyunigps.unitypes_core import (
    C4,
    C8,
    FREQNO,
    R4,
    R8,
    S1,
    S2,
    S4,
    U1,
    U2,
    U3,
    U4,
    U5,
    U6,
    U8,
    U16,
    X1,
    X4,
    X24,
)

EXTSOLSTAT = {
    "groupextsolstat": (
        X1,
        {
            "rtkverify": U1,
            "psrionocorr": U3,  # see PSRIONOCORR decode
            "reserved50": U4,
        },
    ),
}

GPSGLOBDS2SIGMASK = {
    "groupgpsmask": (
        X1,
        {
            "gpsl1": U1,
            "gpsl2": U1,
            "gpsl5": U1,
            "bdsb3l": U1,
            "glol1": U1,
            "glol2": U1,
            "bdsb1l": U1,
            "bdsb2l": U1,
        },
    ),
}

GALBDS3SIGMASK = {
    "groupgalmask": (
        X1,
        {
            "gale1": U1,
            "gale5b": U1,
            "gale5a": U1,
            "reserved51": U1,
            "bdsb1l": U1,
            "bdsb3l": U1,
            "bdsb2a": U1,
            "bdsb1c": U1,
        },
    ),
}

UNI_PAYLOADS_GET = {
    "VERSION": {
        "device": U4,
        "swversion": "C033",
        "authtype": "C129",
        "psn": "C066",
        "efuseid": "C033",
        "comptime": "C043",
    },
    "OBSVM": {
        "numobs": U4,
        "groupobs": (
            "numobs",
            {
                "glofreq": U2,
                "prn": U2,
                "psr": R8,
                "adr": R8,
                "psrstd": U2 + "*100",
                "adrstd": U2 + "*10000",
                "doppfreq": R4,
                "cno": U2 + "*100",
                "reserved1": U2,
                "locktime": R4,
                "trstatus": (
                    X4,
                    {
                        "reserved2": U5,
                        "svchan": U5,
                        "cpsflag": U1,
                        "reserved3": U1,
                        "psrflag": U1,
                        "reserved4": U3,
                        "gnss": U3,
                        "reserved5": U2,
                        "sigtype": U5,
                        "L2Cflag": U1,
                        "reserved6": U5,
                    },
                ),
            },
        ),
    },
    # "OBSVH": {} # same as OVSVM, see below
    "OBSVMCMP": {
        "numobs": U4,
        "groupobs": (
            "numobs",
            {
                "obsvmcmp": (
                    X24,
                    {
                        "reserved2": U5,
                        "svchan": U5,
                        "cpsflag": U1,
                        "reserved3": U1,
                        "psrflag": U1,
                        "reserved4": U3,
                        "gnss": U3,
                        "reserved5": U2,
                        "sigtype": U5,
                        "L2Cflag": U1,
                        "reserved6": U5,
                        "doppler": "U028*256",
                        "psr": "U036*128",
                        "adr": "U032*256",
                        "psrstd": U4,  # special processing see PSRSTD decode
                        "adrstd": U4,  # special processing (n+1)/512
                        "prn": U8,
                        "locktime": "U021*32",
                        "cno": U5,  # special processing 20+
                        "glofreq": U6,
                        "reserved7": U16,
                    },
                ),
            },
        ),
    },
    # "OBSVHCMP": {} # same as OBSVMCMP, see below
    # "OBSVBASE": {} # same as OBSVM, see below
    "BASEINFO": {
        "status": U4,
        "ecefx": R8,
        "ecefy": R8,
        "ecefz": R8,
        "stationid": C8,
        "reserved1": U4,
    },
    "GPSION": {
        "a0": R8,
        "a1": R8,
        "a2": R8,
        "a3": R8,
        "b0": R8,
        "b1": R8,
        "b2": R8,
        "b3": R8,
        "ussvid": U2,
        "usweek": U2,
        "ulsec": U4,
        "reserved1": U4,
    },
    "BD3ION": {
        "a1": R4,
        "a2": R4,
        "a3": R4,
        "a4": R4,
        "a5": R4,
        "a6": R4,
        "a7": R4,
        "a8": R4,
        "a9": R4,
        "reserved1": U4,
    },
    # "BDSION": {}, # same as GPSION, see below
    "GALION": {
        "a0": R8,
        "a1": R8,
        "a2": R8,
        "sf1": U1,
        "sf2": U1,
        "sf3": U1,
        "sf4": U1,
        "sf5": U1,
        "reserved1": U4,
    },
    "GPSUTC": {
        "utcwn": U4,
        "tot": U4,
        "clockbias": R8,
        "clockrate": R8,
        "wnlsf": U4,
        "daynum": U4,
        "deltatls": S4,
        "deltatlsf": S4,
        "deltatutc": U4,
        "reserved1": U4,
    },
    "BD3UTC": {
        "utcwn": U4,
        "tot": U4,
        "clockbias": R8,
        "clockrate": R8,
        "clockdrift": R8,
        "wnlsf": U4,
        "daynum": U4,
        "deltatls": S4,
        "deltatlsf": S4,
        "reserved1": U4,
        "reserved2": U4,
    },
    "BDSUTC": {
        "reserved1": U4,
        "reserved2": U4,
        "clockbias": R8,
        "clockrate": R8,
        "wnlsf": U4,
        "daynum": U4,
        "deltatls": S4,
        "deltatlsf": S4,
        "reserved3": U4,
        "reserved4": U4,
    },
    "GALUTC": {
        "clockbias": R8,
        "clockrate": R8,
        "deltatls": S4,
        "tot": U4,
        "utcwn": U4,
        "ulwnlsf": U4,
        "daynum": U4,
        "deltatlsf": S4,
        "da0g": S4,
        "da1g": U4,
        "utt0g": U4,
        "ulwn0g": U4,
    },
    "GPSEPH": {
        "prn": S4,
        "tow": R8,
        "health": U4,
        "iode1": U4,
        "iode2": U4,
        "week": U4,
        "zweek": U4,
        "toe": R8,
        "a": R8,
        "deltan": R8,
        "m0": R8,
        "ecc": R8,
        "omega": R8,
        "cuc": R8,
        "cus": R8,
        "crc": R8,
        "crs": R8,
        "cic": R8,
        "cis": R8,
        "i0": R8,
        "idot": R8,
        "omega0": R8,
        "omegadot": R8,
        "iodc": U4,
        "toc": R8,
        "tgd": R8,
        "af0": R8,
        "af1": R8,
        "af2": R8,
        "as": U4,
        "n": R8,
        "ura": R8,
    },
    # "QZSSEPH": {}, # same as GPSEPH, see below
    "BD3EPH": {
        "prn": U1,
        "health": U1,
        "sattype": U1,
        "sismai": U1,
        "iode": U2,
        "iodc": U2,
        "week": U2,
        "zweek": U2,
        "tow": R8,
        "toe": R8,
        "deltaa": R8,
        "ddeltaa": R8,
        "deltan": R8,
        "ddeltan": R8,
        "m0": R8,
        "ecc": R8,
        "omega": R8,
        "cuc": R8,
        "cus": R8,
        "crc": R8,
        "crs": R8,
        "cic": R8,
        "cis": R8,
        "i0": R8,
        "idot": R8,
        "omega0": R8,
        "omegadot": R8,
        "toc": R8,
        "tgdb1cp": R8,
        "tgdb2ap": R8,
        "tgdb2bi": R8,
        "tgdb2bq": R8,
        "iscb2ad": R8,
        "iscb1cd": R8,
        "af0": R8,
        "af1": R8,
        "af2": R8,
        "itop": S4,
        "sisaioe": U1,
        "sisaiocb": U1,
        "sisaioc1": U1,
        "sisaioc2": U1,
        "reserved1": S4,
        "reserved2": S4,
        "freqtype": U4,
    },
    "BDSEPH": {
        "prn": U4,
        "tow": R8,
        "health": U4,
        "aode1": U4,
        "aode2": U4,
        "week": U4,
        "zweek": U4,
        "toe": R8,
        "a": R8,
        "deltan": R8,
        "m0": R8,
        "ecc": R8,
        "omega": R8,
        "cuc": R8,
        "cus": R8,
        "crc": R8,
        "crs": R8,
        "cic": R8,
        "cis": R8,
        "i0": R8,
        "idot": R8,
        "omega0": R8,
        "omegadot": R8,
        "aodc": U4,
        "toc": R8,
        "tgd1": R8,
        "tgd2": R8,
        "af0": R8,
        "af1": R8,
        "af2": R8,
        "as": U4,
        "n": R8,
        "ura": R8,
    },
    "GLOEPH": {
        "sloto": U2,
        "freqo": U2,
        "sattype": U1,
        "reserved1": U1,
        "eweek": U2,
        "etime": U4,
        "toffset": U4,
        "nt": U2,
        "reserved2": U1,
        "reserved3": U1,
        "issue": U4,
        "health": U4,
        "posx": R8,
        "posy": R8,
        "posz": R8,
        "velx": R8,
        "vely": R8,
        "velz": R8,
        "lsaccx": R8,
        "lsaccy": R8,
        "lsaccz": R8,
        "taun": R8,
        "deltataun": R8,
        "gamma": R8,
        "tk": U4,
        "p": U4,
        "ft": U4,
        "age": U4,
        "flags": (X4, {"p1flag": U2, "p2flag": U1, "p3flag": U1, "reserved4": "U028"}),
    },
    "GALEPH": {
        "satid": U4,
        "fnavreceived": U1,
        "inavreceived": U1,
        "e1bhealth": U1,
        "e5ahealth": U1,
        "e5bhealth": U1,
        "e1bdvs": U1,
        "e5advs": U1,
        "e5bdvs": U1,
        "sisa": U1,
        "reserved1": U1,
        "iodnav": U4,
        "toe": U4,
        "roota": R8,
        "deltan": R8,
        "m0": R8,
        "ecc": R8,
        "omega": R8,
        "cuc": R8,
        "cus": R8,
        "crc": R8,
        "crs": R8,
        "cic": R8,
        "cis": R8,
        "i0": R8,
        "idot": R8,
        "omega0": R8,
        "omegadot": R8,
        "fnavt0c": U4,
        "fnavaf0": R8,
        "fnavaf1": R8,
        "fnavaf2": R8,
        "inavt0c": U4,
        "inavaf0": R8,
        "inavaf1": R8,
        "inavaf2": R8,
        "e1e5abgd": R8,
        "e1e5bbgd": R8,
    },
    "IRNSSEPH": {
        "prn": U4,
        "towc": R8,
        "l5health": U4,
        "iodec": U4,
        "shealth": U4,
        "week": U4,
        "reserved1": U4,
        "toe": R8,
        "a": R8,
        "deltan": R8,
        "m0": R8,
        "ecc": R8,
        "omega": R8,
        "cuc": R8,
        "cus": R8,
        "crc": R8,
        "crs": R8,
        "cic": R8,
        "cis": R8,
        "i0": R8,
        "idot": R8,
        "omega0": R8,
        "omegadot": R8,
        "reserved2": U4,
        "toc": R8,
        "tgd": R8,
        "af0": R8,
        "af1": R8,
        "af2": R8,
        "flag": U4,
        "n": R8,
        "ura": R8,
    },
    "AGRIC": {
        "gnss": U4,
        "length": U1,
        "year": U1,
        "month": U1,
        "day": U1,
        "hour": U1,
        "minute": U1,
        "second": U1,
        "postype": U1,
        "headingstat": U1,
        "numgpssta": U1,
        "numbdssta": U1,
        "numglosta": U1,
        "baselinen": R4,
        "baselinee": R4,
        "baselineu": R4,
        "baselinenstd": R4,
        "baselineestd": R4,
        "baselineustd": R4,
        "heading": R4,
        "pitch": R4,
        "roll": R4,
        "speed": R4,
        "veln": R4,
        "vele": R4,
        "velu": R4,
        "xigemavx": R4,
        "xigemavy": R4,
        "xigemavz": R4,
        "lat": R8,
        "lon": R8,
        "alt": R8,
        "ecefx": R8,
        "ecefy": R8,
        "ecefz": R8,
        "xigemalat": R4,
        "xigemalon": R4,
        "xigemaalt": R4,
        "xigemaecefx": R4,
        "xigemaecefy": R4,
        "xigemaecefz": R4,
        "baselat": R8,
        "baselon": R8,
        "basealt": R8,
        "seclat": R8,
        "seclon": R8,
        "secalt": R8,
        "gpsweeksec": S4,
        "diffage": R4,
        "speedheading": R4,
        "undulation": R4,
        "reserved3": R4,
        "reserved4": R4,
        "numgalsta": U1,
        "speedtype": U1,
        "remainchar5": U1,
        "remainchar6": U1,
    },
    "PVTSLN": {
        "bestpostype": U4,
        "bestposhmsl": R4,
        "bestposlat": R8,
        "bestposlon": R8,
        "bestposhmslstd": R4,
        "bestposlatstd": R4,
        "bestposlonstd": R4,
        "bestposdiffage": R4,
        "psrpostype": U4,
        "psrposhmsl": R4,
        "psrposlat": R8,
        "psrposlon": R8,
        "undulation": R4,
        "bestpossvs": U1,
        "bestpossolnsvs": U1,
        "psrpossvs": U1,
        "psrpossolnsvs": U1,
        "psrvelnorth": R8,
        "psrveleast": R8,
        "psrvelground": R8,
        "headingtype": U4,
        "headinglength": R4,
        "headingdegree": R4,
        "headingpitch": R4,
        "headingtrackedsvs": U1,
        "headingsolnsvs": U1,
        "headingggl1": U1,
        "headingggl1l2": U1,
        "gdop": R4,
        "pdop": R4,
        "hdop": R4,
        "htdop": R4,
        "tdop": R4,
        "cutoff": R4,
        "prnnum": U2,
        "groupprn": (
            "None",
            {
                "prn": U2,
            },
        ),
    },
    # "UNILOGLIST": {}, # ascii only
    "BESTNAV": {
        "psolstatus": U4,
        "postype": U4,
        "lat": R8,
        "lon": R8,
        "hmsl": R8,
        "undulation": R4,
        "datumid": U4,
        "latstd": R4,
        "lonstd": R4,
        "hmslstd": R4,
        "stationid": C4,
        "diffage": R4,
        "solage": R4,
        "numsvs": U1,
        "numsolnsvs": U1,
        "reserved1": U1,
        "reserved2": U1,
        "reserved3": U1,
        **EXTSOLSTAT,
        **GALBDS3SIGMASK,
        **GPSGLOBDS2SIGMASK,
        "vsolstatus": U4,
        "veltype": U4,
        "latency": R4,
        "age": R4,
        "horspd": R8,
        "trkgnd": R8,
        "vertspd": R8,
        "verspdstd": R4,
        "horspdstd": R4,
    },
    "BESTNAVXYZ": {
        "psolstatus": U4,
        "postype": U4,
        "px": R8,
        "py": R8,
        "pz": R8,
        "pxstd": R4,
        "pystd": R4,
        "pzstd": R4,
        "vsolstatus": U4,
        "veltype": U4,
        "velx": R8,
        "vely": R8,
        "velz": R8,
        "velxstd": R4,
        "velystd": R4,
        "velzstd": R4,
        "stationid": C4,
        "vellatency": R4,
        "diffage": R4,
        "solage": R4,
        "numsvs": U1,
        "numsolnsvs": U1,
        "numggl1": U1,
        "numsolnmultisvs": U1,
        "reserved1": U4,
        **EXTSOLSTAT,
        **GALBDS3SIGMASK,
        **GPSGLOBDS2SIGMASK,
    },
    # "BESTNAVH": {}, # same as BESTNAV, see below
    # "BESTNAVXYZH": {}, # same as BESTNAVXYX, see below
    "BESTSAT": {
        "numsat": U4,
        "groupsat": (
            "numsat",
            {
                "gnss": U4,
                "satid": U4,
                "status": U4,
                "sigmask": U4,
            },
        ),
    },
    "ADRNAV": {
        "solstatus": U4,
        "postype": U4,
        "lat": R8,
        "lon": R8,
        "hmsl": R8,
        "undulation": R4,
        "datumid": U4,
        "latstd": R4,
        "lonstd": R4,
        "hmslstd": R4,
        "stationid": C4,
        "diffage": R4,
        "solage": R4,
        "numsvs": U1,
        "numsolnsvs": U1,
        "reserved1": U1,
        "reserved2": U1,
        "reserved3": U1,
        **EXTSOLSTAT,
        **GALBDS3SIGMASK,
        **GPSGLOBDS2SIGMASK,
        "solstatus2": U4,
        "veltype": U4,
        "latency": R4,
        "agediff": R4,
        "horspd": R8,
        "trkgnd": R8,
        "vertspd": R8,
        "verspdstd": R4,
        "horspdstd": R4,
    },
    # "ADRNAVH": {}, # same as ADRNAV, see below
    "PPPNAV": {
        "solstatus": U4,
        "postype": U4,
        "lat": R8,
        "lon": R8,
        "hmsl": R8,
        "undulation": R4,
        "datumid": U4,
        "latstd": R4,
        "lonstd": R4,
        "hmslstd": R4,
        "stationid": C4,
        "diffage": R4,
        "solage": R4,
        "numsvs": U1,
        "numsolnsvs": U1,
        "reserved1": U1,
        "reserved2": U1,
        "reserved3": U1,
        **EXTSOLSTAT,
        **GALBDS3SIGMASK,
        **GPSGLOBDS2SIGMASK,
    },
    "SPPNAV": {
        "solstatus": U4,
        "postype": U4,
        "lat": R8,
        "lon": R8,
        "hmsl": R8,
        "undulation": R4,
        "datumid": U4,
        "latstd": R4,
        "lonstd": R4,
        "hmslstd": R4,
        "stationid": C4,
        "diffage": R4,
        "solage": R4,
        "numsvs": U1,
        "numsolnsvs": U1,
        "reserved1": U1,
        "reserved2": U1,
        "reserved3": U1,
        **EXTSOLSTAT,
        **GALBDS3SIGMASK,
        **GPSGLOBDS2SIGMASK,
        "solstatus2": U4,
        "veltype": U4,
        "latency": R4,
        "agediff": R4,
        "horspd": R8,
        "trkgnd": R8,
        "vertspd": R8,
        "verspdstd": R4,
        "horspdstd": R4,
    },
    # "SPPNAVH": {}, # same as SPPNAV, see below
    "STADOP": {
        "reserved1": U4,
        "gdop": R4,
        "pdop": R4,
        "tdop": R4,
        "vdop": R4,
        "hdop": R4,
        "ndop": R4,
        "edop": R4,
        "cutoff": R4,
        "reserved2": R4,
        "numprn": U2,
        "groupprn": (
            "numprn",
            {
                "prn": U2,
            },
        ),
    },
    # "STADOPH": {}, # same as STADOP, see below
    "ADRDOP": {
        "reserved1": U4,
        "gdop": R4,
        "pdop": R4,
        "tdop": R4,
        "vdop": R4,
        "hdop": R4,
        "ndop": R4,
        "edop": R4,
        "cutoff": R4,
        "reserved2": R4,
        "numprn": U2,
        "groupprn": (
            "numprn",
            {
                "prn": U2,
            },
        ),
    },
    # "ADRDOPH": {}, # same as ADRDOP, see below
    "PPPDOP": {
        "reserved1": U4,
        "gdop": R4,
        "pdop": R4,
        "tdop": R4,
        "vdop": R4,
        "hdop": R4,
        "ndop": R4,
        "edop": R4,
        "cutoff": R4,
        "reserved2": R4,
        "numprn": U2,
        "groupprn": (
            "numprn",
            {
                "prn": U2,
            },
        ),
    },
    "SPPDOP": {
        "reserved1": U4,
        "gdop": R4,
        "pdop": R4,
        "tdop": R4,
        "vdop": R4,
        "hdop": R4,
        "ndop": R4,
        "edop": R4,
        "cutoff": R4,
        "reserved2": R4,
        "numprn": U2,
        "groupprn": (
            "numprn",
            {
                "prn": U2,
            },
        ),
    },
    # "SPPDOPH": {}, # same as SPPDOP, see below
    "SATSINFO": {
        "numsat": U1,
        "version": U1,
        "reserved1": U1,
        "reserved2": U1,
        "reserved3": U1,
        "freqflag": (
            X1,
            {
                "l1cab1ie1": U1,
                "l2cl2b2ie5b": U1,
                "l5b3ie5al5": U1,
                "b1cl1c": U1,
                "b2ag3e6": U1,
                "b2bl2p": U1,
                "reserved4": U2,
            },
        ),
        "groupsat": (
            "numsat",
            {
                "prn": U1,
                "azi": S2,
                "elev": S1,
                "groupfreq": (
                    FREQNO,  # calculated by 'look ahead' at run time
                    {"sysstatus": U1, "cno": U1, "freqstatus": U1, FREQNO: U1},
                ),
            },
        ),
    },
    "BASEPOS": {
        "psolstatus": U4,
        "postype": U4,
        "lat": R8,
        "lon": R8,
        "hmsl": R8,
        "undulation": R4,
        "datumid": U4,
        "latstd": R4,
        "lonstd": R4,
        "hgtstd": R4,
        "stationid": C4,
        "diffage": R4,
        "solage": R4,
        "numsvs": U1,
        "numsolnsvs": U1,
        "reserved1": U1,
        "reserved2": U1,
        "reserved3": U1,
        **EXTSOLSTAT,
        **GALBDS3SIGMASK,
        **GPSGLOBDS2SIGMASK,
        "vsolstatus": U4,
        "veltype": U4,
        "latency": R4,
        "agediff": R4,
        "horspd": R8,
        "trkgnd": R8,
        "vertspd": R8,
        "verspdstd": R4,
        "horspdstd": R4,
    },
    "SATELLITE": {
        "gnss": U4,
        "satvis": U4,
        "compalm": U4,
        "numsat": U4,
        "groupsat": (
            "numsat",
            {
                "glofreq": U2,
                "prn": U2,
                "health": U4,
                "elv": R8,
                "azi": R8,
                "reserved1": R8,
                "reserved2": R8,
            },
        ),
    },
    "SATECEF": {
        "numsat": U4,
        "groupsat": (
            "numsat",
            {
                "gnss": U4,
                "prn": U4,
                "satcoordx": R4,
                "satcoordy": R4,
                "satcoordz": R4,
                "satclk": R4,
                "ionodelay": R4,
                "tropdelay": R4,
                "reserved1": R8,
            },
        ),
    },
    "RECTIME": {
        "clockstatus": U4,
        "offset": R8,
        "offsetstd": R8,
        "utcoffset": R8,
        "utcyear": U4,
        "utcmonth": U1,
        "utcday": U1,
        "utchour": U1,
        "utcmin": U1,
        "utcms": U4,
        "utcstatus": U4,
    },
    "UNIHEADING": {
        "solstat": U4,
        "postype": U4,
        "length": R4,
        "heading": R4,
        "pitch": R4,
        "reserved1": R4,
        "hdgstddev": R4,
        "ptchstddev": R4,
        "stationid": C4,
        "numsvs": U1,
        "numsolnsvs": U1,
        "numobs": U1,
        "nummulti": U1,
        "reserved2": U1,
        **EXTSOLSTAT,
        **GALBDS3SIGMASK,
        **GPSGLOBDS2SIGMASK,
    },
    "UNIHEADING2": {
        "solstat": U4,
        "postype": U4,
        "length": R4,
        "heading": R4,
        "pitch": R4,
        "reserved1": R4,
        "hdgstddev": R4,
        "ptchstddev": R4,
        "masterstationid": C4,
        "numsvs": U1,
        "numsolnsvs": U1,
        "numobs": U1,
        "nummulti": U1,
        "reserved2": U1,
        **EXTSOLSTAT,
        **GALBDS3SIGMASK,
        **GPSGLOBDS2SIGMASK,
    },
    "HEADINGSTATUS": {
        "cfglength": R4,
        "cfgtol": R4,
        "reserved1": R4,
        "reserved2": R4,
        "reserved3": R4,
        "reserved4": R4,
        "reserved5": U4,
        "reserved6": U4,
    },
    "RTKSTATUS": {
        "gpssource": U4,
        "reserved1": U4,
        "bdssource1": U4,
        "bdssource2": U4,
        "reserved2": U4,
        "glosource": U4,
        "reserved3": U4,
        "galsource1": U4,
        "galsource2": U4,
        "qzsssource": U4,
        "reserved4": U4,
        "postype": U4,
        "calcstatus": U4,
        "iondetected": U1,
        "dualrtkflag": U1,
        "adrnumber": U1,
        "reserved5": U1,
    },
    "AGNSSSTATUS": {
        "gpssource": U2,
        "bdssource": U2,
        "glosource": U2,
        "galsource": U2,
        "reserved1": U4,
        "calcstatus": U4,
        "aidday": U4,
        "aidmonth": U4,
        "aidyear": U4,
        "reserved2": U4,
        "aidtime": R8,
        "aid": U2,
        "reserved3": U2,
        "reserved4": U4,
        "aidlat": R8,
        "aidlon": R8,
        "aidheight": R8,
    },
    "RTCSTATUS": {
        "type": U1,
        "reserved1": U1,
        "reserved2": U1,
        "reserved3": U1,
        "week": S4,
        "second": U4,
        "subsecond": U4,
        "reserved4": U4,
        "reserved5": U4,
    },
    "JAMSTATUS": {
        "postype": U4,
        "cwratio": U1,
        "cwflag": U1,
        "reserved1": U1,
        "reserved2": U1,
    },
    "FREQJAMSTATUS": {
        "postype": U4,
        "l1cwratio": U1,
        "l1cwflag": U1,
        "l2cwratio": U1,
        "l2cwflag": U1,
        "l5cwratio": U1,
        "l5cwflag": U1,
        "reserved1": U1,
        "reserved2": U1,
    },
    "RTCMSTATUS": {
        "msgid": U4,
        "msgnum": U4,
        "baseid": U4,
        "numsats": U4,
        "l1num": U1,
        "l2num": U1,
        "l3num": U1,
        "l4num": U1,
        "l5num": U1,
        "l6num": U1,
    },
    "HWSTATUS": {
        "reserved1": S4,
        "dc09": R4,
        "dc10": R4,
        "dc18": R4,
        "clockflag": U4,
        "clockdrift": R4,
        "reserved": R4,
        "hwflag": U1,
        "reserved2": U1,
        "plllock": U2,
        "reserved3": U4,
        "reserved4": U4,
    },
    "AGC": {
        "ant1l1": S2,
        "ant1l2": S2,
        "ant1l5": S2,
        "reserved1": S2,
        "reserved2": S2,
        "ant2l1": S2,
        "ant2l2": S2,
        "ant2l5": S2,
        "reserved3": S2,
        "reserved4": S2,
    },
    # "KSXT": {}, # ascii only
    "INFOPART1": {
        "nummsg": U1,
        "groupmsg": (
            "nummsg",
            {
                "info": U1,
                "length": U2,
                "groupdata": (
                    "length",
                    {
                        "data": U1,
                    },
                ),
            },
        ),
    },  # TODO double check this is groupdata within groupmsg or not?
    # "INFOPART2": {}, # same as INFOPART, see below
    "MSPOS": {
        "mainpsoltatus": U4,
        "mainpostype": U4,
        "mainlat": R8,
        "mainlon": R8,
        "mainhmsl": R8,
        "mainlatstd": R4,
        "mainlonstd": R4,
        "mainhmslstd": R4,
        "mainobs": U1,
        "mainsatuse": U1,
        "reserved1": S2,
        "secondarypsolstatus": U4,
        "secondarypostype": U4,
        "secondarylat": R8,
        "secondarylon": R8,
        "secondaryhmsl": R8,
        "secondarylatstd": R4,
        "secondarylonstd": R4,
        "secondaryhmslstd": R4,
        "secondaryobs": U1,
        "secondarysatuse": U1,
        "reserved2": S2,
        "stationid": C4,
        "diffage": R4,
    },
    "TROPINFO": {
        "tropmodel": S4,
        "zenithdelay": R4,
        "drydelay": R4,
        "wetdelay": R4,
        "delaystd": R4,
        "reserved1": R4,
    },
    "PPPB2BINFO1": {
        "prn": S2,
        "iodssr": U1,
        "iodp": U1,
        "sow": U4,
        "prnmask": "U032",
    },
    "PPPB2BINFO2": {
        "prn": U2,
        "iodssr": U1,
        "reserved1": U1,
        "sow": U4,
        "grouporbitcorr": (
            6,
            {
                "orbitcorr": "U012",
            },
        ),
    },
    "PPPB2BINFO3": {
        "prn": U2,
        "iodssr": U1,
        "numsat": U1,
        "sow": U4,
        "groupbias": (
            "numsat",
            {
                "codebias": "U064",
            },
        ),
    },
    "PPPB2BINFO4": {
        "prn": U2,
        "iodssr": U1,
        "iodp": U1,
        "sow": U4,
        "subtype": U1,
        "reserved1": U3,
        "groupclockbias": (
            23,
            {
                "clkcorr": U4,
            },
        ),
    },
    "PPPB2BINFO5": {
        "prn": U2,
        "iodssr": U1,
        "iodp": U1,
        "subtype": U1,
        "reserved1": U1,
        "reserved2": U1,
        "reserved3": U1,
        "sow": U4,
        "groupurai": (
            70,
            {
                "urai": U2,
            },
        ),
    },
    "PPPB2BINFO6": {
        "prn": U2,
        "numc": U1,
        "numo": U1,
        "rawnumc": "U096",
        "rawnumo": "U080",
    },
    "PPPB2BINFO7": {
        "prn": U2,
        "numc": U1,
        "numo": U1,
        "rawnumc": "U128",
        "rawnumo": "U080",
    },
    "E6MASKBLOCK": {
        "toh": U4,
        "blockflag": U1,
        "reserved1": U1,
        "maskid": U1,
        "iodid": U1,
        "numsys": U2,
        "reserved2": U2,
        "groupsys": (
            "numsys",
            {
                "gnssid": U2,
                "satmask": U5,
                "signalmask": U2,
                "cmaf": U1,
                "cm": "U040",
                "nm": U1,
                "reserved3": U3,
            },
        ),
    },
    "E6ORBITBLOCK": {
        "toh": U4,
        "blockflag": U1,
        "reserved1": U1,
        "maskid": U1,
        "iodid": U1,
        "vi": S2,
        "reserved": S2,
        "groupiod": (
            68,
            {
                "iodref": U2,
                "dr": S2,
                "dit": S2,
                "dct": S2,
            },
        ),
    },
    "E6CLOCKFULLBLOCK": {
        "toh": U4,
        "blockflag": U1,
        "reserved1": U1,
        "maskid": U1,
        "iodid": U1,
        "vi": S2,
        "reserved": S2,
        "groupdcm": (
            4,
            {
                "dcm": U1,
            },
        ),
        "groupdcc": (
            68,
            {
                "dcc": S2,
            },
        ),
    },
    "E6CLOCKSUBBLOCK": {
        "toh": U4,
        "blockflag": U1,
        "reserved": U1,
        "maskid": U1,
        "iodid": U1,
        "vi": S2,
        "numsys": S2,
        "groupsys": (
            "numsys",
            {
                "gnssid": U2,
                "dcm": U2,
                "satmask": U5,
                "reserved1": U3,
                "groupdcc": (
                    36,
                    {
                        "dcc": S2,
                    },
                ),
            },
        ),
    },
    "E6CBIASBLOCK": {
        "toh": U4,
        "blockflag": U1,
        "reserved1": U1,
        "maskid": U1,
        "iodid": U1,
        "vi": S2,
        "reserved2": S2,
        "groupcodebias": (
            256,
            {
                "codebiases": S2,
            },
        ),
    },
    "E6PBIASBLOCK": {
        "toh": U4,
        "blockflag": U1,
        "reserved1": U1,
        "maskid": U1,
        "iodid": U1,
        "vi": S2,
        "reserved2": S2,
        "groupbias": (
            256,
            {
                "phasebiases": S2,
                "pdi": U2,
            },
        ),
    },
    "BSLNENUHD2": {
        "solstatus": U4,
        "postype": U4,
        "east": R8,
        "north": R8,
        "up": R8,
        "eaststd": R4,
        "northstd": R4,
        "upstd": R4,
        "roverid": C4,
        "mainid": C4,
        "numsvs": U1,
        "numsolnsvs": U1,
        "reserved1": U1,
        "reserved2": U1,
        "reserved3": U1,
        **EXTSOLSTAT,
        **GALBDS3SIGMASK,
        **GPSGLOBDS2SIGMASK,
    },
    "BSLNXYZHD2": {
        "solstatus": U4,
        "postype": U4,
        "dx": R8,
        "dy": R8,
        "dz": R8,
        "dxstd": R4,
        "dystd": R4,
        "dzstd": R4,
        "roverid": C4,
        "mainid": C4,
        "numsvs": U1,
        "numsolnsvs": U1,
        "reserved1": U1,
        "reserved2": U1,
        "reserved3": U1,
        **EXTSOLSTAT,
        **GALBDS3SIGMASK,
        **GPSGLOBDS2SIGMASK,
    },
    "DOPHD2": {
        "gdop": R4,
        "pdop": R4,
        "hdop": R4,
        "htdop": R4,
        "tdop": R4,
        "elev": R4,
        "numsats": U4,
        "satslist": U4,
    },
    # ********************************************************************
    # UNI nominal payload definition, used as fallback where no documented
    # payload definition is available.
    # ********************************************************************
    "UNI-NOMINAL": {
        "groupdata": (
            "None",
            {
                "data": X1,
            },
        )
    },
}

# duplicate definitions
UNI_PAYLOADS_GET["OBSVH"] = UNI_PAYLOADS_GET["OBSVM"]
UNI_PAYLOADS_GET["OBSVHCMP"] = UNI_PAYLOADS_GET["OBSVMCMP"]
UNI_PAYLOADS_GET["OBSVBASE"] = UNI_PAYLOADS_GET["OBSVM"]
UNI_PAYLOADS_GET["BDSION"] = UNI_PAYLOADS_GET["GPSION"]
UNI_PAYLOADS_GET["QZSSEPH"] = UNI_PAYLOADS_GET["GPSEPH"]
UNI_PAYLOADS_GET["BESTNAVH"] = UNI_PAYLOADS_GET["BESTNAV"]
UNI_PAYLOADS_GET["BESTNAVXYZH"] = UNI_PAYLOADS_GET["BESTNAVXYZ"]
UNI_PAYLOADS_GET["ADRNAVH"] = UNI_PAYLOADS_GET["ADRNAV"]
UNI_PAYLOADS_GET["SPPNAVH"] = UNI_PAYLOADS_GET["SPPNAV"]
UNI_PAYLOADS_GET["STADOPH"] = UNI_PAYLOADS_GET["STADOP"]
UNI_PAYLOADS_GET["ADRDOPH"] = UNI_PAYLOADS_GET["ADRDOP"]
UNI_PAYLOADS_GET["SPPDOPH"] = UNI_PAYLOADS_GET["SPPDOP"]
UNI_PAYLOADS_GET["INFOPART2"] = UNI_PAYLOADS_GET["INFOPART1"]
