3 - Receiving Messages

Messages sent from a network server to an end device are referred to as downlinks. These are sent to the end device via a single gateway. If there are multiple gateways near a device, the network server will select the most suitable gateway to broadcast from. This means the end device does not need to consider de-duping.

Devices operating in Class A mode only receive downlinks during the receive windows opened following an uplink, as described in the section Opening Receive Windows of the Sending Messages Book.

Devices that support Class B mode as well as Class A can receive additional downlinks in receive windows opened at fixed time slots. Read more about Class B mode in the Class B Book.

Devices that support Class C mode as well as Class A can receive additional downlinks at any time. Read more in the Class C: Continuously Listening for Downlinks book.

Todo

Fix link

In this book, you learn how to receive and handle downlink packets using the LoRaWAN® 1.0.4 specification.

Processing the Downlink Packet

Check the FPort and FRMPayload Fields

Having calculated the length of the FOpts field in the Frame Header, as described in the previous section Check the FOptsLen and FOpts fields, the end device can now calculate the length of the entire MAC payload in the message. The end device must then inspect the FPort octet found within the MAC Payload as shown in Figure 1 if it is provided in the downlink.

downlink-packet-fport-frmpayload

Figure 1: FPort and FRMPayload fields highlighted in the LoRaWAN® downlink packet structure

If there is no FPort octet present, then there is no further data in the FRMPayload, and the end device can begin processing the MAC commands, as described in the next step Process the MAC Commands.

If FPort value is set to 0, then the accompanying FRMPayload field contains MAC commands. The FRMPayload field is found within the MAC payload, as shown in Figure 1. When the FRMPayload contains MAC commands, the end device must decrypt the contents of the field using the NwkSKey. Decrypt the FRMPayload by following the algorithm described in Section 4.3.3, ‘MAC frame payload encryption’ (page 24) of the TS001-1.0.4 LoRaWAN® L2 1.0.4 Specification. Next, the end device should process the MAC commands in the decrypted FRMPayload field, as described in the following step Process the MAC Commands.

Note

The NwkSKey is derived during the activation process, as explained in the End Device Activation Book.

If FPort is set to a value between 1 and 223, then the accompanying FRMPayload contains application data. The FRMPayload field is found within the MAC payload, as shown in Figure 1. When the FRMPayload contains application data, the end device must decrypt the contents of the field using the AppSKey. Decrypt the FRMPayload by following the algorithm described in Section 4.3.3, ‘MAC frame payload encryption’ (page 24) of the TS001-1.0.4 LoRaWAN® L2 1.0.4 Specification. The end device should then process the data in the decrypted FRMPayload field, as described in the upcoming section Process the Application Data.

Note

The AppSKey is derived during the activation process, as explained in the End Device Activation Book.

If the FPort value is set to 224, then a MAC compliance test is being run and the end device must respond as defined by the document LoRaWAN 1.0.4 End Device Certification Requirements for All Regions.