-
Notifications
You must be signed in to change notification settings - Fork 476
LoRaWAN: multicast
Note
RadioLib currently supports Multicast over Class C, not over Class B. Remote Multicast Setup (TS005) is not implemented, but this can be done by the user through the application layer. If you do so, please share this in the Discussions or open a Pull Request. We hope to support this in the future from within RadioLib.
As the device implementation does not depend on the network server, this is discussed first.
To start a multicast session, the function startMulticastSession()
can be used. This requires a DevAddr, AppSKey and NwkSKey. By default, it uses Rx2 for the multicast downlinks and it allows the full FCnt range. However, these can all be customized e.g. as expected by TS005.
To receive multicast downlinks, the same method can be used as described for Class C.
Tip
Multicast over Class C and Unicast over Class C can be active simultaneously. To discern whether a Class C downlink belongs to the Unicast or Multicast session, a field multicast
is available in the downlink event struct.
To setup a Multicast group on The Things Stack (Sandbox), commonly known as TTN, you can use the console and set the activation type to "Define multicast group (ABP & Multicast)". Then, you can fill in the address and keys. The DevEUI can be left empty, as this is a virtual device, not a physical one. To change the downlink frequency and datarate of the multicast group, you can configure the Rx2 details after adding your device. These Rx2 parameters are used for the multicast downlinks. According to the docs, you must then also reset the MAC state of the device.
Alternatively, use the CLI with the following commands (make sure to fill in the IDs, address and keys, and possibly alter other parameters):
$APP_ID="your-application-id"
$DEVICE_ID="new-device-id"
$FREQUENCY_PLAN="EU_863_870_TTN"
$LORAWAN_VERSION="MAC_V1_0_4"
$LORAWAN_PHY_VERSION="RP002_V1_0_4"
$MULTICAST_GROUP_ADDRESS="260B-add-4-more-hex-digits-here"
$MULTICAST_SESSION_DATARATE="DATA_RATE_3"
$MULTICAST_SESSION_FREQUENCY="869525000"
$MULTICAST_APP_SESSION_KEY="insert-32-hex-digits-here"
$MULTICAST_NWK_SESSION_KEY="insert-32-hex-digits-here"
ttn-lw-cli end-devices create $APP_ID $DEVICE_ID \
--frequency-plan-id $FREQUENCY_PLAN \
--lorawan-version $LORAWAN_VERSION \
--lorawan-phy-version $LORAWAN_PHY_VERSION \
--session.dev-addr $MULTICAST_GROUP_ADDRESS \
--session.keys.app-s-key.key $MULTICAST_APP_SESSION_KEY \
--session.keys.nwk-s-key.key $MULTICAST_NWK_SESSION_KEY \
--multicast \
--mac-settings.rx2-data-rate-index $MULTICAST_SESSION_DATARATE \
--mac-settings.rx2-frequency $MULTICAST_SESSION_FREQUENCY \
--supports-class-c
To schedule multicast downlinks, you cannot use the console. Since multicast groups don't support uplinks, the server does not know which gateway to use for the downlinks transmission, and the console has no way of specifying this. As such, scheduling a downlink using the console will generate an error. Instead, you must use the MQTT integration or a custom webhook. From experience, MQTT is the easiest way to get going:
- Use the Postman app or install an MQTT client on your device.
- Set your MQTT client to v3.1 (or v3.1.1) and point it to the host mqtt://eu1.cloud.thethings.network:1883
- Configure MQTT through the Application's "Other integrations", and get the username and password. Do not share your password, but do save it somewhere safe! (You can always regenerate it, but this action will invalidate the previous password.)
- Configure MQTT Basic Auth using the username and password from the previous step.
- Then publish to topic
v3/{mqtt-username}/devices/{multicast-device-id}/down/replace
(fill in your username and device id):
{
"downlinks" : [
{
"class_b_c" : {
"gateways" : [
{
"gateway_ids" : {
"gateway_id" : "your-ttn-gateway-id"
}
}
]
},
"f_port" : 42,
"frm_payload" : "zncVcA==",
"priority" : "NORMAL"
}
]
}
Note that the frm_payload
is base64-encoded; this example yields a hex-payload CE771570
. You can of course also change the f_port
value.
Refer to the TTS documentation for additional details such as time-synchronized downlink transmission.
You can use the console to setup a Multicast group. Head to your application and open the Multicast tab. Here, you can fill in all the details such as address, keys and Rx2 frequency. Make sure the group type is configured to Class C (default).
To be added...