We take the same diagram we saw before, and we'll now focus on the downlink stream. 1
The IoT platform will transmit an HTTP POST request to the LoRaWAN server, and in this request there 2
will be the downlink message to send to the device. 3
So we're going to install a client that is able to transmit these HTTP POST request. 4
Once again, we'll simply use a terminal with a curl command because we saw earlier that Curl can send 5
any HTTP request. 6
After that, we need to install an HTTP server on the LoRaWAN server. 7
It should be able to handle the HTTP POST request sent by the IoT platform. 8
So we'll start by installing the server. 9
It's going to be extremely easy because actually it's already done. 10
In fact, when we set up the webhook for the uplink, then a server has also been enabled. 11
This service is therefore ready and running. 12
So, when we created the webhook, we enabled both an HTTP client and an HTTP server. 13
So the only thing I need to do with this webhook is to handle the authentication, because what we 14
did earlier for the uplink was extremely insecure. 15
Indeed, when I configure the webhook to send data to my HTTP endpoint. 16
There was no authentication at all. 17
Actually, everyone could have sent data to this endpoint. 18
It doesn't matter. 19
It was just a demo and hopefully you wouldn't do that for a deployment. 20
But of course for the other way around. 21
TTN won't allow it. 22
So in the API Key section, I need to generate a new key. 23
If you watch the previous video, then you know that I've done it already for the HTTP GET request and 24
if you've properly saved the key you can reuse it. 25
Otherwise you just need to create a new one here. 26
In my case, I'm going to use the one I had already. 27
Now to send the right HTTP POST command, then I need to check the documentation. 28
So we go back on the things stack website, and in the search bar we could look for HTTP POST request 29
and do exactly the same journey we've had when we dealt with the HTTP GET request. 30
At the end, we ended up in the storage integration section because that was the name of the integration 31
we used. 32
So let's save time and look for the webhook integration directly, because this time we're dealing with 33
web integration. 34
And in the Webhook tab, there is a schedule downlink section where everything is explained in 35
detail. 36
We've done the API Key creation already, so fine, we can carry on. 37
And at the bottom there is a template of the curl command to complete. 38
In this command we'll have to modify the API Key for the authentication. 39
"app1" should be replaced by the application name, "wh1" replaced by the webhook name "dev1" replaced 40
by the device name. 41
And finally the server address should be replaced by TTN community server address. 42
That's the one we're using in this demo. 43
Okay, I copy this command and I will edit it. 44
- I modify the API key I generated earlier. 45
- I modify the message. 46
In my case, I want to send 0 or 1 in my application. 47
0 or 1 represent an LED status. 48
But of course you can imagine whatever you want. 49
The only thing is that it has to be written in 64 base format. 50
For this demonstration, I give you the value: 51
If you want to send 0 , it's "AA==". 52
And if you want to switch on the LED, then you need to send 1 which is "AQ==". 53
- I modify the Application port in my application it should be 15 to control the LED. 54
But again, you can choose whatever you want for your other application. 55
- The server is the things network, 56
the application ID is training-usmb. 57
The webhook ID is webhook-http, 58
and finally, my device ID is deviceA-abp. 59
I copy this command and I will send it from my terminal. 60
I've got one window representing my device on the left and one window representing my IoT platform on 61
the right. 62
This is where I'm going to send my curl command. 63
Once this command will be sent, then I will go and check what's going on on my network server as well. 64
So the data transmission path is: 1. The IoT platform where it starts, 2. The application server, 65
3. The network server. 66
4. My gateway, and 67
finally, my enddevice, here. I send the curl command. 68
Now the downlink is scheduled, 69
so when my enddevice will send a new uplink frame to the server, then this message will be sent. 70
So I press the button to send an uplink frame. 71
And there we go. 72
We have received our command on the device. 73
In my case, when the command is properly received, an LED turns OFF. 74
But obviously you can take any action depending on your application.