pamoja for TypeScript - v0.2.0
    Preparing search index...

    Variable relayConst

    relay: {
        encodeForward(forwarded: ForwardedUplink): Buffer;
        nextWor(
            synchronization: Synchronization,
            nowUs: number,
            deviceXtalPpm: number,
            symbolUs: number,
            otherChannel?: boolean,
        ): WorSlot | null;
        openWor(
            frame: Uint8Array,
            keys: WorKeys,
            wfcnt: number,
            wor: Carrier,
        ): Carrier;
        openWorAck(
            frame: Uint8Array,
            keys: WorKeys,
            devAddr: number,
            wfcnt: number,
            ack: Carrier,
            uplink: Carrier,
        ): StateSync;
        parseForward(payload: Uint8Array): ForwardedUplink;
        parseWor(frame: Uint8Array): Wor;
        rootWorSKey(networkKey: Uint8Array): Buffer;
        secondChannel(
            secondChannelIndex: number,
            dataRate: number,
            ackOffset: number,
            frequencyHz: number,
        ): LoraRelayChannel | null;
        synchronization(
            worStartUs: number,
            preambleSymbols: number,
            symbolUs: number,
            state: StateSync,
        ): Synchronization;
        tOffsetMs(scanStartUs: number, preambleEndUs: number): number | null;
        unsynchronizedPreamble(
            cadPeriodicity: LorawanCadPeriodicity,
            symbolUs: number,
            cadToRx: LorawanCadToRx,
        ): number;
        worAck(
            keys: WorKeys,
            devAddr: number,
            wfcnt: number,
            ack: Carrier,
            uplink: Carrier,
            state: StateSync,
        ): Buffer;
        worJoinRequest(uplink: Carrier): Buffer;
        worKeys(rootKey: Uint8Array, devAddr: number): WorKeys;
        worUplink(
            keys: WorKeys,
            devAddr: number,
            wfcnt: number,
            uplink: Carrier,
            wor: Carrier,
        ): Buffer;
    } = ...

    A LoRaWAN relay, TS011-1.0.1: what an end device and a relay say to each other.

    A relay sleeps, waking every scan period to look for radio activity. An end device out of a gateway's reach first sends a wake-on-radio (WOR) frame whose preamble spans that sleep and which says where its uplink follows. The relay may acknowledge with its own timing, so the next preamble can be short, then forwards the uplink on port LA_FPORT_RELAY.

    Type Declaration

    • encodeForward: function
      • Writes an uplink a relay forwards on port 226, section 9.1. A strength or ratio past what its field carries goes out as the closest value.

        Parameters

        • forwarded: ForwardedUplink

          The metadata, the frequency, and the end device's frame.

        Returns Buffer

        The relay uplink's payload.

        For a data rate or frequency the fields cannot carry.

    • nextWor: function
      • Picks the relay scan a synchronized end device aims its next WOR frame at, appendix 1.

        Parameters

        • synchronization: Synchronization

          What the device knows of the relay.

        • nowUs: number

          The time.

        • deviceXtalPpm: number

          The device's crystal accuracy.

        • symbolUs: number

          The symbol time of the WOR frame's data rate.

        • otherChannel: boolean = false

          Whether the frame goes out on the relay's other channel.

        Returns WorSlot | null

        When to send and how long a preamble, or null once the drift exceeds a period.

    • openWor: function
      • Checks a WOR frame ahead of a Class A uplink and reads where the uplink follows.

        Parameters

        • frame: Uint8Array

          The frame a relay received.

        • keys: WorKeys

          The keys of the device it names.

        • wfcnt: number

          The full 32-bit counter the relay takes it to carry.

        • wor: Carrier

          The carrier it arrived on.

        Returns Carrier

        Where and how fast the uplink follows.

        When the frame is not an uplink WOR, or its integrity code does not verify.

    • openWorAck: function
      • Checks and reads a WOR ACK, section 6.2.

        Parameters

        • frame: Uint8Array

          The acknowledgment an end device received.

        • keys: WorKeys

          The device's WOR keys.

        • devAddr: number

          Its address.

        • wfcnt: number

          The counter of the WOR frame it sent.

        • ack: Carrier

          The carrier the acknowledgment arrived on.

        • uplink: Carrier

          The carrier the WOR frame named.

        Returns StateSync

        What the relay said about itself.

        When the integrity code does not verify, or the periodicity is reserved.

    • parseForward: function
      • Reads an uplink a relay forwarded, section 9.1.

        Parameters

        • payload: Uint8Array

          The relay uplink's payload on port 226.

        Returns ForwardedUplink

        The metadata, the frequency, and the end device's frame.

        For a payload too short or a reserved WOR channel.

    • parseWor: function
      • Reads a WOR frame, leaving an uplink's carrier sealed.

        Parameters

        • frame: Uint8Array

          The bytes a relay received.

        Returns Wor

        The frame's kind, and a join request's carrier or an uplink's address and counter.

        For a reserved or proprietary type, or a length that is not the type's.

    • rootWorSKey: function
      • Derives an end device's root relay session key from its network session key, section 4.4.

        Parameters

        • networkKey: Uint8Array

          The 16-byte network session key.

        Returns Buffer

        The 16-byte root key.

    • secondChannel: function
      • Reads the second channel a relay or end device configuration describes.

        Parameters

        • secondChannelIndex: number

          The coded index, 1 for a second channel.

        • dataRate: number

          Its data rate.

        • ackOffset: number

          The coded acknowledgment offset, table 35.

        • frequencyHz: number

          Its frequency.

        Returns LoraRelayChannel | null

        The channel with its acknowledgment frequency, or null when none is named.

    • synchronization: function
      • Works out when a relay scanned from the WOR ACK that answered a frame, appendix 1.

        Parameters

        • worStartUs: number

          When the acknowledged WOR frame started going out.

        • preambleSymbols: number

          Its preamble length.

        • symbolUs: number

          Its symbol time.

        • state: StateSync

          What the acknowledgment said.

        Returns Synchronization

        The synchronization.

    • tOffsetMs: function
      • The offset a relay reports in a WOR ACK, appendix 1.

        Parameters

        • scanStartUs: number

          When the scan that detected the frame started.

        • preambleEndUs: number

          When the frame's preamble ended: when it finished arriving, less the airtime of its sync word and payload.

        Returns number | null

        The offset in milliseconds, or null when the preamble ended before the scan or more than eleven bits of milliseconds after it.

    • unsynchronizedPreamble: function
      • The WOR preamble of an end device that does not know when the relay scans, section 5.2.

        Parameters

        • cadPeriodicity: LorawanCadPeriodicity

          How often the relay scans.

        • symbolUs: number

          The symbol time of the WOR frame's data rate, in microseconds.

        • cadToRx: LorawanCadToRx

          The relay's time to start receiving.

        Returns number

        The preamble length in symbols.

    • worAck: function
      • Builds a relay's WOR ACK, section 6.2.

        Parameters

        • keys: WorKeys

          The end device's WOR keys.

        • devAddr: number

          Its address.

        • wfcnt: number

          The counter of the acknowledged WOR frame.

        • ack: Carrier

          The carrier the acknowledgment goes out on.

        • uplink: Carrier

          The carrier the WOR frame named for the uplink.

        • state: StateSync

          What the relay tells the device.

        Returns Buffer

        The seven-byte acknowledgment.

        For a state or carrier the fields cannot carry.

    • worJoinRequest: function
      • Builds the WOR frame ahead of a join request, section 5.3.1.

        Parameters

        • uplink: Carrier

          Where and how fast the join request follows.

        Returns Buffer

        The five-byte frame.

        For a data rate past 15 or a frequency the field cannot carry.

    • worKeys: function
      • Derives an end device's WOR keys from its root relay session key, section 4.5.

        Parameters

        • rootKey: Uint8Array

          The 16-byte root key.

        • devAddr: number

          The device's address.

        Returns WorKeys

        The integrity and encryption keys.

      • Builds the WOR frame ahead of a Class A uplink, section 5.3.2.

        Parameters

        • keys: WorKeys

          The device's WOR keys.

        • devAddr: number

          Its address.

        • wfcnt: number

          The WOR frame counter, raised for every WOR frame.

        • uplink: Carrier

          Where and how fast the uplink follows.

        • wor: Carrier

          The carrier this WOR frame goes out on.

        Returns Buffer

        The fifteen-byte frame.

        For a carrier the fields cannot carry.

    const keys = session.worKeys()
    const wor = { frequencyHz: 865_100_000, dataRate: 3 }
    const uplink = { frequencyHz: 868_100_000, dataRate: 5 }
    const frame = relay.worUplink(keys, session.devAddr, 1, uplink, wor)
    relay.openWor(frame, keys, 1, wor) // { frequencyHz: 868100000, dataRate: 5 }