Sending a Request
The message or command is sent to the agrirouter using a protocol dependent request to its agrirouter inbox.
General Prerequisites
Using MQTT
The endpoint address of the MQTT broker is delivered as host+port in the onboarding request. The inbox is the topic delivered with the "measures" attribute of the onboarding request.
To send a message, publish it. (Here, publish means the MQTT-Term, see https://mqtt.org)
In general, the hosts should be as follows:
Area | Environment | URL |
---|---|---|
EU |
Quality Assurance |
|
EU |
Productive |
Using REST
Using REST, the message is sent as a single HTTP call using HTTPs and the endpoint certificates delivered with the onboarding Request.
Address
To send messages to the agrirouter, the app has to perform a POST request sending a message included in a Request.
Messages and commands are sent to the inbox. The address of the inbox is returned with the onboarding request ("measures") and should look like this:
Method | Address |
---|---|
POST |
/iot/gateway/rest/measures/{{deviceAlternateId}} |
Header
As the communication works via https, the SSL Certificate information delivered with the onboarding Result is needed.
In most communication libraries, the developer just has to provide
-
the certificate, which is the public key,
-
the SSLKey, which is the private key
-
the password for the private key
Most libraries are than able to handle the communication.
For further information see the curl documentation on the parameters used for a communication. For curl_easy_setopt(:
-
CURLOPT_SSLKEY
-
CURLOPT_KEYPASSWD
-
CURLOPT_SSLCERT
The header of the HTTP Request for the REST implementation also requires
Content-Type: "application/json"
or
Content-Type: "application/x-protobuf"
Regardless which Content-Type you use, make sure that your implementation includes "application/json" in the "accept"-Parameter of the HTTP Call. The Inbox of agrirouter is not able to return protobuf and will return a status of 4xx if it can’t find json in the accepted responses. |