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.
Enabling Class B Mode
Processing and Using the Beacon
The beacon receive window must remain open for long enough to detect a preamble. If no preamble is detected, the end device must stop listening until the next expected beacon broadcast. Consult the Handling Absence of Beacons section for advice on how the end device must behave when no beacons are detected.
If a preamble is detected, the precise time it begins to be received must be stored by the end device, referred to here as BEACON_PREAMBLE_RECEIVE_TIME.
The end device must then demodulate and process the beacon. The beacon frame length and position of the contents depend on the spreading factor defined by the data rate, which varies between regions. Locate the spreading factor to use in the region your end device will operate in by consulting the ‘Class B beacon’ or ‘Class B beacon and default downlink channel’ subsection for the region in Section 2 of the RP002-1.0.4 LoRaWAN® Regional Parameters specification. Cross-reference the spreading factor with Table 74 (page 67) of the LoRaWAN Link Layer Specification v1.0.4 to identify the frame format for the region.
The beacon contains three fields which are used in the next steps: Time, Param, and GwSpecific.
Sync the Clock to the Time Reference
The four Time octets in the beacon communicate the number of seconds elapsed since the GPS epoch at the moment the beacon was transmitted, encoded as explained in Section 13.2, ‘Beacon Frame Format’ (page 68) of the LoRaWAN Link Layer Specification v1.0.4.
The end device must align its internal timing reference with the time contained in the Time field, using the moment the beacon was first detected, referred to earlier as BEACON_PREAMBLE_RECEIVE_TIME.
Store the Time Field
The end device must store the contents of the Time field temporarily for use in the ping slot timing algorithm described in Timing of Ping Slot Windows.
Update TAccuracy Using the Prec Bit
The Param octet contains the Prec bit which communicates the timing precision of the beacons, discussed in the earlier Timing of Beacons section. The contents of the Prec bit must be used to update the value of TAccuracy, first converting the Prec bit by following the algorithm in Section 13.2, ‘Beacon Frame Format’ (page 68) of the LoRaWAN Link Layer Specification v1.0.4.
Use of GwSpecific (Optional)
The GwSpecific octets are not sent by all gateways, so this may not be present.
If the GwSpecific octets are present, they are used to either communicate the GPS coordinates of the antenna broadcasting the beacon, or the network’s NetID alongside a gateway identifier. The rules for understanding the data in the GwSpecific octets are found in section 13.3 ‘Beacon GwSpecific Field Format’ (page 68) of the LoRaWAN Link Layer Specification v1.0.4.
Learn how to use the information in GwSpecific to improve the performance of Class B devices that can move in the best practice section Updating the Network Downlink Route.