From 86fff45a2cd9755fd6bd77f64ab34b12b8f67253 Mon Sep 17 00:00:00 2001 From: zhaowg Date: Wed, 29 Aug 2018 17:54:11 +0800 Subject: [PATCH] 鐢典俊IOT鎻掍欢 --- pom.xml | 1 + zteits-job/src/main/resources/application-dany.properties | 26 ++++++++++++++++++++++++++ zteits-nbiot/lib/com.huawei.m2m.cig.tup-1.3.1.jar | Bin 0 -> 1615 bytes zteits-nbiot/package/VehicleDetector-ZTEITS-ZTEITS-1.0.0.jar | Bin 0 -> 156295 bytes zteits-nbiot/package/package.zip | Bin 0 -> 156027 bytes zteits-nbiot/pom.xml | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ zteits-nbiot/src/main/java/com/zteits/nbiot/decoder/Utilty.java | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ zteits-nbiot/src/main/java/com/zteits/nbiot/decoder/ZteitsCmdProcess.java | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ zteits-nbiot/src/main/resources/OSGI-INF/CodecProvideHandler.xml | 7 +++++++ zteits-nbiot/src/test/java/com/thrid/party/codec/demo/ProtocolServiceImplTest.java | 260 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 611 insertions(+), 0 deletions(-) create mode 100644 zteits-job/src/main/resources/application-dany.properties create mode 100644 zteits-nbiot/lib/com.huawei.m2m.cig.tup-1.3.1.jar create mode 100644 zteits-nbiot/package/VehicleDetector-ZTEITS-ZTEITS-1.0.0.jar create mode 100644 zteits-nbiot/package/package.zip create mode 100644 zteits-nbiot/pom.xml create mode 100644 zteits-nbiot/src/main/java/com/zteits/nbiot/decoder/Utilty.java create mode 100644 zteits-nbiot/src/main/java/com/zteits/nbiot/decoder/ZteitsCmdProcess.java create mode 100644 zteits-nbiot/src/main/resources/OSGI-INF/CodecProvideHandler.xml create mode 100644 zteits-nbiot/src/test/java/com/thrid/party/codec/demo/ProtocolServiceImplTest.java diff --git a/pom.xml b/pom.xml index 8e378bf..6a1bd5a 100644 --- a/pom.xml +++ b/pom.xml @@ -10,6 +10,7 @@ 1.0-SNAPSHOT zteits-job + zteits-nbiot \ No newline at end of file diff --git a/zteits-job/src/main/resources/application-dany.properties b/zteits-job/src/main/resources/application-dany.properties new file mode 100644 index 0000000..b9a89fc --- /dev/null +++ b/zteits-job/src/main/resources/application-dany.properties @@ -0,0 +1,26 @@ +server.port=8075 + +#park-datasource +park-datasource.url=jdbc:mysql://172.19.128.115:3306/zt_park?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true +park-datasource.username=park +park-datasource.password=MySQL57@123 + +#order-datasource +order-datasource.driverClassName=com.mysql.jdbc.Driver +order-datasource.url=jdbc:mysql://172.19.128.115/zt_order_n?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true +order-datasource.username=order +order-datasource.password=MySQL57@123 + +#道闸平台地址-获取空闲车位数使用 +dzurl.qingdao=http://47.104.7.222:12220 +dzurl.nanze=http://121.40.121.40:8087 +irain.bjxc.getfreeberthNum= +dzurl.irain=http://api.parkingwang.com:8280 +dzurl.irain.appid=avakrky0gk1m7n00 +dzurl.irain.appsecret=rrr6uz3aqvutpsq2lsna0k18cea4mabw + + +spring.redis.host=172.19.0.178 +spring.redis.port=6379 +spring.redis.password=myredis +spring.redis.database=0 diff --git a/zteits-nbiot/lib/com.huawei.m2m.cig.tup-1.3.1.jar b/zteits-nbiot/lib/com.huawei.m2m.cig.tup-1.3.1.jar new file mode 100644 index 0000000..389ffc0 Binary files /dev/null and b/zteits-nbiot/lib/com.huawei.m2m.cig.tup-1.3.1.jar differ diff --git a/zteits-nbiot/package/VehicleDetector-ZTEITS-ZTEITS-1.0.0.jar b/zteits-nbiot/package/VehicleDetector-ZTEITS-ZTEITS-1.0.0.jar new file mode 100644 index 0000000..55b00fa Binary files /dev/null and b/zteits-nbiot/package/VehicleDetector-ZTEITS-ZTEITS-1.0.0.jar differ diff --git a/zteits-nbiot/package/package.zip b/zteits-nbiot/package/package.zip new file mode 100644 index 0000000..8775faf Binary files /dev/null and b/zteits-nbiot/package/package.zip differ diff --git a/zteits-nbiot/pom.xml b/zteits-nbiot/pom.xml new file mode 100644 index 0000000..6f2e54a --- /dev/null +++ b/zteits-nbiot/pom.xml @@ -0,0 +1,115 @@ +锘 + 4.0.0 + + com.zteits.nbiot + + VehicleDetector-ZTEITS-ZTEITS + 1.0.0 + + bundle + + + UTF-8 + 4.11 + 2.7.4 + 2.5.4 + 2.4 + 1.3.1 + 1.7.6 + ./ + + + + + + junit + junit + ${junit.version} + + + + org.slf4j + slf4j-api + ${slf4j.api.version} + + + + com.fasterxml.jackson.core + jackson-databind + ${fasterxml.jackson.version} + + + + + com.huawei + protocal-jar + 1.3.1 + system + ${basedir}/lib/com.huawei.m2m.cig.tup-1.3.1.jar + + + + + net.sf.json-lib + json-lib + 2.4 + jdk15 + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + org.apache.felix + maven-bundle-plugin + ${felix.maven.plugin.version} + true + + ./target + + false + + + J2SE-1.5 + + OSGI-INF/* + + VehicleDetector-ZTEITS-ZTEITS + + + org.slf4j, + org.slf4j.spi, + org.apache.log4j.spi, + com.huawei.m2m.cig.tup.modules.protocol_adapter, + com.fasterxml.jackson.databind, + com.fasterxml.jackson.databind.node + + + + json-lib + + + + + + generate-resource + + manifest + + + + + + + \ No newline at end of file diff --git a/zteits-nbiot/src/main/java/com/zteits/nbiot/decoder/Utilty.java b/zteits-nbiot/src/main/java/com/zteits/nbiot/decoder/Utilty.java new file mode 100644 index 0000000..d9de305 --- /dev/null +++ b/zteits-nbiot/src/main/java/com/zteits/nbiot/decoder/Utilty.java @@ -0,0 +1,95 @@ +package com.zteits.nbiot.decoder; + + +import java.util.Arrays; + +public class Utilty { + + private static Utilty instance = new Utilty(); + + public static Utilty getInstance() { + return instance; + } + + public static final int MIN_MID_VALUE = 1; + + public static final int MAX_MID_VALUE = 65535; + + + public static int bytes2Int(byte[] b, int start, int length) { + int sum = 0; + int end = start + length; + for (int k = start; k < end; k++) { + int n = ((int) b[k]) & 0xff; + n <<= (--length) * 8; + sum += n; + } + return sum; + } + + public static byte[] int2Bytes(int value, int length) { + byte[] b = new byte[length]; + for (int k = 0; k < length; k++) { + b[length - k - 1] = (byte) ((value >> 8 * k) & 0xff); + } + return b; + } + + public boolean isValidofMid(int mId) { + if (mId < MIN_MID_VALUE || mId > MAX_MID_VALUE) { + return false; + } + return true; + } + + public static String parseByte2HexStr(byte[] buf) { + if (null == buf) { + return null; + } + + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < buf.length; i++) { + String hex = Integer.toHexString(buf[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + sb.append(hex.toUpperCase()); + } + return sb.toString(); + } + /** + * 16杩涘埗杞崲鎴愪负integer + * @return + */ + public static Integer hexStringToInteger(byte[] original, int from, int to) { + String s = Utilty.parseByte2HexStr(Arrays.copyOfRange(original, from, to)); + return Integer.parseInt(s,16); + } + + /** + * 16杩涘埗杞崲鎴愪负string绫诲瀷瀛楃涓 + * @return + */ + public static String hexStringToString(byte[] original, int from, int to) { + String s = Utilty.parseByte2HexStr(Arrays.copyOfRange(original, from, to)); + if (s == null || s.equals("")) { + return null; + } + s = s.replace(" ", ""); + byte[] baKeyword = new byte[s.length() / 2]; + for (int i = 0; i < baKeyword.length; i++) { + try { + baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16)); + } catch (Exception e) { + e.printStackTrace(); + } + } + try { + s = new String(baKeyword, "UTF-8"); + new String(); + } catch (Exception e1) { + e1.printStackTrace(); + } + return s; + } +} diff --git a/zteits-nbiot/src/main/java/com/zteits/nbiot/decoder/ZteitsCmdProcess.java b/zteits-nbiot/src/main/java/com/zteits/nbiot/decoder/ZteitsCmdProcess.java new file mode 100644 index 0000000..57b654e --- /dev/null +++ b/zteits-nbiot/src/main/java/com/zteits/nbiot/decoder/ZteitsCmdProcess.java @@ -0,0 +1,107 @@ +package com.zteits.nbiot.decoder; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import java.util.Arrays; +import java.util.Date; + +public class ZteitsCmdProcess { + + private String msgType = "cloudRsp"; + private String serviceId = "VehicleDetectorInfo"; + private String cmd = "SET_DEVICE_LEVEL"; + private int hasMore = 1; + //璇锋眰澶勭悊鐨勭粨鏋滅爜,0琛ㄧず鎴愬姛锛1琛ㄧず澶辫触 + private int errcode = 1; + private int mid = 0; + private byte[] requests; + private JsonNode paras; + + + public ZteitsCmdProcess() { + } + + public ZteitsCmdProcess(ObjectNode input) { + + try { + this.msgType = input.get("msgType").asText(); + this.requests = input.get("request").binaryValue(); + /* + 骞冲彴鏀跺埌璁惧涓婃姤娑堟伅锛岀紪鐮丄CK + { + "msgType":"cloudRsp", + "request": ***,//璁惧涓婃姤鐨勭爜娴 + "errcode":0, + "hasMore":0 + } + * */ + if (msgType.equals("cloudRsp")) { + //鍦ㄦ缁勮ACK鐨勫 + this.errcode = input.get("errcode").asInt(); + this.hasMore = input.get("hasMore").asInt(); + } + } catch (Exception e) { + this.errcode = 1; + e.printStackTrace(); + } + + } + + public byte[] toByte() { + try { + /* + 骞冲彴鏀跺埌璁惧鐨勪笂鎶ユ暟鎹紝鏍规嵁闇瑕佺紪鐮丄CK锛屽璁惧杩涜鍝嶅簲锛屽鏋滄澶勮繑鍥瀗ull锛岃〃绀轰笉闇瑕佸璁惧鍝嶅簲銆 + * */ + if (this.msgType.equals("cloudRsp")) { + + byte[] ack = new byte[28]; + ack[0] = (byte) 0x77; + ack[1] = (byte)0x00; + //璇锋眰澶勭悊鐨勭粨鏋滅爜銆 + //0琛ㄧず鎴愬姛锛1琛ㄧず澶辫触 + if(errcode == 0){ + ack[2] = (byte)0x70; + }else if(errcode == 1){ + ack[2] = (byte)0x30; + } + //packCount 2H + ack[3] = requests[18]; + ack[4] = requests[19]; + //magId 4H + ack[5] = requests[22]; + ack[6] = requests[23]; + ack[7] = requests[24]; + ack[8] = requests[25]; + //command 2H + ack[9] = (byte)0x00; + ack[10] = (byte)0x00; + //鏃堕棿8H + ack[11] = (byte)0x00; + ack[12] = (byte)0x00; + ack[13] = (byte)0x00; + ack[14] = (byte)0x00; + Long time = new Date().getTime()/1000; + byte[] timeByte = Utilty.int2Bytes(time.intValue(), 4); + ack[15] = timeByte[0]; + ack[16] = timeByte[1]; + ack[17] = timeByte[2]; + ack[18] = timeByte[3]; + + ack[19] = (byte)errcode; + ack[20] = (byte)0x00; + ack[21] = (byte)0x00; + ack[22] = (byte)0x00; + ack[23] = (byte)0x00; + ack[24] = (byte)0x00; + ack[25] = (byte)0x00; + return CRC16Util.appendCrc16(ack); + } + return null; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/zteits-nbiot/src/main/resources/OSGI-INF/CodecProvideHandler.xml b/zteits-nbiot/src/main/resources/OSGI-INF/CodecProvideHandler.xml new file mode 100644 index 0000000..e186746 --- /dev/null +++ b/zteits-nbiot/src/main/resources/OSGI-INF/CodecProvideHandler.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/zteits-nbiot/src/test/java/com/thrid/party/codec/demo/ProtocolServiceImplTest.java b/zteits-nbiot/src/test/java/com/thrid/party/codec/demo/ProtocolServiceImplTest.java new file mode 100644 index 0000000..9cb91cd --- /dev/null +++ b/zteits-nbiot/src/test/java/com/thrid/party/codec/demo/ProtocolServiceImplTest.java @@ -0,0 +1,260 @@ +package com.thrid.party.codec.demo; + +import com.zteits.nbiot.decoder.ProtocolAdapterImpl; +import org.junit.Before; +import org.junit.Test; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.huawei.m2m.cig.tup.modules.protocol_adapter.IProtocolAdapter; + +/** + * Unit test for simple App. + */ +public class ProtocolServiceImplTest { + + private IProtocolAdapter protocolAdapter; + + @Before + public void setProtocolAdapter() { + this.protocolAdapter = new ProtocolAdapterImpl(); + } + + /** + * 娴嬭瘯鐢ㄤ緥1锛氳澶囧悜骞冲彴涓婃姤鏁版嵁銆 + *

