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

    Class Relay

    A LoRaWAN relay: an end device that also carries the uplinks of the devices around it.

    A relay sleeps, waking every scan period to look for radio activity on its WOR channel. One turn runs like this: Relay.nextScan says when and where to listen, a frame heard there goes to Relay.heardWor, the uplink it announced to Relay.heardUplink, and Relay.forward wraps that in one of the relay's own uplinks on port LA_FPORT_RELAY. What the relay's own receive windows hear goes to Relay.heardIn, which turns a downlink meant for an end device into one to send in that device's relay window.

    It owns no radio and no clock, so the same relay runs over any radio, or in a test with none. The codecs behind it are on the relay object.

    const node = Relay.personalized(planFor(LoraRegion.Eu868), devAddr, nwkSKey, appSKey, {
    minOutputDbm: 2,
    maxOutputDbm: 14,
    })
    node.start(CadPeriodicity.Ms1000, 0)
    node.trust(0, { devAddr: sensorAddr, rootWorSKey: relay.rootWorSKey(sensorNwkSKey) })
    const scan = node.nextScan(clock.nowUs())
    Index
    • get dataRate(): number

      The data rate the relay forwards at, which its acknowledgments report.

      Returns number

    • get devAddr(): number | null

      The address the relay's own device is on the network by, or null before joining.

      Returns number | null

    • get forwardDue(): number | null

      When the forwarded uplink waiting to go out is due, or null with nothing waiting.

      Returns number | null

    • get joined(): boolean

      Whether the relay's own device is on a network.

      Returns boolean

    • get running(): boolean

      Whether the relay is scanning.

      Returns boolean

    • Sends the uplink the relay is holding, in one of its own on port LA_FPORT_RELAY.

      Parameters

      • nowUs: number

        The time, in microseconds.

      Returns lorawan.Transmission

      What to transmit, with the relay's own receive windows.

      A DeviceError when the relay's own device cannot send it yet, or when nothing is waiting.

    • Reads a frame the relay's own device heard, acting on the relay commands in it.

      Parameters

      • window: LorawanReceiveWindow

        The window the radio heard it in.

      • frame: Uint8Array

        The bytes the radio received.

      • snrDb: number

        Its signal-to-noise ratio.

      Returns lorawan.RelayHeard

      What it turned out to be: the relay's own downlink, one to pass on to an end device, or one that cannot be passed on.

    • Reads the uplink a WOR frame announced, and holds it to forward.

      Parameters

      • frame: Uint8Array

        The bytes the radio received.

      • rssiDbm: number

        Its received signal strength.

      • snrDb: number

        Its signal-to-noise ratio.

      • endedUs: number

        When the frame ended, in microseconds.

      Returns number

      When to Relay.forward it: fifty milliseconds after it ended.

      When nothing announced it, or the frame is not the one it announced.

    • Reads a WOR frame a scan heard.

      Parameters

      • scan: lorawan.Scan

        The scan that heard it, as Relay.nextScan returned it.

      • frame: Uint8Array

        The bytes the radio received.

      • rssiDbm: number

        Its received signal strength, which the forwarded uplink carries.

      • snrDb: number

        Its signal-to-noise ratio, which the forwarded uplink carries.

      • endedUs: number

        When the frame ended, in microseconds.

      Returns lorawan.Wake

      What the frame led to: an acknowledgment to send, an uplink to listen for, or a notification for the network.

      For a frame that does not verify, a device the relay does not forward for, or a limit already spent.

    • Builds the relay's own join request.

      Parameters

      • devNonce: number

        A nonce this relay has never used with its join EUI.

      • nowUs: number

        The time, in microseconds.

      Returns lorawan.Transmission

      What to transmit, with the join accept windows.

      A DeviceError: NoCredentials, Busy or Wait.

    • Says when and where to scan next.

      Parameters

      • nowUs: number

        The time, in microseconds.

      Returns lorawan.Scan | null

      The scan, or null while the relay is stopped.

    • Says what comes next once the relay's own windows closed with nothing in them.

      Parameters

      • nowUs: number

        The time the second window closed, in microseconds.

      Returns lorawan.Next

      Whether to repeat the frame, join again, or move on.

      A DeviceError: NothingPending.

    • Sends one of the relay's own uplinks, which also carries what it owes its network.

      Parameters

      • port: number

        The application port, 1 to 223.

      • payload: string | Uint8Array<ArrayBufferLike>

        The payload, as bytes or text encoded as UTF-8.

      • nowUs: number

        The time, in microseconds.

      • Optionalconfirmed: boolean

        Whether to ask the network to acknowledge it.

      Returns lorawan.Transmission

      What to transmit, with its receive windows.

    • Sends an uplink with no payload, carrying whatever the relay owes its network.

      Parameters

      • nowUs: number

        The time, in microseconds.

      Returns lorawan.Transmission

      What to transmit, with its receive windows.

    • Starts scanning, or changes what a running relay scans from its next scan on.

      Parameters

      Returns void

      For a channel index the region does not define.

    • Stops scanning. A forwarded uplink already waiting still goes out.

      Returns void

    • Trusts an end device, as an UpdateUplinkListReq with the same fields does.

      Parameters

      Returns void

      For an index past 15.

    • Clears the uplink a WOR frame announced, once listening heard nothing.

      Returns void

    • Makes a relay whose own device joins over the air.

      Parameters

      • plan: lora.LoraChannelPlan

        A published channel plan.

      • devEui: Uint8Array

        Its 8-byte device EUI.

      • joinEui: Uint8Array

        Its 8-byte join EUI.

      • appKey: Uint8Array

        Its 16-byte root key.

      • settings: lorawan.DeviceSettings

        What its radio can do.

      • OptionalxtalAccuracy: LorawanXtalAccuracy

        How accurate its crystal is.

      • OptionalcadToRx: LorawanCadToRx

        How long it takes to start receiving once it detects activity.

      Returns lorawan.Relay

      The relay, neither joined nor scanning.

      If the plan was built rather than published, or a credential is the wrong length.

    • Makes a relay whose own device is activated by personalization.

      Parameters

      • plan: lora.LoraChannelPlan

        A published channel plan, from planFor or cn470Plan.

      • devAddr: number

        The address the relay was provisioned with.

      • nwkSKey: Uint8Array

        Its 16-byte network session key.

      • appSKey: Uint8Array

        Its 16-byte application session key.

      • settings: lorawan.DeviceSettings

        What its radio can do.

      • OptionalxtalAccuracy: LorawanXtalAccuracy

        How accurate its crystal is, which its acknowledgments report.

      • OptionalcadToRx: LorawanCadToRx

        How long it takes to start receiving once it detects activity.

      Returns lorawan.Relay

      The relay, stopped until Relay.start.

      If the plan was built rather than published, or a key is the wrong length.