5 - Class B

This book explores in depth how to use Class B in end devices implementing LoRaWAN® 1.0.4. Class B mode enables the end device to receive downlinks at regular intervals. We teach you how to configure your end device to receive Class B downlinks using beacons and ping slots and best practices to follow to increase the chance of receiving downlinks while maintaining reasonable battery life.

Listening for Class B Downlinks

Timing of Ping Slot Windows

Beacons are broadcast once every 128 seconds. When a beacon is first detected, there is a period of 2.120 seconds during which no downlinks will be received, allowing time for the beacon to be demodulated. This period is referred to as BEACON_RESERVED in the specification.

Just before the next beacon will be received there is a period of 3 seconds during which no downlinks will be transmitted, allowing time to complete transmission of any Class B downlinks before the next beacon is broadcast. This period is referred to as the BEACON_GUARD in the specification.

There is a beacon window (BEACON_WINDOW) of 122.880 seconds during which a Class B downlink can be received between the BEACON_RESERVED period directly after the preceding beacon is received and the BEACON_GUARD period before the next beacon is received.

Timing of BEACON_RESERVED, BEACON_WINDOW and BEACON_GUARD

Figure 1: Timing of BEACON_RESERVED, BEACON_WINDOW and BEACON_GUARD

The beacon window period is divided into 4096 windows of 30ms each, referred to in the specification as ping slots. One or more of these ping slots is then selected by the network server to broadcast any queued downlinks, as shown in Figure 2.

Ping Slots Within the BEACON_WINDOW, with an Example of a Downlink Being Broadcast in Ping Slot 3

Figure 2: Ping Slots Within the BEACON_WINDOW, with an Example of a Downlink Being Broadcast in Ping Slot 3

The ping slot used to send a downlink is randomized per beacon period and per end device, which reduces the chance of the gateway having to transmit multiple downlinks at the same time. An algorithm is run by the network server to identify the ping slot or slots it will use in each beacon period; the end device runs the same algorithm so that it begins to listen at the same time as the network server is transmitting.

Use the algorithm in section 11.2 ‘Slot Randomization’ (page 60) of the LoRaWAN® Link Layer Specification v1.0.4 to calculate the times when the downlink windows must be opened. This algorithm requires the following inputs:

  • End device address (DevAddr)

    When listening for unicast messages, use the DevAddr value set during the end device activation process, described in section Step 3: Join Procedure Overview of the End Device Activation Book.

    When listening for multicast messages, use the multicast network address as the DevAddr. See section Send Messages to Multiple End Devices Simultaneously for more details on multicasting.

  • Periodicity

    When listening for unicast messages, the Periodicity is a configurable setting that the end device and network server use to calculate the number of ping slots to use for transmission during each beacon window. The algorithm to use to convert the Periodicity value into the number of ping slots to use per beacon window (PingNb) is found in Section 11.2, ‘Slot Randomization’ (page 60) of the LoRaWAN Link Layer Specification v1.0.4.

    The end device must begin by using the PING_SLOT_PERIODICITY setting, defined as 7 in Section 2.3, ‘Default Settings’ (page 28) of the RP002-1.0.4 LoRaWAN Regional Parameters specification. A Periodicity value of 7 means a single ping slot is used per beacon period, as shown in Figure 5, meaning the end device needs to only listen during a single 30ms period during the 122.880 second beacon window.

    The end device can modify the periodicity to increase the number of ping slots used during each beacon window as explained in Increasing the Number of Ping Slots Used in Each Beacon Window.

    When listening for multicast messages, the application layer defines the value of Periodicity. TS005-2.0.0 LoRAWAN Remote Multicast Setup Specification contains a recommended approach to managing periodicity when using multicasting.

  • Beacon time

    The beacon time value is found in the beacon payload received at the start of the beacon window, in the Time field. The end device should have saved this value, as described in section Store the Time Field and can now retrieve it.

The algorithm will inform you of the ping slot or slots that will be used and the time each will be opened.

If the end device is intended to receive both unicast and multicast messages, as shown in Figure 3, the algorithm must be run twice, first with the unicast DevAddr and Periodicity, then a second time with the multicast DevAddr and Periodicity. The end device can then listen on both unicast and multicast slots during the beacon window.

Multicast and Unicast Ping Slots in Use in the Same Beacon Window

Figure 3: Multicast and Unicast Ping Slots in Use in the Same Beacon Window

Note

If the timing of one of the Class B slots clashes with the time of a Class A receive window, the Class A receive window has priority. Listen on the Class A frequency and data rate to open the Class A receive window, instead of the Class B frequency and data rate.