Report the Measure Processing Results (Protobuf)
The IoT Gateway reports the processing results for the posted measures to the device using the REST API. The general outcome is reported as the status code returned for the corresponding HTTP request. The details including the error messages are returned in the body of the HTTP response which has the same content type as the request: if the measures are posted in the Google Protocol Buffers format, the detailed processing results are also returned in protobuf. If the measures are posted in the JSON format, the results are returned in JSON. For more information, please refer to section Report the Measure Processing Results (JSON).
Note that the IoT Gateway reports the processing status immediately, before forwarding the measures to the Device Connectivity. If the IoT Gateway considers the measure message invalid and rejects it, this outcome is final. However, if the IoT Gateway accepts the measure message as valid, it may still be rejected or lost further down the road. Thus, the IoT Gateway typically does not return the 200 OK status code, but only 202 Accepted. The REST API will be extended in future releases of the gateway, allowing HTTP clients to query the final processing outcome of measure messages posted earlier, including the processing by the Device Connectivity.
HTTP Status Codes
The device must be able to handle at least the status codes described in the following table. This list is not exhaustive. Future versions of the IoT Gateway may return additional status codes.
|
Status code |
Meaning |
|---|---|
|
200 OK |
The IoT Gateway has received a confirmation from Device Connectivity that the measure message was processed correctly before returning the result to the device. Almost never occurs. |
|
202 Accepted |
The measure message has passed the validation check executed by the IoT Gateway. |
|
207 Multi-Status |
Batched Measure Messages were posted to the IoT Gateway. Some messages in the batch have failed the validation, but at least one was accepted. The body of the response contains detailed information. |
|
400 Bad Request |
The measure message has failed the validation check executed by the IoT Gateway. If the message posted is a batched message, all message parts have failed the validation check. All measures were discarded. The body of the response contains detailed information. |
|
401 Unauthorized |
Authentication has failed, or the authenticated device is not authorized to post measures on behalf of the device with the alternate ID specified in the URL. |
|
404 Not Found |
The requested URL refers to a non-existent REST endpoint. |
|
405 Method Not Allowed |
Only HTTP POST can be used for sending the measures. |
|
500 Internal Server Error |
The IoT Gateway is not configured correctly, or a software error has occurred in the IoT Gateway. |
|
504 Gateway Timeout |
This error is not returned by the IoT Gateway itself, but rather by an HTTP proxy or reverse proxy located between the device and the IoT Gateway. The most likely reason is that the IoT Gateway is overloaded with requests, or that the measure message posted is very large and takes too long to process. |
Response Body
When the device posts measures in the protobuf format, it receives a detailed status response which is also in the protobuf format. The device must check the Content-Type HTTP header because a different content type may be returned by an HTTP proxy, or no response body at all may be returned in some cases.
The definition of the corresponding type in the proto3 syntax is provided in the following sample. All fields are optional. More fields can be added in future versions of the IoT Gateway.
message MeasureResponse {
int32 code = 1; // the same as the HTTP status code
string id = 2; // not returned by the current version
int64 timestamp = 3; // not returned by the current version
string sensorAlternateId = 4; // value from the request
string capabilityAlternateId = 5; // value from the request
repeated string messages = 6; // a list of human-readable strings,
// mostly error messages, generated during
// the verification of the measure message
}
The current version of the IoT Gateway does not support the protobuf format for batched measure messages. Therefore, neither individual identifiers nor individual timestamps for measure messages are needed.
The messages field can contain any human-readable error messages. There is no fixed list of allowed values, but the messages may start with the strings listed in the following table.
Typical error messages are described in the following table.
|
Message |
Condition |
|---|---|
|
Unauthorized |
The client is not authorized to post the measure messages on behalf of the device. In particular, this may mean an HTTP authentication failure. |
|
Invalid device alternate ID |
Most likely to appear when a valid and authenticated router device posts measure messages on behalf of another one. |
|
Invalid message format |
This means that the whole payload could not be parsed, for example due to invalid JSON syntax. The sensor and device alternate IDs, etc., cannot be extracted in this case. |
|
Invalid sensor alternate ID |
The sensor does not exist and could not be onboarded automatically. |
|
Invalid capability alternate ID |
The capability does not exist for the sensor, or it does not accept measures (being of the command type). |
|
Invalid property alternate ID |
The property does not exist in the capability. |
|
Illegal property value |
The value is not acceptable for the reason specified in the same error message. The message can be used if the measure is posted as a list with a wrong number of elements. It can also be used when the value for a certain property cannot be converted to the corresponding type. |
|
No valid measurement data found |
No property of the capability was assigned a valid value. |
|
Illegal time stamp value |
The time stamp provided by the client for the measure message could not be parsed. |
|
Gateway configuration error |
Typically returned for a wrongly configured IoT Gateway Edge. However, it may also be sent if there are errors in the data model, such as a capability without any properties. |
|
Gateway internal error |
Some other error was detected, and an internal consistency check has failed in the IoT Gateway. |