The preamble series is >, >, >


[Graffiti Internet of Things Footprint] Graffiti Cloud Platform standard instruction set


The open messaging platform mainly actively pushes various event data to external partners through Pulsar, so as to meet the partners’ requirements for real-time message and message persistence.

A Pulsar,

>, >, > Pulsar – Introduction to Pulsar Simply put, Pulsar, originally developed by Yahoo and now managed by the Apache Software Foundation, is a multi-tenant, high-performance server-to-server messaging solution.

Graffiti Intelligence is customized and improved based on the open source Pulsar system. Message access can be completed according to the Pulsar SDK provided by Graffiti Intelligence.

Pulsar uses a Pub/Sub (publish and subscribe) design pattern as a message broker. In this design pattern, producers publish messages to topics, and consumers can then subscribe to these topics, process incoming messages, and send an acknowledgement when the processing is complete. When a subscription is created (even if the message processing device is disconnected) all messages are retained by Pulsar. Remaining messages are discarded only after the message processing device confirms that the message was successfully processed.

In addition, a topic can be subscribed to by multiple consumers, and when the consumer successfully processes the message, it needs to send an acknowledgement to the broker so that the broker can discard the message. Graffiti Smart’s Pulsar Message Dispatcher allocates multiple partitions to each topic, and the Pulsar Message Dispatcher distributes messages based on the partitions and consumers.

II. Relevant Instructions

Security:

  • Authentication security: The Pulsar messaging system is deeply customized for identity authentication to meet high security requirements. The Pulsar messaging system adopts dynamic token mechanism to enhance security. Developers can ignore implementation details and complete authentication based on SDK provided by Pulsar Intelligence.
  • Data security:

    • Security of transmission: Doodle Intelligent Pulsar Message Push System transmits data based on SSL.
    • Business security: all business data are encrypted by AES-128, and all requests are signed.

Request method:

See the ConsumerExample code for details. The following three parts of data need to be provided when accessing:

  • Username: Access ID to fill in the API authorization key in the cloud development platform.
  • Password: Access Secret of the API authorization key in the cloud development platform.
  • URL: Select according to the region of the call.

    • China:pulsar+ssl://mqe.tuyacn.com:7285/
    • The area:pulsar+ssl://mqe.tuyaus.com:7285/
    • Europe:pulsar+ssl://mqe.tuyaeu.com:7285/
    • India area:pulsar+ssl://mqe.tuyain.com:7285/

Open mode:

  1. Log in to IoT Workbench > Cloud Development.

2. Create a project.

3. Enable the message subscription function in the message subscription module of the project.

Code example:

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();

Data format:

{"protocol": 4, "pv": "2.0", "t": In 146052438362, "data":"4FDEE3FE59FCD76E260F7115011D65C7FD2AF59BFA4DC29E5DDF3FDA6BD5447E02F679052C34BBAAB7BB0EFEED62C760FD2AF59BFA4DC29E 5DDF3FDA6BD5447EC660C816075824E004EC0123DE4FD1B638BB633A478EB2C2004EF4289276****", "sign": "58285279b5b5790c7d917de88b3e****" }

Data signature:

Before getting the actual DATA data, you can set tamper-proof MD5 signature verification. The execution steps of the signature algorithm are as follows:

  1. Format each parameter in the JSON format you receive (except for sign and null values) as key=val.
  2. Assemble (using Key Ascending). After assembly of string format example: k1 = v1 | | k2 = v2.
  3. Add the key. For example: k1 = v1 | | k2 = v2… Kn =.vn | | key.
  4. Performs the MD5 signature of the entire string.
  5. If the MD5 value matches the sign of the received data, the data has not been tampered with. Otherwise it is deemed to have been tampered with.

After the signature verification is passed, the data is decrypted:

  1. The data is Base64 decoded first.
  2. The middle 16-bit code of the accessKey is decrypted through AES (ECB mode) to get the real device state data.

The data format after decryption is as follows:

{ "devId": "002dj00118fe34d9****", "productKey": "Developer platform defines the product Key corresponding to the product ", "dataId":"1459168450ddfdfoiopiopi****",// global unique ID, data submission unique ID "status": [ { "code":"switch", "value":false, "mode":"rw", "t":146052438362 }, { "code":"work_mode", "value":"colour", "mode":"rw", "t":146052438362 } ] }

III. Business data

Agreement no. :

Protocol numbers (different protocol numbers represent different functions).

Equipment data reporting events:

{"devId": "002dj00118fe34d9****", "productKey": "productKey defined by developer platform ", "dataId": "1459168450ddfdfoiopiopi****", "status": [{" data point code 1 (the corresponding data point code at the time of product definition) ": "data point corresponding value ", "t": 1540615024283 // Data point state occurrence time}, {" Data point code 2(the data point code corresponding to the product definition) ": "Data point corresponding value ", "t": 1540615024283 // Data point state occurrence time}]}

Other events:

  • Equipment on-line:

BizData instructions

The data sample

{"devId": "002dj00118fe34d9****", "productKey": "developer platform defines productKey", "bizCode": "online", "bizData": {"time": 146052438362}}
  • Offline device:

BizData instructions

The data sample

{"devId": "002dj00118fe34d9****", "productKey": "productKey defined by developer platform ", "bizCode": "offline", "bizData": {"time": 146052438362}}
  • Device name change

BizData instructions

The data sample

{"devId": "002dj00118fe34d9****", "productKey": "developer platform defined productKey", "bizCode": "nameUpdate", "bizData": {"devId": "002dj00118fe34d9****", "name": "new name" } }
  • Device DP name changed

BizData instructions

The data sample

{"devId": "002dj00118fe34d9****", "productKey": "developer platform defined productKey", "bizCode": "dpNameUpdate", "bizData": {"devId": "productKey":" developer platform defined productKey", "bizCode": "dpNameUpdate", "bizData": {"devId": "002dj00118fe34d9****", "name": "new name", "dpId": "dpId" } }
  • Equipment binding

BizData instructions

The data sample

{"devId": "002dj00118fe34d9****", "productKey": "developer platform defines productKey", "bizCode": "bindUser", "bizData": {"devId": "002dj00118fe34d9****", "uuid": "06200043b4e618c1****", "uid":"ay1529485403390****", "token": "IIpQ****" } }
  • Equipment to remove

BizData instructions

The data sample

{"devId": "002dj00118fe34d9****", "productKey": "developer platform defined productKey", "bizCode": "delete", "bizData": {"devId": "002dj00118fe34d9 ": "productKey"; "002dj00118fe34d9****", "uid":"ay1529485403390S****" } }
  • Equipment Upgrade Status

BizData instructions

The data sample

{ "bizCode":"upgradeStatus", "bizData": {"devId":"6ca8756d*****1b4ewsdn", "moduleType":0, "upgradeStatus":2, "description":" upgrade test ", "oldVersion": "1.0.1," "newVersion" : "1.0.2"}, "devId" : "6 ca8756d b4ewsdn * * * * * 1", "productKey" : "vFHpaEFwu8UD * * * *", "ts" : 1562232522192}