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 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

    • 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: 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 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 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 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 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.

      • confirmed: boolean = false

        Whether to ask the network to acknowledge it.

      Returns Transmission

      What to transmit, with its receive windows.

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

      Parameters

      • plan: 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: DeviceSettings

        What its radio can do.

      • xtalAccuracy: LorawanXtalAccuracy = XtalAccuracy.Ppm40

        How accurate its crystal is.

      • cadToRx: LorawanCadToRx = CadToRx.Symbols8

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

      Returns 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: 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: DeviceSettings

        What its radio can do.

      • xtalAccuracy: LorawanXtalAccuracy = XtalAccuracy.Ppm40

        How accurate its crystal is, which its acknowledgments report.

      • cadToRx: LorawanCadToRx = CadToRx.Symbols8

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

      Returns Relay

      The relay, stopped until Relay.start.

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