Device Request Handler
Device Requests are introduced in Device Communication. These are the requests devices make to your application to either report sensor readings or request information.
They are delivered as an HTTP POST to the URL specified in your Request Handler.

Example of a configured Request Handler in the Console
When Blecon sends a device request to your handler, it delivers a JSON document.
A device request JSON document follows the following format:
Network Headers
The
network_headers
section contains metadata about the device and the network used. Field | Function |
---|---|
message_type | Type of message, for example, DEVICE_REQUEST |
account_id | The account is the mechanism used on Blecon for multi-tenancy. Devices and Networks belong to an Account |
network_id | The ID of the network used |
device_id | The unique ID of the device |
device_location | Location of the device as reported by the nearest Access Point |
device_model_id |
Request Data
Read on for a look at the request data format.
When a device model or product is registered with Blecon, Blecon translates the request from the device into a more easily used format.
The
device_model_id
field indicates how the requesting device was recognised. {
"network_headers": {
"message_type": "DEVICE_REQUEST",
"account_id": "2AKvnTJlm4mtAORqiVobHXBV0Fb",
"network_id": "2AKwJ5REoRZj1h3UsyPpgwI5EyK",
"device_id": "81eee9a9-fe29-4df7-9b4a-e40b6ac22fe4",
"device_location": "52.12519110941635,0.16142776655171814",
"device_model_id: "0"
},
"request_data": {
"payload": "48656c6c6f20426c65636f6e21"
}
}
As you can see, the
device_model_id
is 0 and request_data
contains a payload
field which is the raw bytes from the device in hexadecimal form. This will be what you see from the Blecon modem when building a device and before setting the device model.{
"network_headers": {
"message_type": "DEVICE_REQUEST",
"account_id": "2AKvnTJlm4mtAORqiVobHXBV0Fb",
"network_id": "2Ac2cxOUwOa4B617S6C17EY51ye",
"device_id": "7a510527-1a61-4c3c-81e5-fec0d729cb6b",
"device_location": "52.20893764406008,0.09002334854893419",
"device_model_id": "00010001"
},
"request_data": {
"uptime": 501176,
"records": [
{
"id": 1825,
"timestamp": "2022-06-20T09:28:55.916044",
"event_type": "MOTION"
}
],
"battery_mv": 4178,
"battery_condition": "NORMAL"
}
}
In the above example from the KKM Accelerometer, the raw device data has been translated to an easy-to-use JSON format.
Contact us to discuss adding translation for your device.
The response to a Device Request must always be valid JSON with content-type
application/json
and status code 200 OK.
For the specific JSON to return, refer to the individual device getting started guides.
It is good security practice to authenticate requests. To do this, set up your API so it requires an API key in a header. You can then provide that API key when you configure your Handler in the Blecon Console.

Example API key
Last modified 5mo ago