1.1. Overview
Network connection protocol for smart home gateway connection, control smart home
1.2. Usage scenarios
Smart home manufacturers hope to achieve local home control through the method of network protocols
1.3. Access Instructions
After confirming the method for connection, you need to download an APK and install it on the Xiao Ke host to connect via the document protocol.Click here to download the APK plugin After downloading the APK, you can connect the screen and computer with a USB cable, install it using the adb command, or copy it to the screen's storage. Go to the screen's desktop, select "Other Apps" - "File Manager" to find jdxy.apk and click to install.
2. Shenzhen Judian Interactive Technology Co., Ltd.
2.1. Smart Home Integration Protocol 4.2
2.2. Table of Contents
- Integration Basic Requirements
- Connection Method
- Protocol Format
- Command Allocation Rules
- Data Sent by Each Command
- 5.1 Heartbeat Request
- 5.2 Heartbeat Response
- 5.3 Request Device List
- 5.4 Return Device List, Device List Updated
- 5.5 Request Scene List
- 5.6 Return Scene List
- 5.7 Request Room List (Optional)
- 5.8 Return Room List (Optional)
- 5.9 Request Floor List (Optional)
- 5.10 Return Floor List (Optional)
- 5.11 Send Control Command
- 5.12 Response to Control Command, Device Status Updated
- Return Status Codes
- Common Device Types
- Control Commands
2.2.1. 1. Integration Basic Requirements
1.1 Must be able to provide all device list data. Device information must include Device ID, Device Name, Device Type, Device Status (optional), Room ID (optional), Floor ID (optional). 1.2 Must be able to provide all scene list data. Scene information must include Scene ID, Scene Name. 1.3 Must be able to provide all room list data. Room information must include Room ID, Room Name. (Optional) 1.4 Must be able to provide all floor list data. Floor information must include Floor ID, Floor Name. (Optional)
2.2.2. 2. Connection Method
Background music host sends UDP broadcast, port (tentative) 6666, sending data as follows:
{ "type": "REQUEST_TCP", "sn": "xxxxx" // The SN code of the background music host, unique device ID }
After the server receives the broadcast from the background music host, it sends a UDP broadcast, port (tentative) 7777, sending data as follows:
{ "type": "RESPONSE_TCP", "data": { "ip": "xxx.xxx.xxx.xxx", "port": 8888, "company": "xxxx",//The company field represents the integration partner "protocolVersion": "v1" //The protocolVersion field indicates the version used (optional v1 and v2. The protocol format changes accordingly) // V1 protocol header is 0xAA, length 2 bytes. V2 protocol header is 0xAB, length 3 bytes. The v2 version can receive more device data. } }
The background music host obtains the server's IP and connects to the server via TCP, port (tentative) 8888.
- Then obtain data through the protocol format below.
2.2.3. 3. Protocol Format
protocolVersion=v1/v2
Protocol Header (0XAA) | Length (0XXXXX) | Command Number (0XXXXX) | Data | Checksum (0XXXXX) |
---|---|---|---|---|
One byte, fixed 0xAA for v1, 0xAB for v2 | Two bytes for v1, three bytes for v2, represents the length of the "Data" part in the protocol, excluding the command number and checksum | Two bytes, refer to command allocation rules | Command content, content is a UTF-8 encoded string | One byte, XOR all bytes in "Length, Command Number, Data" with 0 and then multiply |
Protocol Length:
- v1 protocol total length = 6 + data length
- v2 protocol total length = 7 + data length
Verification Algorithm:XOR all bytes in "Length, Command Number, Data" with 0 and then multiply.
private boolean check(byte fcs, byte[] data) {
int xorResult = 0;
for (byte b : data) {
xorResult ^= b;
}
return fcs == xorResult;
}
2.2.4. 4. Command Allocation Rules
Command Number | Sender | Receiver | Command Type |
---|---|---|---|
0x0001 | Client | Gateway | Heartbeat Request |
0x0002 | Gateway | Client | Heartbeat Response |
0x0003 | Client | Gateway | Send Control Command |
0x0004 | Gateway | Client | Response to Control Command, Device Status Updated |
0x0005 | Client | Gateway | Request Device List |
0x0006 | Gateway | Client | Return Device List, Device List Updated |
0x0007 | Client | Gateway | Request Scene List |
0x0008 | Gateway | Client | Return Scene List |
0x0009 | Client | Gateway | Request Room List (Optional) |
0x000A | Gateway | Client | Return Room List (Optional) |
0x000B | Client | Gateway | Request Floor List (Optional) |
0x000C | Gateway | Client | Return Floor List (Optional) |
0x000D | Client | Gateway | (Reserved) |
0x000F | Gateway | Client | Notify Screen End to Re-fetch Device Scene Data |
Note:Client refers to the background music host.
2.2.5. 5. Data Sent by Each Command
5.1 Heartbeat Request
{
"type": "REQUEST_HEART_BEAT",
"sn": "xxxxx"
}
5.2 Heartbeat Response
{
"type": "RESPONSE_HEART_BEAT"
}
5.3 Request Device List
{
"type": "REQUEST_DEVICE",
"sn": "xxxxx"
}
5.4 Return Device List, Device List Updated
{
"type": "RESPONSE_DEVICE",
"deviceData": [
{
"deviceId": "Device ID",
"deviceName": "Device Name",
"deviceType": "Device Type",
"roomId": "Room ID (optional)",
"floorId": "Floor ID (optional)",
"state": {
"order": "Device command on, off, pause (optional)",
"mode": "Device mode (optional)",
"temperature": "Temperature (optional)",
"fanSpeed": "Fan speed (optional)",
"fanDirection": "Fan direction (optional)",
"brightness": "Brightness 0-100 (optional)",
"colorTemp":"Color temperature value 0-100",
"position": "Progress 0-100 (optional)",
"angle": "Angle 0-180",
"sensorStatus": "1: Someone, trigger alarm 0: No one, no trigger",
"battery": "Battery level",
"humidity": "Humidity",
"universalSensorData": "Universal sensor data (jsonArray.toJSONString())"
},
"modeAttributes": "Mode attributes, the desktop can custom display which modes to control based on the filled mode attributes",
"speedAttributes": "Speed attributes, the desktop can custom display which speeds to control based on the filled mode attributes",
"directionAttributes": "Direction attributes, the desktop can custom display which directions to control based on the filled mode attributes"
}
]
}
Universal Sensor universalSensorData Explanation::
Universal Sensor type=DEVICE_TYPE_MULTIFUNCTIONAL_SENSOR
Specific sensor data, this value is in jsonArray form, can be passed as follows:
universalSensorData=jsonArray.toJSONString();
JSONArray jsonArray = new JSONArray();
jsonArray.put(new JSONObject().put("key", "温度").put("value", "23.5℃"));
jsonArray.put(new JSONObject().put("key", "湿度").put("value", "65%"));
jsonArray.put(new JSONObject().put("key", "PM2.5").put("value", "35"));
jsonArray.put(new JSONObject().put("key", "光照强度").put("value", "300lux"));
You can set whatever you want to display, key represents the name, value represents the corresponding value for that name.
"universalSensorData": "[
{"key":"Temperature","value":"23.5℃"},
{"key":"Humidity","value":"65%"},
{"key":"PM2.5","value":"35"},
{"key":"Illuminance","value":"300lux"}
]"
modeAttributes Mode Attributes Explanation::
- Attributes supported by Air Conditioner/Thermostat:
["cold","heat","airsupply","dehumidification","auto","manual","comfortable","sleep"]
- Attributes supported by Fresh Air/Underfloor Heating:
["auto","manual","sleep"]
speedAttributes Speed Attributes Explanation::
- Attributes supported by Air Conditioner/Thermostat:
["low","medium","high","autoWind","sleepWind","quietWind"]
- Attributes supported by Fresh Air:
["low","medium","high","autoWind","sleepWind"]
directionAttributes Direction Attributes Explanation::
- Attributes supported by Air Conditioner:
["leftright","updown"]
5.5 Request Scene List
{
"type": "REQUEST_SCENE",
"sn": "xxxxx"
}
5.6 Return Scene List
{
"type": "RESPONSE_SCENE",
"data": [
{
"id": "Scene ID",
"name": "Scene Name",
"aliasList": ["Scene Alias 1", "Scene Alias 2"]
},
{
"id": "Scene ID",
"name": "Scene Name",
"aliasList": ["Scene Alias 1", "Scene Alias 2"]
}
]
}
5.7 Request Room List (Optional)
{
"type": "REQUEST_ROOM",
"sn": "xxxxx"
}
5.8 Return Room List (Optional)
{
"type": "RESPONSE_ROOM",
"data": [
{
"id": "Room ID",
"name": "Room Name"
},
{
"id": "Room ID",
"name": "Room Name"
}
]
}
5.9 Request Floor List (Optional)
{
"type": "REQUEST_FLOOR",
"sn": "xxxxx"
}
5.10 Return Floor List (Optional)
{
"type": "RESPONSE_FLOOR",
"data": [
{
"id": "Floor ID",
"name": "Floor Name"
}
]
}
5.11 Send Control Command
{
"type":"REQUEST_CONTROL",
"sn":"xxxxx",
"original":"Primitive",
"data":[
{
//Specific control command to send
"id":"Device ID",
"name":"Device Name",
"scene":"Scene",
"state":"Status",
"action":"Action",
"attribute":"Attribute",
"attributeValue":"Attribute Value",
"mode":"Mode",
"floor":"Floor",
"room":"Room"
}
]
}
5.12 Response to Control Command, Device Status Updated
{
"type": "RESPONSE_CONTROL",
"code":0,//Return code
"msg":"Return message", //If empty, defaults to replying ["Okay"]
"msgVoice":"What the background music host needs to say",
"deviceId":"Device ID",
"deviceName":"Device Name",
"deviceType":"Device Type",
"deviceState":{
//Specific returned device status data
"order":"Device command on, off, pause",
"mode":"Device mode",
"temperature":"Temperature",
"fanSpeed":"Fan speed",
"fanDirection":"Fan direction",
"brightness":"Brightness 0-100",
"position":"Progress 0-100 ",
"angle":"Angle 0-180",
"sensorStatus":"1: Someone, trigger 0: No one, no trigger",
"battery":"Battery level",
"humidity":"Humidity",
"universalSensorData":"Universal sensor(jsonArray.toJSONString())"
}
}
Note:When the order field in 5.4 Get Device List and 5.12 Status Update is empty, it will be defaulted to STATE_OFF|Off.
2.2.6. 6. Return Status Codes
Status Code | Meaning |
---|---|
0 | Control successful |
1 | Device does not exist |
2 | Device does not support this operation |
3 | Control parameters incorrect |
4 | Device offline |
5 | Device control timeout |
6 | Other |
2.2.7. 7. Common Device Types
Device Name | English Type |
---|---|
Light | LIGHT |
Dimmable Light | DIMMING_LAMP |
Socket | SOCKET |
Curtain | CURTAIN |
Adjustable Progress Curtain | ADJUST_CURTAIN |
Fan | ELECTRIC_FAN |
Air Conditioner | AIR_CONDITION |
TV | TV |
Thermostat | THERMOSTAT |
Projector | PROJECT |
Dream Curtain (with angle adjustment) | CURTAIN_ANGLE |
Door/Window Contact Sensor | DOOR_MAGNETIC_SENSOR |
Water Leakage Sensor | DOOR_WATER_SENSOR |
Human Infrared Sensor | INFRARED_SENSOR |
Smoke Sensor | SMOKER_SENSOR |
SOS | SOS_SENSOR |
CO2 | CO2_SENSOR |
Universal Sensor | DEVICE_TYPE_MULTIFUNCTIONAL_SENSOR |
Temperature/Humidity Display | TEMP_HUMIDITY_SENSOR |
Fresh Air | FRESH_AIR |
Underfloor Heating | FLOOR_HEATING |
Switch | SWITCH |
Color Temperature Light | CW_LAMP |
2.2.8. 8. Control Commands
Switches, lights, and other device types
- Control information
state=STATE_ON
(on)state=STATE_OFF
(off)
Dimmer light
- Brightness:
{ "action": "ACTION_TO", "attributeValue": "brightness value" }
Color temperature light
- Color temperature:
{ "action": "ACTION_TO", "attribute": "ATTRIBUTE_COLORTEMP", "attributeValue": "Color temperature value" }
- Brightness:
{ "action": "ACTION_TO", "attribute": "ATTRIBUTE_BRIGHTNESS", "attributeValue": "Brightness value" }
Air conditioning, thermostat
- Mode:
{ "attribute": "ATTRIBUTE_MODE", "mode": "mode value" //"MODE_COOL","MODE_HEAT","MODE_FAN","MODE_DRY","MODE_AUTO","MODE_MANUAL","MODE_COMFORTABLE","MODE_SLEEP" }
Wind speed:
{ "attribute": "ATTRIBUTE_WIND_SPEED", "attributeValue": "Wind speed value" //"MODE_WIND_LOW","MODE_WIND_MID","MODE_WIND_HIGH","MODE_WIND_AUTO","MODE_WIND_SLEEP","MODE_WIND_MUTE" }
Air conditioning direction:
{ "attribute": "ATTRIBUTE_WIND_DIRECTION", "attributeValue": "Wind direction value" //"MODE_SWING_UP_DOWN","MODE_SWING_LEFT_RIGHT" }
- Temperature regulation:
{ "action": "ACTION_TO", "attribute": "ATTRIBUTE_TEMPERATURE", "attributeValue": "Temperature value" }
Underfloor heating
- Mode:
{ "attribute": "ATTRIBUTE_MODE", "mode": "Mode value" //"MODE_AUTO","MODE_MANUAL","MODE_SLEEP" }
- Temperature regulation:
{ "action": "ACTION_TO", "attribute": "ATTRIBUTE_TEMPERATURE", "attributeValue": "Temperature value" }
Fresh air
- Mode:
{ "attribute": "ATTRIBUTE_MODE", "mode": "Mode value" //"MODE_AUTO","MODE_MANUAL","MODE_SLEEP" }
- Wind speed:
{ "attribute": "ATTRIBUTE_WIND_SPEED", "mode": "Wind speed value" //"MODE_WIND_HIGH","MODE_WIND_MID","MODE_WIND_LOW","MODE_WIND_SLEEP","MODE_WIND_AUTO" }
Curtains,Progress curtains:
- Control information:
state=STATE_ON
(ON,Progress 100)state=STATE_OFF
(OFF,Progress 0)state=STATE_STOP
(STOP,Progress 50)
- Progress:
{ "action": "ACTION_TO", "attributeValue": "Progress value" }
Dream Curtain (with angle adjustment)::
- Control command information:
state=STATE_ON
(Turn on, progress 100)state=STATE_OFF
(Turn off, progress 0)state=STATE_STOP
(Pause, progress 50)
- Progress:
{ "action": "ACTION_TO", "attribute": "ATTRIBUTE_PROGRESS", "attributeValue": "Specific progress value" }
- Angle
{ "action": "ACTION_TO", "attribute": "ATTRIBUTE_ANGLE", "attributeValue": "Specific angle value" }
TV:
- Channel Up:
{ "action": "ACTION_ADD", "attribute": "ATTRIBUTE_CHANNEL", "attributeValue": "CHANNEL_UP" }
- Channel Down:
{ "action": "ACTION_REDUCE", "attribute": "ATTRIBUTE_CHANNEL", "attributeValue": "CHANNEL_DOWN" }
Volume Up:
{ "action": "ACTION_ADD", "attribute": "ATTRIBUTE_VOLUME", "attributeValue": "VOLUME_UP" }
Volume Down:
{ "action": "ACTION_REDUCE", "attribute": "ATTRIBUTE_VOLUME", "attributeValue": "VOLUME_DOWN" }
Mute
{ "action": "ACTION_TO", "mode": "MODE_MUTE" }
Unmute/Cancel Mute:
{ "action": "ACTION_TO", "mode": "MODE_CANCEL_MUTE" }
Status:
STATE_ON
:OnSTATE_OFF
:OffSTATE_STOP
:Stop
Action:
ACTION_TO
:Adjust to, set to, change to, switch to, become, setACTION_ADD
:Brighten, Increase, Warm up, Heat up, Turn up, Make louder, Increase, Add, Brighter, A bit brighter, Higher, A bit higher, Next, Raise, Larger, A bit larger, Add, Increase, Pull up, Pull open
Mode:
MODE_COOL
:CoolMODE_HEAT
:HeatMODE_FAN
:FanMODE_DRY
:DryMODE_AUTO
:AutoMODE_MANUAL
:ManualMODE_COMFORTABLE
:ComfortMODE_SLEEP
:SleepMODE_WIND_HIGH
:High WindMODE_WIND_MID
:Medium WindMODE_WIND_LOW
:Low WindMODE_WIND_AUTO
:Auto WindMODE_WIND_MUTE
:Mute WindMODE_WIND_SLEEP
:Sleep WindMODE_PLAY
:PlayMODE_PAUSE
:PauseMODE_MUTE
:MuteMODE_CANCEL_MUTE
:Cancel MuteMODE_NEXT
:Next, Air conditioner mode switchMODE_PREVIOUS
:PreviousMODE_SWING_ANGLE
:Swing, OscillateMODE_SWING_NO
:Stop swing, Stop oscillationMODE_SWING_LEFT_RIGHT
:Left-right swingMODE_SWING_UP_DOWN
:Up-down swingMODE_PURIFIER
:Air Purification
Attribute:
ATTRIBUTE_MODE
:ModeATTRIBUTE_WIND_SPEED
:Wind SpeedATTRIBUTE_WIND_DIRECTION
:Wind DirectionATTRIBUTE_TEMPERATURE
:TemperatureATTRIBUTE_HUMIDITY
:HumidityATTRIBUTE_GEAR
:GearATTRIBUTE_BRIGHTNESS
:BrightnessATTRIBUTE_COLOR
:ColorATTRIBUTE_COLOR_TEMP
:Color TemperatureATTRIBUTE_VOLUME
:Volume, SoundATTRIBUTE_CHANNEL
:Channel, Program, StationATTRIBUTE_HOUR
:HourATTRIBUTE_MINUTE
:MinuteATTRIBUTE_SECOND
:SecondATTRIBUTE_PROGRESS
:ProgressATTRIBUTE_ANGLE
:Angle
Attribute Value:
VALUE_COLOR_WHITE
:WhiteVALUE_COLOR_RED
:RedVALUE_COLOR_ORANGE
:OrangeVALUE_COLOR_YELLOW
:YellowVALUE_COLOR_GREEN
:GreenVALUE_COLOR_CYAN
:CyanVALUE_COLOR_BLUE
:BlueVALUE_COLOR_PURPLE
:PurpleVALUE_COLOR_PINK
:PinkVALUE_MAX
:Brightest, Largest, Highest, MostVALUE_MIN
:Darkest, Smallest, Lowest, ColdestVALUE_LITTLE
:A little, A bitCHANNEL_UP
:Channel UpCHANNEL_DOWN
:Channel DownVOLUME_UP
:Volume UpVOLUME_DOWN
:Volume Down0.5
:0.51.5
:1.52.5
:2.53.5
:3.54.5
:4.5