Important note:
Downlinks should only be used to a limited extent depending on the infrastructure. In the free version of TTN, the Fair use policy says, that no more than 10 downlinks should be made. You also have to observe the regulations within the Limit of the duty cycle limitation. That is why Downlinks are only to be carried out with caution and when absolutely necessary. The number of possible characters that can be sent is limited by the respective spreading factor (With a SF of 12 only 51 characters).
The applicable and possible downlinks depend on the device and the firmware version.
The described examples do not claim to be complete and are used at your own risk.
Example 1: Getting the firmware version:
Example to do this over TTN Console:
On your TTN Console choose your Application and your Device, Messaging:
The downlink and response can be viewed in "live data":
The result of the converted HEX to ASCII is:
Example 2: Change Configuration Pressure and Temperature Sensor via Script:
Change:
SMbCmd=0 0/10 * * * *:R,9600,8N1:010300160002,010300260002,fa0400050001
to hex:
53 4D 62 43 6D 64 3D 30 20 30 2F 31 30 20 2A 20 2A 20 2A 20 2A 3A 52 2C 39 36 30 30 2C 38 4E 31 3A 30 31 30 33 30 30 31 36 30 30 30 32 2C 30 31 30 33 30 30 32 36 30 30 30 32 2C 66 61 30 34 30 30 30 35 30 30 30 31
to base64:
U01iQ21kPTAgMC8xMCAqICogKiAqOlIsOTYwMCw4TjE6MDEwMzAwMTYwMDAyLDAxMDMwMDI2MDAwMixmYTA0MDAwNTAwMDE=
Example for TTN:
The downlink via a script via TTN would then look like this:
curl --location \ --header 'Authorization: Bearer NNSXS.XJAZK3VF3YBMXX_API_KEY_KR2HFG6ABXXXXXX.CP4WZUOXXXXXXXB5WW4UUSMNXRLUJ7LVO2U' \
--header 'Content-Type: application/json' \
--header 'User-Agent: my-integration/my-integration-version' \
--request POST \ --data '{"downlinks":[{ "frm_payload":
"U01iQ21kPTAgMC8xMCAqICogKiAqOlIsOTYwMCw4TjE6MDEwMzAwMTYwMDAyLDAxMDMwMDI2MDAwMixmYTA0MDAwNTAwMDE=",
"f_port":128 }] }' \
'https://eu1.cloud.thethings.network/api/v3/as/applications/your-ttn-applicationID/devices/eui-your_TTN_end_deviceID/down/push'
(You should use your own data for the API KEY, your-ttn-applicationID and your your_TTN_end_deviceID)
See detail TTN Documentation:
TTN Documentation scheduling-downlinks
Example for Chirpstack:
The downlink via a script via Chirpstack would then look like this:
curl -X POST --header 'Content-Type: application/json'
--header 'Accept: application/json'
--header 'Grpc-Metadata-Authorization:
Bearer xxxxxxxxx_API_KEY_xxxxxxx' -d
'{ "deviceQueueItem": { "confirmed": false, "data":
"U01iQ21kPTAgMC8xMCAqICogKiAqOlIsOTYwMCw4TjE6MDEwMzAwMTYwMDAyLDAxMDMwMDI2MDAwMixmYTA0MDAwNTAwMDE=",
"fPort": 128
} }'
'http://192.198.0.101:8080/api/devices/ChirpStack_end_deviceID/queue'
(You should use your own data for the API KEY, your Chirpstack_IP_Adress and your your_ChirpStack_end_deviceID)
See detail Chirpstack Documentation:
Be sure your number of characters matches the possibilities of your spreading factor
SF 7 = 242 Byte Max Payload, SF 12 = 51 Byte Max Payload