Device read and write operations

Read devices

Command sent as unicast to the gateway udp 9898 port.

  • User can query status of wall switch, smartplug, the gateway returns all the device information: {"cmd":"read","sid":"158d0000123456"}

  • gatway replys using unicast and format: {"cmd":"read_ack","model":"ctrl_neutral2","sid":"158d0000123456","short_id":4343,"data":"{\"channel_0\":\"on\",\"channel_1\":\"off\"}"}

Write devices (send command to switches)

Command sent as unicast to the gateway udp 9898 port. when user need to control switches or plugs, use the write command.

{"cmd":"write","model":"ctrl_neutral1","sid":"158d0000123456","short_id":4343,"data":"{\"channel_0\":\"on\",\"key\":\"3EB43E37C20AFF4C5872CC0D04D81314\"}" }

gateway replys with unicast: {"cmd":"write_ack","model":"ctrl_neutral2","sid":"158d0000123456","short_id":4343,"data":"{\"channel_0\":\"on\",\"channel_1\":\"off\"}"}

This write_ack only represent the gateway recived the write command, the stuatus in "data" is the lastest status of the devices, NOT the status after receiving the write command. The final status will report as a status report.

Attention

The "key" is a 32-byte length string. When the encription mode is active in the gateway, it will verify the legitimacy of the write command using the "key". The rule of genarate the "key" is: after user recived 16-byte "token" from "heartbeat", encrypt this string use AES-CBC to generate a 16-byte ciphertext and then converted to 32 bytes of ASCII code string.

For example: user configured 16-byte key "0987654321qwerty" and "token" is "1234567890abcdef", the ciphertext is 0x3E,0xB4,0x3E,0x37,0xC2,0x0A,0xFF,0x4C,0x58,0x72,0xCC,0x0D,0x04,0xD8,0x13,0x14。the ”key” is:”3EB43E37C20AFF4C5872CC0D04D81314”。

results matching ""

    No results matching ""