+ *

+     * 璁惧涓婃姤鏁版嵁:AA72000032088D0320623399
+     * 
+ * + * @throws Exception + */ + @Test + public void testDecodeDeviceReportData() throws Exception { + byte[] deviceReqByte = initDeviceReqByte(); + ObjectNode objectNode = protocolAdapter.decode(deviceReqByte); + String str = objectNode.toString(); + System.out.println(str); + } + + public static void main(String[] args) throws Exception { + IProtocolAdapter protocolAdapter = new ProtocolAdapterImpl(); + byte[] deviceReqByte = initDeviceReqByte(); + ObjectNode cloudRspObjectNode = initCloudRspObjectNode(deviceReqByte); + byte[] outputByte2 = protocolAdapter.encode(cloudRspObjectNode); + System.out.println("cloudRsp output:" + parseByte2HexStr(outputByte2)); + } + + /** + * 娴嬭瘯鐢ㄤ緥2锛氬钩鍙板悜璁惧涓嬪彂鎺у埗鍛戒护: + *

+ *

+     * {
+     * //"identifier": "123",
+     * "msgType": "cloudReq",
+     * "cmd": "SET_DEVICE_LEVEL",
+     * "mid": 2016,
+     * "paras": { "value": "10" },
+     * "hasMore": 0
+     * }
+     * 
+ */ + @Test + public void testEncodeIoTSendCommand() throws Exception { + ObjectNode CloudReqObjectNode = initCloudReqObjectNode(); + byte[] outputByte = protocolAdapter.encode(CloudReqObjectNode); + System.out.println("cloudReq output:" + parseByte2HexStr(outputByte)); + } + + /** + * 娴嬭瘯鐢ㄤ緥3锛氳澶囧骞冲彴鍛戒护鐨勫簲绛旀秷鎭 鏈夊懡浠ょ煭id + *

+ *

+     * 璁惧搴旂瓟娑堟伅:AA7201000107E0
+     *
+     * 
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testDecodeDeviceResponseIoT() throws Exception {
+        byte[] deviceRspByte = initDeviceRspByte();
+        ObjectNode objectNode = protocolAdapter.decode(deviceRspByte);
+        String str = objectNode.toString();
+        System.out.println(str);
+    }
+
+    /**
+     * 娴嬭瘯鐢ㄤ緥4锛氬钩鍙版敹鍒拌澶囩殑涓婃姤鏁版嵁鍚庡璁惧鐨勫簲绛旓紝濡傛灉涓嶉渶瑕佸簲绛斿垯杩斿洖null鍗冲彲
+     * 
+     * {
+     * "identifier": "0",
+     * "msgType": "cloudRsp",
+     * "request": [AA,72,00,00,32,08,8D,03,20,62,33,99],
+     * "errcode": 0,
+     * "hasMore": 0
+     * }
+     *
+     * 
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testEncodeIoTResponseDevice() throws Exception {
+        byte[] deviceReqByte = initDeviceReqByte();
+        ObjectNode cloudRspObjectNode = initCloudRspObjectNode(deviceReqByte);
+        byte[] outputByte2 = protocolAdapter.encode(cloudRspObjectNode);
+        System.out.println("cloudRsp output:" + parseByte2HexStr(outputByte2));
+    }
+
+    public static String parseByte2HexStr(byte[] buf) {
+        if (null == buf) {
+            return null;
+        }
+
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < buf.length; i++) {
+            String hex = Integer.toHexString(buf[i] & 0xFF);
+            if (hex.length() == 1) {
+                hex = '0' + hex;
+            }
+            sb.append(hex.toUpperCase());
+        }
+        return sb.toString();
+    }
+
+    /*
+     * 鍒濆鍖栵細璁惧鏁版嵁涓婃姤鐮佹祦
+     */
+    private static byte[] initDeviceReqByte() {
+        /**
+         * 鏈緥鍏ュ弬锛 57 58 48 53 50 5F 4D 44 21 00 00 00 00 5A 9E 68 42 01 00 01 0B B8
+         01 13 1D B1 12 00 14 00 1E 00 0F 04 00 00 01 00 00 02 00 05 00 0A 00 0F 00 00 00 00 00 00 00 00 00 00 00 00 27 8F
+         */
+        byte[] byteDeviceReq = new byte[60];
+
+
+
+        byteDeviceReq[0] = (byte) 0x57;
+        byteDeviceReq[1] = (byte) 0x58;
+        byteDeviceReq[2] = (byte) 0x48;
+        byteDeviceReq[3] = (byte) 0x53;
+
+        byteDeviceReq[4] = (byte) 0x50;
+        byteDeviceReq[5] = (byte) 0x5F;
+        byteDeviceReq[6] = (byte) 0x4D;
+        byteDeviceReq[7] = (byte) 0x44;
+
+        byteDeviceReq[8] = (byte) 0x21;
+
+        byteDeviceReq[9] = (byte) 0x00;
+
+        byteDeviceReq[10] = (byte) 0x00;
+        byteDeviceReq[11] = (byte) 0x00;
+        byteDeviceReq[12] = (byte) 0x00;
+
+        byteDeviceReq[13] = (byte) 0x5A;
+        byteDeviceReq[14] = (byte) 0x9E;
+        byteDeviceReq[15] = (byte) 0x68;
+        byteDeviceReq[16] = (byte) 0x42;
+        byteDeviceReq[17] = (byte) 0x01;
+
+        byteDeviceReq[18] = (byte) 0x00;
+        byteDeviceReq[19] = (byte) 0x01;
+        byteDeviceReq[20] = (byte) 0x0B;
+        byteDeviceReq[21] = (byte) 0xB8;
+        byteDeviceReq[22] = (byte) 0x01;
+        byteDeviceReq[23] = (byte) 0x13;
+        byteDeviceReq[24] = (byte) 0x1D;
+        byteDeviceReq[25] = (byte) 0xB1;
+        byteDeviceReq[26] = (byte) 0x12;
+        byteDeviceReq[27] = (byte) 0x00;
+        byteDeviceReq[28] = (byte) 0x14;
+        byteDeviceReq[29] = (byte) 0x00;
+        byteDeviceReq[30] = (byte) 0x1E;
+        byteDeviceReq[31] = (byte) 0x00;
+        byteDeviceReq[32] = (byte) 0x0F;
+
+        byteDeviceReq[33] = (byte) 0x04;
+        byteDeviceReq[34] = (byte) 0x00;
+        byteDeviceReq[35] = (byte) 0x00;
+        byteDeviceReq[36] = (byte) 0x01;
+        byteDeviceReq[37] = (byte) 0x00;
+        byteDeviceReq[38] = (byte) 0x00;
+        byteDeviceReq[39] = (byte) 0x02;
+        byteDeviceReq[40] = (byte) 0x00;
+        byteDeviceReq[41] = (byte) 0x05;
+        byteDeviceReq[42] = (byte) 0x00;
+        byteDeviceReq[43] = (byte) 0x0A;
+        byteDeviceReq[44] = (byte) 0x00;
+        byteDeviceReq[45] = (byte) 0x0F;
+        byteDeviceReq[46] = (byte) 0x00;
+        byteDeviceReq[47] = (byte) 0x00;
+        byteDeviceReq[48] = (byte) 0x00;
+        byteDeviceReq[49] = (byte) 0x00;
+        byteDeviceReq[50] = (byte) 0x00;
+        byteDeviceReq[51] = (byte) 0x00;
+        byteDeviceReq[52] = (byte) 0x00;
+        byteDeviceReq[53] = (byte) 0x00;
+        byteDeviceReq[54] = (byte) 0x00;
+        byteDeviceReq[55] = (byte) 0x00;
+        byteDeviceReq[56] = (byte) 0x00;
+        byteDeviceReq[57] = (byte) 0x00;
+        byteDeviceReq[58] = (byte) 0x27;
+        byteDeviceReq[59] = (byte) 0x8F;
+
+
+
+        return byteDeviceReq;
+    }
+
+    /*
+     * 鍒濆鍖栵細骞冲彴鍚戣澶囧懡浠や笅鍙戞暟鎹
+     */
+    private static ObjectNode initCloudReqObjectNode() {
+        ObjectMapper mapper = new ObjectMapper();
+        ObjectNode cloudReqObjectNode = mapper.createObjectNode();
+        ObjectNode paras = mapper.createObjectNode();
+        paras.put("value", "10");
+        cloudReqObjectNode.put("identifier", "123");
+        cloudReqObjectNode.put("msgType", "cloudReq");
+        cloudReqObjectNode.put("cmd", "SET_DEVICE_LEVEL");
+        cloudReqObjectNode.put("paras", paras);
+        cloudReqObjectNode.put("hasMore", 0);
+        cloudReqObjectNode.put("mid", 2016);
+        return cloudReqObjectNode;
+    }
+
+    /*
+     * 鍒濆鍖栵細璁惧瀵瑰钩鍙扮殑鍝嶅簲鐮佹祦
+     */
+    private static byte[] initDeviceRspByte() {
+        /*
+         * 娴嬭瘯鐢ㄤ緥锛氭湁鍛戒护鐭璵id 璁惧搴旂瓟娑堟伅:AA7201000107E0
+         */
+        byte[] byteDeviceRsp = new byte[12];
+        byteDeviceRsp[0] = (byte) 0xAA;
+        byteDeviceRsp[1] = (byte) 0x72;
+        byteDeviceRsp[2] = (byte) 0x01;
+        byteDeviceRsp[3] = (byte) 0x00;
+        byteDeviceRsp[4] = (byte) 0x01;
+        byteDeviceRsp[5] = (byte) 0x07;
+        byteDeviceRsp[6] = (byte) 0xE0;
+        return byteDeviceRsp;
+    }
+
+    /*
+     * 鍒濆鍖栵細骞冲彴瀵硅澶囩殑搴旂瓟鏁版嵁
+     */
+    private static ObjectNode initCloudRspObjectNode(byte[] device2CloudByte) {
+
+        ObjectMapper mapper = new ObjectMapper();
+        ObjectNode cloudRspObjectNode = mapper.createObjectNode();
+        cloudRspObjectNode.put("msgType", "cloudRsp");
+        // 璁惧涓婃姤鐨勭爜娴
+        cloudRspObjectNode.put("request", device2CloudByte);
+        cloudRspObjectNode.put("errcode", 0);
+        cloudRspObjectNode.put("hasMore", 0);
+        return cloudRspObjectNode;
+    }
+}
--
libgit2 0.21.4