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

Request the Network Server Time

The end device first sends a Class A uplink containing a DeviceTimeReq MAC command. There is no payload associated with the DeviceTimeReq MAC command; it is sent as a single octet command identifier (CID) set to 0x0D, as described in section 5, MAC Commands (page 27) of the LoRaWAN® Link Layer Specification v1.0.4. Learn about sending uplinks containing MAC commands in the section Sending MAC Commands of the Sending Messages Book.

When transmission of the uplink containing DeviceTimeReq ends, the end device must note its internal time, referred to here as END_OF_DEVICETIMEREQ_TRANSMISSION_TIME.

Note

The DeviceTimeReq MAC command should be sent within the FOpts field, taking advantage of encryption, unless there is application data to send at the same time.

Wait for the DeviceTimeAns MAC command to be returned by the network server in one of the RX windows, as described in the section Handling MAC Commands of the Receiving Messages Book. As shown in Figure 1, DeviceTimeAns contains the number of seconds and fractional seconds since the GPS epoch (January 6th, 1980, 00:00:00 UTC) on the network server at the end of the uplink transmission.

Fields contained in DeviceTimeAns

Figure 1: Fields Contained in DeviceTimeAns

The end device can now use the time supplied by the DeviceTimeAns along with the internal time noted at the end of transmission (END_OF_DEVICETIMEREQ_TRANSMISSION_TIME) and adjust its internal clock accordingly so that it matches the network server’s clock.

Warning

The GPS epoch does not consider leap seconds and is not considered UTC time. If your end device uses UTC time, adjust accordingly.

Learn more about requesting the network server time in the sections 5.9 End-Device Time Commands (page 41) and 8.1: Introduction to Class B, Principle of Synchronous Network-initiated Class B Downlinks (page 51) of the LoRaWAN Link Layer Specification v1.0.4.