📜 ⬆️ ⬇️

IOTV - a simple HTTP protocol for working with messages and commands of IOT objects in the VIALATM service



Several developers using the VIALATM service for working with IOT objects have asked me to implement a simple http protocol. Previously, they used the MQTT protocol, but for some reason they needed a simpler solution. The protocol is implemented. This article has a brief description of it.

Port 7746 is reserved for support of the IOTV port in service (for work on the https protocol, the port should be used - 7745).

HTTP header


All requests via the IOTV protocol must contain the attribute “iotv-user” in the header (http header). If in the account settings “IOTV password” is set, the attribute “iotv-password” in the header should match this value, otherwise it can be omitted.
')


Required attribute


All requests must contain a mandatory attribute "root".



Optional Attributes


The “time” attribute can be added to requests. It must be installed in UNIX STAMP format (the number of seconds from January 1, 1970). If this attribute is omitted, the time of the event is considered the time of the request to the server. All other possible attributes depend on how the IOT object is defined in the service. The current values ​​of all object attributes are returned in response to the request.

Examples


Get
Request: vialatm.com : 7746 /? Root = HOME & A1 = 5 & B1 = 12
Response: A1 = 5 & B1 = 12 & C1 = 14

POST
Request: vialatm.com : 7746 /

Json
Data: {"A1": "12", "root": "HOME", "B1": "44"}
Response: {"A1": "12", "B1": "44", "C2": "12"}
XML
Data: <req> <A1> 73 </ A1> <root> HOME </ root> <B1> 87 </ B1> </ req>
Response: <resp> <A1> 73 </ A1> <B1> 87 </ B1> <D1> 88 </ D1> </ resp>
POST FORM
Data: A1 = 543 & root = HOME & B1 = 12 &
Response: command = 12.4 & A1 = 543 & B1 = 12 & C1 = 14

Commands in response to requests


For IOT objects, you can define commands



In this case, when a command for an object is specified, it is sent in response to an IOTV request:



Examples of responses to requests in these cases:

Get
Request: vialatm.com : 7746 /? Root = HOME & A1 = 5 & B1 = 12
Response: command = 12.4 & A1 = 5 & B1 = 12 & C1 = 14

POST
Request: vialatm.com : 7746 /

Json
Data: {"A1": "12", "root": "HOME", "B1": "44"}
Response: {"command": "12.4", "A1": "12", "B1": "44", "C2": "12"}
XML
Data: <req> <A1> 73 </ A1> <root> HOME </ root> <B1> 87 </ B1> </ req>
Response: <resp> <command> 12.4 </ command> <A1> 73 </ A1> <B1> 87 </ B1> <D1> 88 </ D1> </ resp>
POST FORM
Data: A1 = 543 & root = HOME & B1 = 12 &
Response: command = 12.4 & A1 = 543 & B1 = 12 & C1 = 14

Source: https://habr.com/ru/post/335468/


All Articles