JetLinks Things underlying platform - the official protocol

JetLinks official agreement

In addition to using protocols other than Custom, jetlinks provides a default protocol support.
When the device can use this protocol access platform. Device protocols have been defined and can not be modified protocol, it is recommended to use a custom protocol access

MQTT access

MQTT3.1.1 and currently supports version 3.1 protocol.

Authenticate

CONNECT message:

clientId: 设备实例ID
username: secureId+"|"+timestamp
password: md5(secureId+"|"+timestamp+"|"+secureKey)

Description: secureIdand secureKeyperformed during the creation of the device and the device instance products.
timestampCurrent system time stamp (ms), and the system time is not a difference of 5 minutes.

Reading device properties

topic: /{productId}/{deviceId}/properties/read

direction: 下行

Message format:

{
"messageId":"消息ID",
"deviceId":"设备ID",
"properties":["sn","model"] //要读取到属性列表
}

Reply to Topic: /{productId}/{deviceId}/properties/read/reply

Reply message format:

//成功
{
    "messageId":"与下行消息中的messageId相同",
    "properties":{"sn":"test","model":"test"}, //key与设备模型中定义的属性id一致
    "deviceId":"设备ID",
    "success":true,
}
//失败. 下同
{
    "messageId":"与下行消息中的messageId相同",
    "success":false,
    "code":"error_code",
    "message":"失败原因"
}

Modify device properties:

topic: /{productId}/{deviceId}/properties/write

direction: 下行

Message format:

{
"messageId":"消息ID",
"deviceId":"设备ID",
"properties":{"color":"red"} //要设置的属性
}

Reply to Topic: /{productId}/{deviceId}/properties/wirte/reply

direction: 上行

Reply message format:

{
"messageId":"与下行消息中的messageId相同",
"properties":{"color":"red"}, //设置成功后的属性,可不返回
"success":true,
}

Device Properties report

topic: /{productId}/{deviceId}/properties/report

direction: 上行

Message format:

{
"messageId":"随机消息ID",
"properties":{"temp":36.8} //上报数据
}

Calls the device function

topic: /{productId}/{deviceId}/function/invoke

direction: 下行

Message format:

{
"messageId":"消息ID",
"deviceId":"设备ID",
"function":"playVoice",//功能ID
"inputs":[{"name":"text","value":"播放声音"}] //参数
}

Reply to Topic: /{productId}/{deviceId}/function/invoke/reply

direction: 上行

Message format:

{
"messageId":"与下行消息中的messageId相同",
"output":"success", //返回执行结果
"success":true,
}

Equipment event reporting

topic: /{productId}/{deviceId}/event/{eventId}

direction: 上行

Message format:

{
"messageId":"随机消息ID",
"data":100 //上报数据
}

Child Device Registration

And sub-device message in conjunction to achieve equipment and the gateway device automatically bound.

topic: /{productId}/{deviceId}/child/{childDeviceId}/register

direction: 上行

Message format:

{
"messageId":"随机消息ID",
"deviceId":"子设备ID"
}

Sub-equipment write-off

And sub-device message used in conjunction with a device implementing the gateway device automatically unbind.

topic: /{productId}/{deviceId}/child/{childDeviceId}/unregister

direction: 上行

Message format:

{
"messageId":"随机消息ID",
"deviceId":"子设备ID"
}

On-line sub-device

And sub-device message in conjunction to achieve the gateway device associated with the sub-line. (Default gateway line, the child device will be fully automated on-line.)

topic: /{productId}/{deviceId}/child/{childDeviceId}/connected

direction: 上行

Message format:

{
"messageId":"随机消息ID",
"timestamp":1584331469964//时间戳
}

Child device is offline

And sub-device message in conjunction to achieve sub-associated gateway device is offline. (Default gateway offline, all the sub-device will automatically off.)

topic: /{productId}/{deviceId}/child/{childDeviceId}/disconnected

direction: 上行

Message format:

{
"messageId":"随机消息ID",
"timestamp":1584331469964//时间戳
}

Sub-device messages

topic: /{productId}/{deviceId}/child/{childDeviceId}/{topic}

Direction: 上行或下行The {topic} decision.

tip {topic} and a data format consistent with the device as defined topic: acquiring attribute child device: /1/d1/child/c1/properties/read

CoAP access

Using the CoAP access only needs to encrypt the data encryption algorithms:. AES / ECB / PKCS5Padding.

Use Custom Option: 2100:设备IDto identify the device.

The body of the request is encrypted, the key is configured in the creation of products and equipment device instance ( secureKey).

Request address ( URI) MQTT the Topicsame as the message body ( payload) with the same MQTT (only uplink message).

DTLS access

Need to be authenticated when using CoAP DTLS protocol access:

Sends an authentication request:

POST /auth
Accept: application/json
Content-Format: application/json
2100: 设备ID
2110: 签名 md5(payload+secureKey)
payload: {"timestamp":"时间戳"}

In response to the results:

2.05 (Content)
payload: {"token":"令牌"}

After the request needs to be returned to the token carries custom Option: 2111

E.g:

POST /test/device1/event/fire_alarm
2100: 设备ID
2111: 令牌
...其他Option
payload: json数据
Released seven original articles · won praise 7 · views 5794

Guess you like

Origin blog.csdn.net/qq_36598097/article/details/105073217