First, if you want to know more about the HTTP protocol, I advise you to go back to the previous chapter 1
where we explain everything about the HTTP protocol itself. 2
And I'm going to use exactly the same diagram for the explanation about the HTTP integration with Chirpstack, 3
because it works exactly in the same way. 4
Actually, HTTP integration always looks similar whatever the Lorawan server used. 5
So if you're comfortable with the previous demonstration, this one should be easy. 6
We are going to use the HTTP post request to get the data from the application server. 7
So that refers to the uplink stream. 8
Then, of course we will also send some data to the end device. 9
This action refers to the downlink stream. 10
Okay. 11
First, let's talk about the uplink. 12
As usual, for this demonstration, I will send a temperature from my end device. 13
In that case, my LoRaWAN server, it's the HTTP client that pushes the data to my HTTP server. 14
And this HTTP server is my IOT platform. 15
To simulate the HTTP server, we will use the same web application we used before. 16
It's called rbaskets, but there are many others. 17
The idea is just to display the request sent by the client and in this situation the request should 18
contain the uplink data. 19
Once again, get back to the corresponding video for more details about that. 20
Okay, let's make this first demonstration for the uplink part. 21
On the left, there is our HTTP post client, which is Chirpstack. 22
And, on the right, we have our HTTP server. 23
In that case, rbaskets. 24
In Chirpstack, we need to set up the client. 25
For that we go in our application. 26
Then, we go on the integration tab. 27
We can see all integration available in Chirpstack. 28
In this demonstration we want to use the generic HTTP integration here and the configuration is really 29
easy. 30
We just need to fill in the endpoint URL where we want to pass the uplink data. 31
Endpoint is just another name for the HTTP server. 32
But first, we need to create it. 33
So, we go on rbaskets on the right window and we create a new endpoint. 34
Of course we could reuse the one we created during the TTN demonstration, but I don't want to mix up everything, 35
so, I prefer to create a new one. 36
And if you want to come back on this server later, you can save the token. 37
In my case, it's not necessary. 38
Right. 39
So now the endpoint. 40
So the HTTP server instance is ready. 41
We just need to copy the URL to the client and that's it. 42
On the left, I have a window representing my own device. 43
When I press the button, the temperature is sent, is received by the network server, application server, 44
then sent in HTTP to my server. 45
And there we go. 46
It's displayed in the log here. 47
Great. 48
So we are done with the uplink integration using HTTP. 49
Now, let's focus on the downlink. For the downlink stream, 50
I want to send data from my IoT platform to the application server. 51
In that case, our IoT platform is the client that pushes data to the HTTP server. 52
And where is this HTTP server? 53
It's Chirpstack itself, so Chirpstack will have to handle the HTTP post request. 54
And, on the other side we'll have to send the http post request with an HTTP client. 55
In the previous chapter we use Curl for our HTTP client. 56
We will use the same tool again for this demonstration, but you will see that we will use something 57
even easier. 58
So we'll start by installing the server and it's going to be extremely easy because actually it's already 59
done. 60
In fact, when we set up the HTTP integration for uplink, then a server has also been enabled. 61
This service is therefore ready and running. 62
Okay, so the only thing I need to do with this HTTP server is to handle the authentication, because 63
what I did earlier for the uplink was extremely insecure. 64
Indeed, when I configured the integration to send data to my HTTP endpoint, there was no authentication 65
at all. 66
Actually, everyone could send data to this endpoint. 67
It doesn't matter. 68
It was just a demo, but hopefully you wouldn't do that during deployment. 69
Of course, for the other way around, Chip Stack won't allow it. 70
So in the API key section I need to generate a new key. 71
So I click on Add API key, I give it a name, my key, and when the token is generated I copy it. 72
Be careful because when you press the button back then there is no way to retrieve the token anymore. 73
Okay. 74
Now, to send the right HTTP post command, then I could go and check the documentation on Chirpstack 75
website. 76
But there is an easier way because when we install Chirpstack with Docker, another service has been 77
included during the installation. 78
It's called Stack REST API. 79
So what is the REST API? 80
It's just another name for the set of HTTP requests to use to access data on the LoRaWAN server. 81
In our case, the REST API is handle on the LoRaWAN server and any client who read the REST API in the 82
documentation can send requests. 83
But the fact that the network server handles a set of HTTP command, 84
so a REST API is not something new because it exists in all LoRaWAN server. 85
However, what is nice here is that instead of digging into the documentation, there is a tool with 86
a user interface to send and try all requests. 87
This tool is called Swagger. 88
To connect to the swagger user interface. 89
We use the same role on Port 1890. 90
Here we go. 91
Here is the interactive documentation of the REST API. 92
So, all the HTTP requests we can possibly send to our server are here. 93
Of course, to use it we need to be identified, so we will need the API key we've just created. 94
So we click on the Authorize button here. We enter the word Bearer followed by the API key and click 95
again on Authorize and Close. 96
And now we have access to all requests. 97
The one we're interested in is the one which provides downlink data to our Application Server. So, we 98
can look for the keyword downlink. 99
And here at the last line of this section, there is indeed the right command to enqueue some data in 100
the LoRaWAN server downlink queue. 101
Let's try that. 102
We click on try it out and we now have access to the field required for this request. 103
The devEui and the data JSON object. 104
So I just fill the first field with the devEui I want to send data to and for the JSON object we'll 105
use the same demonstration as before. 106
We want to set the LED on on our board. 107
So for that we need to send 1 on port 15. 108
The value needs to be written in base 64, which is AQ== and the port 15. 109
We can also simplify this object because there are some fields that we don't need, but otherwise we 110
can leave it like this. 111
Great. 112
And now we click on Execute. 113
If the request is sent properly, then in return we have an identifier of the new item queued on the 114
network server. 115
We can check that on the Network Server 116
everything has been received properly. 117
So, we go on Chirpstack and in the corresponding device section there is a tab called Queue and there 118
we go. 119
We can see our downlink data waiting to be sent to the device. 120
When will it be sent? 121
When the device transmits, of course. 122
On the left, I've got one window with my end-device logs and on the right I've got one window with my 123
live data of my LoRaWAN server. 124
I press the push button on the right. 125
I can see that I've received a new uplink frame and on the left I've received the data 1 on Port 15 126
and the LED is on. 127
Everything works perfectly. 128
You can use this tool for many other requests than just signing downlinks. 129
And once you've tested it, you can even pick up the Curl command and sign it from wherever you want. 130
In my case, I can take the one I used already, 131
go on MobaXterm and send this Curl command from my terminal. 132
The result is exactly the same. 133
Great. 134
That's all for the HTTP integration with Chirpstack. 135
So now, let's try MQTT.