2 - Sending Messages
Messages sent from an end device to a network server via one or more nearby gateways are referred to as uplinks.
In this book, you learn the rules and best practices to follow when sending uplinks from your end device using the LoRaWAN® 1.0.4 specification.
Composing the Packet
Metadata
These fields, highlighted in Figure 1, must all be sent within each uplink.
Frame Type (FType)
The FType field is three bits long at position [7:5] inside the MAC Header as shown in Figure 2.
FType is used to identify that the frame is an uplink and whether a response is required from the network server.
Set to 010 (unconfirmed data uplink) if the end device does not require a response from the network server. Sending an unconfirmed data uplink uses less power and network time, so use this unless you have a good reason.
Set to 011 (confirmed data uplink) if the end device requires a response from the network server. When the end device sends a confirmed uplink, the response will come in one of the two receive windows opened directly after the transmission of this message. Learn how to handle the response in the Receiving Messages Book.
Read more in Section 4.2.1, ‘Frame types’ (page 16) of the TS001-1.0.4 LoRaWAN® L2 1.0.4 Specification.
MHDR Reserved for future use (RFU) Field
The MAC Header RFU field is three bits long at position [4:2] inside the MAC Header as shown in Figure 2.
RFU is reserved for future use.
Set the MHDR RFU to 000.
Major Data Frame Version (Major)
The Major field is two bits long at position [1:0] inside the MAC Header as shown in Figure 2.
Major defines the major version of the frame format used to construct the packet being sent alongside it.
Set Major to 00, which is the current major version of the frame format.
Read more in Section 4.2.2, ‘Major data frame version’ (page 17) of the TS001-1.0.4 LoRaWAN® L2 1.0.4 Specification.
End Device Address (DevAddr)
The DevAddr field is four octets long and is positioned inside the Frame Header within the MAC Payload, as shown in Figure 2.
DevAddr is used by the network server to identify the end device.
Set the DevAddr field to the DevAddr value set during the end device activation process (described in the Data Stored in End Device After Activation section of the End Device Activation Book.
Read more about the DevAddr in Section 6.1.1, ‘End-device address’ (page 42) of the TS001-1.0.4 LoRaWAN® L2 1.0.4 Specification.
Frame Counter (FCnt)
The FCnt field is two octets long and is positioned inside the Frame Header within the MAC Payload, as shown in Figure 2.
FCnt is used to send the current uplink frame counter (referred to in the specification as FCntUp) to the network server. The frame counter is used by the network server to ensure it has not already received the message.
The End Device Activation Book explained that the end device stores a value entitled FCntUp in memory, set to 0 during the activation process. When a new uplink message is about to be sent from the end device to the network server, the value of FCntUp must be incremented by 1. When retransmitting the same uplink message, the value of FCntUp must not be incremented. Following these rules, the FCnt field can then be set to the current FCntUp value stored in memory.
Read more in Section 4.3.1.5, ‘Frame counter’ (page 22) of the TS001-1.0.4 LoRaWAN® L2 1.0.4 Specification.
Frame Options Length (FOptsLen)
The FOptsLen field is four bits long at position [3..0] inside the Frame Control octet within the Frame Header, as shown in Figure 2.
If the uplink will contain both MAC commands and application data, then the MAC commands must be sent in the FOpts field. The FOpts field can be between 0 and 15 octets long. This FOptsLen field identifies how many octets the variable length FOpts field contains.
For example, if the FOpts field is 4 octets long, then the FOptsLen field must be set to 4. If the FOpts field is not in use, FOptsLen must be set to 0.
Examples of the use of FOptsLen follow in the next section.
Read more in Section 4.3.1.6, ‘Frame options’ (page 23) of the TS001-1.0.4 LoRaWAN® L2 1.0.4 Specification.