-
Notifications
You must be signed in to change notification settings - Fork 512
LoRaWAN: Class C
Note
Class C is intended for devices that are plugged in, rather than powered by batteries. Read more about LoRaWAN classes in the TTN documentation.
Configuring your device is as easy as checking the "Supports Class C" checkbox on the most popular network servers. For example on The Things Stack (Sandbox), this is part of the Network settings of your device. On Chirpstack, this can be found in the Device profile.
When scheduling a downlink, this downlink is now likely to be transmitted as a Class C downlink, meaning that it can be transmitted at once (no prior uplink needed). To this end, it selects the best gateway that received the last uplink from this device. Therefore, it is useful to have your device sending uplinks at a reasonable interval (e.g. an empty frame once every hour or day) such that the server is aware of the best gateway. Maybe a gateway got disconnected, so another must be used. There is no point in sending uplinks every minute, because the nearby gateways don't change every minute...
To check whether a Class C downlink is available, the function getDownlinkClassC can be used. This functions checks whether a valid downlink Class C downlink is received since the last call to this function (or since the last uplink). If a downlink is available, the corresponding Rx window number is returned (always 3 for RxC). If there was no downlink, RADIOLIB_ERR_NONE is returned. It is however also very likely that another error code is returned such as RADIOLIB_ERR_DOWNLINK_MALFORMED. Since the radio is always active in Class C, it will catch spurious downlinks that are not intended for your device. But as these aren't meant for your device, they will not parse correctly.
It is recommended to execute the function getDownlinkClassC as often as possible to be sure to catch all downlinks. However, you can do intermediate processing (like sensor readings) without problem. The only risk is that if you perform something that takes a lot of time, the device may have received a new Class C downlink already, overwriting the previous one. However, you probably shouldn't be sending that many downlinks anyway!
Tip
To address multiple Class C devices at once, try Multicast!