Last Updated on : 2024-06-20 07:20:05download
The Smart Business Platform actively pushes event data to external partners through Pulsar, which meets their demands for real-time and persistent messages.
Note:If you need to use the device message subscription, you should develop the client through the OEM App or App SDK. Devices that use the Light+Space App to pair the network do not support push messages to developers at present.
Pulsar is a multi-tenant, high-performance solution for server-to-server messaging. Pulsar was originally developed by Yahoo and now is under the stewardship of the Apache Software Foundation. Tuya Smart Message Service is customized and built based on Apache Pulsar. Message Service integration can be achieved by the Pulsar SDK.
As a message broker, Pulsar is built on the Pub/Sub pattern. In this pattern, producers publish messages to topics. Consumers subscribe to those topics, process incoming messages, and send an acknowledgment when processing is completed.
When a subscription is created, Pulsar retains all messages, even if the consumer is disconnected. Retained messages are discarded only when a consumer acknowledges that those messages are processed successfully.
Moreover, multiple consumers can subscribe to one topic. When messages are processed successfully, consumers need to send acknowledgments, so brokers can discard these messages. The Pulsar brokers provided by Tuya Smart allocate multiple partitions for each topic. Pulsar brokers send messages according to partitions and consumers.
Authentication security:
Tuya Smart Pulsar Message Service adopts a highly customized authentication algorithm and dynamic tokens to safeguard your operation. You can skip the implementation details and accomplish the authentication based on the provided SDK.
Data security:
Transmission security: Tuya Smart Pulsar Message Service transmits data based on the SSL.
Business security: Business data is encrypted with AES-128 and attached with a signature.
You can submit your account and clientId (accessId) to the technical support of the Smart Business Platform to subscribe to messages.
For more information, see ConsumerExample. The following data must be provided:
String url = "";
String accessId = "";
String accessKey = "";
MqConsumer mqConsumer = MqConsumer.build()
.serviceUrl(url)
.accessId(accessId)
.accessKey(accessKey)
.maxRedeliverCount(3)
.messageListener(new MqConsumer.IMessageListener() {
@Override
public void onMessageArrived(Message message) throws Exception {
// Write your own message processing logic
}
});
mqConsumer.start();
Before you get the real data
, you can set the tamper-proof MD5 signature verification. The signature algorithm is processed as below:
sign
and the parameters with an empty value) into key=val
.key
in ascending order. Format example of the assembled string: k1=v1||k2=v2
.k1=v1||k2=v2...kn=vn||key
.sign
value, it means the data has not been tampered with. Otherwise, the data has been tampered with.The data is decoded after the signature is checked.
accessKey
through the AES (ECB mode) to get the real device status data.Name | Type | Description |
---|---|---|
encryptPayload | String | Ciphertext |
sign | String | The signature that is generated by a specified signature algorithm |
encryptType | String | Encryption type |
t | Long | A 13-bit standard timestamp |
v | String | Version number |
{
"encryptType": "aes_ecb",
"v": "1.0",
"t": 1588918073598,
"encryptPayload":"4FDEE3FE59FCD76E260******33A478EB2C2004EF4289276****",
"sign": "4b7084b3b87b550c0d967f7736e9****"
}
Name | Type | Description |
---|---|---|
bizCode | String | Service type |
eventType | String | Event type |
data | JSON | Message data |
Description of service type
bizCode | Description |
---|---|
device | Push device events |
voice | Push voice-enabled services |
construction | Push construction services |
{
"bizCode": "device",
"eventType": "dp_report",
"data": {}
}
eventType | Description |
---|---|
bind | Bind a device |
unbind | Unbind a device |
reset | Reset a device |
online | Go online |
offline | Go offline |
dp_report | Report the device status |
name_update | Change the device name |
{
"data":{
"devId":"02200434dc4f221axxxx",
"deviceName":"****socket****(wifi)_0",
"gwId":"",
"location":{
"child":{
"id":"1256152666585710592",
"name":"****room where the test is carried out****"
},
"id":"1256148753241358336",
"name":""
},
"namespace":"BgdBXzUhIg5x77770LL1OfpDxxxxx",
"ownerId":"139960xx",
"position":"****study room****",
"productId":"qCY4YFq02AP0i1xx",
"sub":false,
"uid":"bay1588324079695kFxx",
"uuid":"02200434dc4f221a6xxx"
},
"bizCode":"device",
"eventType":"bind"
}
{
"data":{
"devId":"02200434dc4f221xxxxx",
"namespace":"****Your****namespace"
},
"bizCode":"device",
"eventType":"unbind"
}
{
"data":{
"devId":"02200434dc4f221xxxxx",
"namespace":"****Your****namespace"
},
"bizCode":"device",
"eventType":"reset"
}
{
"data":{
"devId":"02200434dc4f221axxxx",
"namespace":"****Your****namespace",
"time":1589019224062
},
"bizCode":"device",
"eventType":"online"
}
{
"data":{
"devId":"02200434dc4f221a6120",
"namespace":"****Your****namespace",
"time":1589019224062
},
"bizCode":"device",
"eventType":"offline"
}
{
"data":{
"devId": "002dj00118fe34xxxxx",
"productId": "The product ID defined on the Tuya Developer Platform",
"dataId": "145xxxxxxxxxxxxxxxxxxx",// The global unique ID, indicating the reporting of single data
"namespace":"Your namespace",
"status": [
{
"code": "switch_1",
"value": "true",
"time": 1589767589137
}
]
},
"bizCode":"device",
"eventType":"dp_report"
}
{
"data":{
"devId":"02200434dc4f221axxxx",
"deviceName":"****socket****",
"namespace":"****Your****namespace"
},
"bizCode":"device",
"eventType":"name_update"
}
eventType | Description |
---|---|
voice_nlu | Push the speech recognition result |
voice_room_bind | Push the binding result of a speaker and a room |
{
"data":{
"devId":"6cd40b4ed084ac264bmcvu",
"namespace":"BgdBXzUhIg5x77770LL1OfpDwXj6b",
"nlu":"[{\"entities\":[{\"value\":\"TV\",\"entity\":\"deviceName\"}], \"domain\":\"mediaControl\",\"confidence\":1,\"text\":\"Pause the TV\",\"intent\":\"pause\"}]",
"productId":"fabzep46",
"uid":"bay1588324079695kF7G",
"uuid":"f572ecc09e19d8c1"
},
"bizCode":"voice",
"eventType":"voice_nlu"
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback