Commit 86fff45a2cd9755fd6bd77f64ab34b12b8f67253
1 parent
b5a79ddd
电信IOT插件
Showing
10 changed files
with
611 additions
and
0 deletions
pom.xml
zteits-job/src/main/resources/application-dany.properties
0 → 100644
1 | +server.port=8075 | |
2 | + | |
3 | +#park-datasource | |
4 | +park-datasource.url=jdbc:mysql://172.19.128.115:3306/zt_park?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true | |
5 | +park-datasource.username=park | |
6 | +park-datasource.password=MySQL57@123 | |
7 | + | |
8 | +#order-datasource | |
9 | +order-datasource.driverClassName=com.mysql.jdbc.Driver | |
10 | +order-datasource.url=jdbc:mysql://172.19.128.115/zt_order_n?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true | |
11 | +order-datasource.username=order | |
12 | +order-datasource.password=MySQL57@123 | |
13 | + | |
14 | +#道闸平台地址-获取空闲车位数使用 | |
15 | +dzurl.qingdao=http://47.104.7.222:12220 | |
16 | +dzurl.nanze=http://121.40.121.40:8087 | |
17 | +irain.bjxc.getfreeberthNum= | |
18 | +dzurl.irain=http://api.parkingwang.com:8280 | |
19 | +dzurl.irain.appid=avakrky0gk1m7n00 | |
20 | +dzurl.irain.appsecret=rrr6uz3aqvutpsq2lsna0k18cea4mabw | |
21 | + | |
22 | + | |
23 | +spring.redis.host=172.19.0.178 | |
24 | +spring.redis.port=6379 | |
25 | +spring.redis.password=myredis | |
26 | +spring.redis.database=0 | ... | ... |
zteits-nbiot/lib/com.huawei.m2m.cig.tup-1.3.1.jar
0 → 100644
No preview for this file type
zteits-nbiot/package/VehicleDetector-ZTEITS-ZTEITS-1.0.0.jar
0 → 100644
No preview for this file type
zteits-nbiot/package/package.zip
0 → 100644
No preview for this file type
zteits-nbiot/pom.xml
0 → 100644
1 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
2 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
3 | + <modelVersion>4.0.0</modelVersion> | |
4 | + | |
5 | + <groupId>com.zteits.nbiot</groupId> | |
6 | + <!-- 请修改为你的编解码插件的名字,命名规范:设备类型-厂商ID-设备型号,例如:WaterMeter-Huawei-NBIoTDevice --> | |
7 | + <artifactId>VehicleDetector-ZTEITS-ZTEITS</artifactId> | |
8 | + <version>1.0.0</version> | |
9 | + <!-- 请检查这里的值为bundle,不能为jar --> | |
10 | + <packaging>bundle</packaging> | |
11 | + | |
12 | + <properties> | |
13 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
14 | + <junit.version>4.11</junit.version> | |
15 | + <fasterxml.jackson.version>2.7.4</fasterxml.jackson.version> | |
16 | + <felix.maven.plugin.version>2.5.4</felix.maven.plugin.version> | |
17 | + <json.lib.version>2.4</json.lib.version> | |
18 | + <m2m.cig.version>1.3.1</m2m.cig.version> | |
19 | + <slf4j.api.version>1.7.6</slf4j.api.version> | |
20 | + <basedir>./</basedir> | |
21 | + </properties> | |
22 | + | |
23 | + <dependencies> | |
24 | + <!-- 单元测试使用 --> | |
25 | + <dependency> | |
26 | + <groupId>junit</groupId> | |
27 | + <artifactId>junit</artifactId> | |
28 | + <version>${junit.version}</version> | |
29 | + </dependency> | |
30 | + <!-- 日志使用 --> | |
31 | + <dependency> | |
32 | + <groupId>org.slf4j</groupId> | |
33 | + <artifactId>slf4j-api</artifactId> | |
34 | + <version>${slf4j.api.version}</version> | |
35 | + </dependency> | |
36 | + <!-- 转换JSON使用,必须 --> | |
37 | + <dependency> | |
38 | + <groupId>com.fasterxml.jackson.core</groupId> | |
39 | + <artifactId>jackson-databind</artifactId> | |
40 | + <version>${fasterxml.jackson.version}</version> | |
41 | + </dependency> | |
42 | + <!-- Huawei提供的编解码接口,必须 --> | |
43 | + <!-- systemPath请替换成你本地的目录 \codecDemo\lib\com.huawei.m2m.cig.tup-1.3.1.jar --> | |
44 | + <dependency> | |
45 | + <groupId>com.huawei</groupId> | |
46 | + <artifactId>protocal-jar</artifactId> | |
47 | + <version>1.3.1</version> | |
48 | + <scope>system</scope> | |
49 | + <systemPath>${basedir}/lib/com.huawei.m2m.cig.tup-1.3.1.jar</systemPath> | |
50 | + </dependency> | |
51 | + | |
52 | + <!-- 本例中数据转换使用到的jar,你用到的jar请写到这里,记得把artifactId填入后面的Embed-Dependency --> | |
53 | + <dependency> | |
54 | + <groupId>net.sf.json-lib</groupId> | |
55 | + <artifactId>json-lib</artifactId> | |
56 | + <version>2.4</version> | |
57 | + <classifier>jdk15</classifier> | |
58 | + </dependency> | |
59 | + | |
60 | + </dependencies> | |
61 | + <build> | |
62 | + <plugins> | |
63 | + <!-- 编码需要使用JDK1.8版本 --> | |
64 | + <plugin> | |
65 | + <groupId>org.apache.maven.plugins</groupId> | |
66 | + <artifactId>maven-compiler-plugin</artifactId> | |
67 | + <configuration> | |
68 | + <source>1.8</source> | |
69 | + <target>1.8</target> | |
70 | + </configuration> | |
71 | + </plugin> | |
72 | + <!-- OSGI规范打包配置 --> | |
73 | + <plugin> | |
74 | + <groupId>org.apache.felix</groupId> | |
75 | + <artifactId>maven-bundle-plugin</artifactId> | |
76 | + <version>${felix.maven.plugin.version}</version> | |
77 | + <extensions>true</extensions> | |
78 | + <configuration> | |
79 | + <buildDirectory>./target</buildDirectory> | |
80 | + <archive> | |
81 | + <addMavenDescriptor>false</addMavenDescriptor> | |
82 | + </archive> | |
83 | + <instructions> | |
84 | + <Bundle-RequiredExecutionEnvironment>J2SE-1.5</Bundle-RequiredExecutionEnvironment> | |
85 | + <Bundle-Activator></Bundle-Activator> | |
86 | + <Service-Component>OSGI-INF/*</Service-Component> | |
87 | + <!-- 请修改为你的编解码插件的名字,命名规范:设备类型-厂商ID-设备型号,例如:WaterMeter-Huawei-NBIoTDevice --> | |
88 | + <Bundle-SymbolicName>VehicleDetector-ZTEITS-ZTEITS</Bundle-SymbolicName> | |
89 | + <Export-Package></Export-Package> | |
90 | + <Import-Package> | |
91 | + org.slf4j, | |
92 | + org.slf4j.spi, | |
93 | + org.apache.log4j.spi, | |
94 | + com.huawei.m2m.cig.tup.modules.protocol_adapter, | |
95 | + com.fasterxml.jackson.databind, | |
96 | + com.fasterxml.jackson.databind.node | |
97 | + </Import-Package> | |
98 | + <!-- 除junit,slf4j-api,jackson-databind,protocal-jar, 其他所有的依赖包,必须把包对应的artifactId填入Embed-Dependency。artifactId之间以逗号分隔。 --> | |
99 | + <Embed-Dependency> | |
100 | + json-lib | |
101 | + </Embed-Dependency> | |
102 | + </instructions> | |
103 | + </configuration> | |
104 | + <executions> | |
105 | + <execution> | |
106 | + <id>generate-resource</id> | |
107 | + <goals> | |
108 | + <goal>manifest</goal> | |
109 | + </goals> | |
110 | + </execution> | |
111 | + </executions> | |
112 | + </plugin> | |
113 | + </plugins> | |
114 | + </build> | |
115 | +</project> | |
0 | 116 | \ No newline at end of file | ... | ... |
zteits-nbiot/src/main/java/com/zteits/nbiot/decoder/Utilty.java
0 → 100644
1 | +package com.zteits.nbiot.decoder; | |
2 | + | |
3 | + | |
4 | +import java.util.Arrays; | |
5 | + | |
6 | +public class Utilty { | |
7 | + | |
8 | + private static Utilty instance = new Utilty(); | |
9 | + | |
10 | + public static Utilty getInstance() { | |
11 | + return instance; | |
12 | + } | |
13 | + | |
14 | + public static final int MIN_MID_VALUE = 1; | |
15 | + | |
16 | + public static final int MAX_MID_VALUE = 65535; | |
17 | + | |
18 | + | |
19 | + public static int bytes2Int(byte[] b, int start, int length) { | |
20 | + int sum = 0; | |
21 | + int end = start + length; | |
22 | + for (int k = start; k < end; k++) { | |
23 | + int n = ((int) b[k]) & 0xff; | |
24 | + n <<= (--length) * 8; | |
25 | + sum += n; | |
26 | + } | |
27 | + return sum; | |
28 | + } | |
29 | + | |
30 | + public static byte[] int2Bytes(int value, int length) { | |
31 | + byte[] b = new byte[length]; | |
32 | + for (int k = 0; k < length; k++) { | |
33 | + b[length - k - 1] = (byte) ((value >> 8 * k) & 0xff); | |
34 | + } | |
35 | + return b; | |
36 | + } | |
37 | + | |
38 | + public boolean isValidofMid(int mId) { | |
39 | + if (mId < MIN_MID_VALUE || mId > MAX_MID_VALUE) { | |
40 | + return false; | |
41 | + } | |
42 | + return true; | |
43 | + } | |
44 | + | |
45 | + public static String parseByte2HexStr(byte[] buf) { | |
46 | + if (null == buf) { | |
47 | + return null; | |
48 | + } | |
49 | + | |
50 | + StringBuffer sb = new StringBuffer(); | |
51 | + for (int i = 0; i < buf.length; i++) { | |
52 | + String hex = Integer.toHexString(buf[i] & 0xFF); | |
53 | + if (hex.length() == 1) { | |
54 | + hex = '0' + hex; | |
55 | + } | |
56 | + sb.append(hex.toUpperCase()); | |
57 | + } | |
58 | + return sb.toString(); | |
59 | + } | |
60 | + /** | |
61 | + * 16进制转换成为integer | |
62 | + * @return | |
63 | + */ | |
64 | + public static Integer hexStringToInteger(byte[] original, int from, int to) { | |
65 | + String s = Utilty.parseByte2HexStr(Arrays.copyOfRange(original, from, to)); | |
66 | + return Integer.parseInt(s,16); | |
67 | + } | |
68 | + | |
69 | + /** | |
70 | + * 16进制转换成为string类型字符串 | |
71 | + * @return | |
72 | + */ | |
73 | + public static String hexStringToString(byte[] original, int from, int to) { | |
74 | + String s = Utilty.parseByte2HexStr(Arrays.copyOfRange(original, from, to)); | |
75 | + if (s == null || s.equals("")) { | |
76 | + return null; | |
77 | + } | |
78 | + s = s.replace(" ", ""); | |
79 | + byte[] baKeyword = new byte[s.length() / 2]; | |
80 | + for (int i = 0; i < baKeyword.length; i++) { | |
81 | + try { | |
82 | + baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16)); | |
83 | + } catch (Exception e) { | |
84 | + e.printStackTrace(); | |
85 | + } | |
86 | + } | |
87 | + try { | |
88 | + s = new String(baKeyword, "UTF-8"); | |
89 | + new String(); | |
90 | + } catch (Exception e1) { | |
91 | + e1.printStackTrace(); | |
92 | + } | |
93 | + return s; | |
94 | + } | |
95 | +} | ... | ... |
zteits-nbiot/src/main/java/com/zteits/nbiot/decoder/ZteitsCmdProcess.java
0 → 100644
1 | +package com.zteits.nbiot.decoder; | |
2 | + | |
3 | +import com.fasterxml.jackson.databind.JsonNode; | |
4 | +import com.fasterxml.jackson.databind.node.ObjectNode; | |
5 | + | |
6 | +import java.util.Arrays; | |
7 | +import java.util.Date; | |
8 | + | |
9 | +public class ZteitsCmdProcess { | |
10 | + | |
11 | + private String msgType = "cloudRsp"; | |
12 | + private String serviceId = "VehicleDetectorInfo"; | |
13 | + private String cmd = "SET_DEVICE_LEVEL"; | |
14 | + private int hasMore = 1; | |
15 | + //请求处理的结果码,0表示成功,1表示失败 | |
16 | + private int errcode = 1; | |
17 | + private int mid = 0; | |
18 | + private byte[] requests; | |
19 | + private JsonNode paras; | |
20 | + | |
21 | + | |
22 | + public ZteitsCmdProcess() { | |
23 | + } | |
24 | + | |
25 | + public ZteitsCmdProcess(ObjectNode input) { | |
26 | + | |
27 | + try { | |
28 | + this.msgType = input.get("msgType").asText(); | |
29 | + this.requests = input.get("request").binaryValue(); | |
30 | + /* | |
31 | + 平台收到设备上报消息,编码ACK | |
32 | + { | |
33 | + "msgType":"cloudRsp", | |
34 | + "request": ***,//设备上报的码流 | |
35 | + "errcode":0, | |
36 | + "hasMore":0 | |
37 | + } | |
38 | + * */ | |
39 | + if (msgType.equals("cloudRsp")) { | |
40 | + //在此组装ACK的值 | |
41 | + this.errcode = input.get("errcode").asInt(); | |
42 | + this.hasMore = input.get("hasMore").asInt(); | |
43 | + } | |
44 | + } catch (Exception e) { | |
45 | + this.errcode = 1; | |
46 | + e.printStackTrace(); | |
47 | + } | |
48 | + | |
49 | + } | |
50 | + | |
51 | + public byte[] toByte() { | |
52 | + try { | |
53 | + /* | |
54 | + 平台收到设备的上报数据,根据需要编码ACK,对设备进行响应,如果此处返回null,表示不需要对设备响应。 | |
55 | + * */ | |
56 | + if (this.msgType.equals("cloudRsp")) { | |
57 | + | |
58 | + byte[] ack = new byte[28]; | |
59 | + ack[0] = (byte) 0x77; | |
60 | + ack[1] = (byte)0x00; | |
61 | + //请求处理的结果码。 | |
62 | + //0表示成功,1表示失败 | |
63 | + if(errcode == 0){ | |
64 | + ack[2] = (byte)0x70; | |
65 | + }else if(errcode == 1){ | |
66 | + ack[2] = (byte)0x30; | |
67 | + } | |
68 | + //packCount 2H | |
69 | + ack[3] = requests[18]; | |
70 | + ack[4] = requests[19]; | |
71 | + //magId 4H | |
72 | + ack[5] = requests[22]; | |
73 | + ack[6] = requests[23]; | |
74 | + ack[7] = requests[24]; | |
75 | + ack[8] = requests[25]; | |
76 | + //command 2H | |
77 | + ack[9] = (byte)0x00; | |
78 | + ack[10] = (byte)0x00; | |
79 | + //时间8H | |
80 | + ack[11] = (byte)0x00; | |
81 | + ack[12] = (byte)0x00; | |
82 | + ack[13] = (byte)0x00; | |
83 | + ack[14] = (byte)0x00; | |
84 | + Long time = new Date().getTime()/1000; | |
85 | + byte[] timeByte = Utilty.int2Bytes(time.intValue(), 4); | |
86 | + ack[15] = timeByte[0]; | |
87 | + ack[16] = timeByte[1]; | |
88 | + ack[17] = timeByte[2]; | |
89 | + ack[18] = timeByte[3]; | |
90 | + | |
91 | + ack[19] = (byte)errcode; | |
92 | + ack[20] = (byte)0x00; | |
93 | + ack[21] = (byte)0x00; | |
94 | + ack[22] = (byte)0x00; | |
95 | + ack[23] = (byte)0x00; | |
96 | + ack[24] = (byte)0x00; | |
97 | + ack[25] = (byte)0x00; | |
98 | + return CRC16Util.appendCrc16(ack); | |
99 | + } | |
100 | + return null; | |
101 | + } catch (Exception e) { | |
102 | + e.printStackTrace(); | |
103 | + return null; | |
104 | + } | |
105 | + } | |
106 | + | |
107 | +} | ... | ... |
zteits-nbiot/src/main/resources/OSGI-INF/CodecProvideHandler.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="com.zteits.nbiot.decoder.ProtocolAdapterImpl"> | |
3 | + <implementation class="com.zteits.nbiot.decoder.ProtocolAdapterImpl"/> | |
4 | + <service> | |
5 | + <provide interface="com.huawei.m2m.cig.tup.modules.protocol_adapter.IProtocolAdapter" /> | |
6 | + </service> | |
7 | +</scr:component> | ... | ... |
zteits-nbiot/src/test/java/com/thrid/party/codec/demo/ProtocolServiceImplTest.java
0 → 100644
1 | +package com.thrid.party.codec.demo; | |
2 | + | |
3 | +import com.zteits.nbiot.decoder.ProtocolAdapterImpl; | |
4 | +import org.junit.Before; | |
5 | +import org.junit.Test; | |
6 | + | |
7 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
8 | +import com.fasterxml.jackson.databind.node.ObjectNode; | |
9 | +import com.huawei.m2m.cig.tup.modules.protocol_adapter.IProtocolAdapter; | |
10 | + | |
11 | +/** | |
12 | + * Unit test for simple App. | |
13 | + */ | |
14 | +public class ProtocolServiceImplTest { | |
15 | + | |
16 | + private IProtocolAdapter protocolAdapter; | |
17 | + | |
18 | + @Before | |
19 | + public void setProtocolAdapter() { | |
20 | + this.protocolAdapter = new ProtocolAdapterImpl(); | |
21 | + } | |
22 | + | |
23 | + /** | |
24 | + * 测试用例1:设备向平台上报数据。 | |
25 | + * <p> | |
26 | + * <pre> | |
27 | + * 设备上报数据:AA72000032088D0320623399 | |
28 | + * </pre> | |
29 | + * | |
30 | + * @throws Exception | |
31 | + */ | |
32 | + @Test | |
33 | + public void testDecodeDeviceReportData() throws Exception { | |
34 | + byte[] deviceReqByte = initDeviceReqByte(); | |
35 | + ObjectNode objectNode = protocolAdapter.decode(deviceReqByte); | |
36 | + String str = objectNode.toString(); | |
37 | + System.out.println(str); | |
38 | + } | |
39 | + | |
40 | + public static void main(String[] args) throws Exception { | |
41 | + IProtocolAdapter protocolAdapter = new ProtocolAdapterImpl(); | |
42 | + byte[] deviceReqByte = initDeviceReqByte(); | |
43 | + ObjectNode cloudRspObjectNode = initCloudRspObjectNode(deviceReqByte); | |
44 | + byte[] outputByte2 = protocolAdapter.encode(cloudRspObjectNode); | |
45 | + System.out.println("cloudRsp output:" + parseByte2HexStr(outputByte2)); | |
46 | + } | |
47 | + | |
48 | + /** | |
49 | + * 测试用例2:平台向设备下发控制命令: | |
50 | + * <p> | |
51 | + * <pre> | |
52 | + * { | |
53 | + * //"identifier": "123", | |
54 | + * "msgType": "cloudReq", | |
55 | + * "cmd": "SET_DEVICE_LEVEL", | |
56 | + * "mid": 2016, | |
57 | + * "paras": { "value": "10" }, | |
58 | + * "hasMore": 0 | |
59 | + * } | |
60 | + * </pre> | |
61 | + */ | |
62 | + @Test | |
63 | + public void testEncodeIoTSendCommand() throws Exception { | |
64 | + ObjectNode CloudReqObjectNode = initCloudReqObjectNode(); | |
65 | + byte[] outputByte = protocolAdapter.encode(CloudReqObjectNode); | |
66 | + System.out.println("cloudReq output:" + parseByte2HexStr(outputByte)); | |
67 | + } | |
68 | + | |
69 | + /** | |
70 | + * 测试用例3:设备对平台命令的应答消息 有命令短id | |
71 | + * <p> | |
72 | + * <pre> | |
73 | + * 设备应答消息:AA7201000107E0 | |
74 | + * | |
75 | + * <pre> | |
76 | + * | |
77 | + * @throws Exception | |
78 | + */ | |
79 | + @Test | |
80 | + public void testDecodeDeviceResponseIoT() throws Exception { | |
81 | + byte[] deviceRspByte = initDeviceRspByte(); | |
82 | + ObjectNode objectNode = protocolAdapter.decode(deviceRspByte); | |
83 | + String str = objectNode.toString(); | |
84 | + System.out.println(str); | |
85 | + } | |
86 | + | |
87 | + /** | |
88 | + * 测试用例4:平台收到设备的上报数据后对设备的应答,如果不需要应答则返回null即可 | |
89 | + * <pre> | |
90 | + * { | |
91 | + * "identifier": "0", | |
92 | + * "msgType": "cloudRsp", | |
93 | + * "request": [AA,72,00,00,32,08,8D,03,20,62,33,99], | |
94 | + * "errcode": 0, | |
95 | + * "hasMore": 0 | |
96 | + * } | |
97 | + * | |
98 | + * <pre> | |
99 | + * | |
100 | + * @throws Exception | |
101 | + */ | |
102 | + @Test | |
103 | + public void testEncodeIoTResponseDevice() throws Exception { | |
104 | + byte[] deviceReqByte = initDeviceReqByte(); | |
105 | + ObjectNode cloudRspObjectNode = initCloudRspObjectNode(deviceReqByte); | |
106 | + byte[] outputByte2 = protocolAdapter.encode(cloudRspObjectNode); | |
107 | + System.out.println("cloudRsp output:" + parseByte2HexStr(outputByte2)); | |
108 | + } | |
109 | + | |
110 | + public static String parseByte2HexStr(byte[] buf) { | |
111 | + if (null == buf) { | |
112 | + return null; | |
113 | + } | |
114 | + | |
115 | + StringBuffer sb = new StringBuffer(); | |
116 | + for (int i = 0; i < buf.length; i++) { | |
117 | + String hex = Integer.toHexString(buf[i] & 0xFF); | |
118 | + if (hex.length() == 1) { | |
119 | + hex = '0' + hex; | |
120 | + } | |
121 | + sb.append(hex.toUpperCase()); | |
122 | + } | |
123 | + return sb.toString(); | |
124 | + } | |
125 | + | |
126 | + /* | |
127 | + * 初始化:设备数据上报码流 | |
128 | + */ | |
129 | + private static byte[] initDeviceReqByte() { | |
130 | + /** | |
131 | + * 本例入参: 57 58 48 53 50 5F 4D 44 21 00 00 00 00 5A 9E 68 42 01 00 01 0B B8 | |
132 | + 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 | |
133 | + */ | |
134 | + byte[] byteDeviceReq = new byte[60]; | |
135 | + | |
136 | + | |
137 | + | |
138 | + byteDeviceReq[0] = (byte) 0x57; | |
139 | + byteDeviceReq[1] = (byte) 0x58; | |
140 | + byteDeviceReq[2] = (byte) 0x48; | |
141 | + byteDeviceReq[3] = (byte) 0x53; | |
142 | + | |
143 | + byteDeviceReq[4] = (byte) 0x50; | |
144 | + byteDeviceReq[5] = (byte) 0x5F; | |
145 | + byteDeviceReq[6] = (byte) 0x4D; | |
146 | + byteDeviceReq[7] = (byte) 0x44; | |
147 | + | |
148 | + byteDeviceReq[8] = (byte) 0x21; | |
149 | + | |
150 | + byteDeviceReq[9] = (byte) 0x00; | |
151 | + | |
152 | + byteDeviceReq[10] = (byte) 0x00; | |
153 | + byteDeviceReq[11] = (byte) 0x00; | |
154 | + byteDeviceReq[12] = (byte) 0x00; | |
155 | + | |
156 | + byteDeviceReq[13] = (byte) 0x5A; | |
157 | + byteDeviceReq[14] = (byte) 0x9E; | |
158 | + byteDeviceReq[15] = (byte) 0x68; | |
159 | + byteDeviceReq[16] = (byte) 0x42; | |
160 | + byteDeviceReq[17] = (byte) 0x01; | |
161 | + | |
162 | + byteDeviceReq[18] = (byte) 0x00; | |
163 | + byteDeviceReq[19] = (byte) 0x01; | |
164 | + byteDeviceReq[20] = (byte) 0x0B; | |
165 | + byteDeviceReq[21] = (byte) 0xB8; | |
166 | + byteDeviceReq[22] = (byte) 0x01; | |
167 | + byteDeviceReq[23] = (byte) 0x13; | |
168 | + byteDeviceReq[24] = (byte) 0x1D; | |
169 | + byteDeviceReq[25] = (byte) 0xB1; | |
170 | + byteDeviceReq[26] = (byte) 0x12; | |
171 | + byteDeviceReq[27] = (byte) 0x00; | |
172 | + byteDeviceReq[28] = (byte) 0x14; | |
173 | + byteDeviceReq[29] = (byte) 0x00; | |
174 | + byteDeviceReq[30] = (byte) 0x1E; | |
175 | + byteDeviceReq[31] = (byte) 0x00; | |
176 | + byteDeviceReq[32] = (byte) 0x0F; | |
177 | + | |
178 | + byteDeviceReq[33] = (byte) 0x04; | |
179 | + byteDeviceReq[34] = (byte) 0x00; | |
180 | + byteDeviceReq[35] = (byte) 0x00; | |
181 | + byteDeviceReq[36] = (byte) 0x01; | |
182 | + byteDeviceReq[37] = (byte) 0x00; | |
183 | + byteDeviceReq[38] = (byte) 0x00; | |
184 | + byteDeviceReq[39] = (byte) 0x02; | |
185 | + byteDeviceReq[40] = (byte) 0x00; | |
186 | + byteDeviceReq[41] = (byte) 0x05; | |
187 | + byteDeviceReq[42] = (byte) 0x00; | |
188 | + byteDeviceReq[43] = (byte) 0x0A; | |
189 | + byteDeviceReq[44] = (byte) 0x00; | |
190 | + byteDeviceReq[45] = (byte) 0x0F; | |
191 | + byteDeviceReq[46] = (byte) 0x00; | |
192 | + byteDeviceReq[47] = (byte) 0x00; | |
193 | + byteDeviceReq[48] = (byte) 0x00; | |
194 | + byteDeviceReq[49] = (byte) 0x00; | |
195 | + byteDeviceReq[50] = (byte) 0x00; | |
196 | + byteDeviceReq[51] = (byte) 0x00; | |
197 | + byteDeviceReq[52] = (byte) 0x00; | |
198 | + byteDeviceReq[53] = (byte) 0x00; | |
199 | + byteDeviceReq[54] = (byte) 0x00; | |
200 | + byteDeviceReq[55] = (byte) 0x00; | |
201 | + byteDeviceReq[56] = (byte) 0x00; | |
202 | + byteDeviceReq[57] = (byte) 0x00; | |
203 | + byteDeviceReq[58] = (byte) 0x27; | |
204 | + byteDeviceReq[59] = (byte) 0x8F; | |
205 | + | |
206 | + | |
207 | + | |
208 | + return byteDeviceReq; | |
209 | + } | |
210 | + | |
211 | + /* | |
212 | + * 初始化:平台向设备命令下发数据 | |
213 | + */ | |
214 | + private static ObjectNode initCloudReqObjectNode() { | |
215 | + ObjectMapper mapper = new ObjectMapper(); | |
216 | + ObjectNode cloudReqObjectNode = mapper.createObjectNode(); | |
217 | + ObjectNode paras = mapper.createObjectNode(); | |
218 | + paras.put("value", "10"); | |
219 | + cloudReqObjectNode.put("identifier", "123"); | |
220 | + cloudReqObjectNode.put("msgType", "cloudReq"); | |
221 | + cloudReqObjectNode.put("cmd", "SET_DEVICE_LEVEL"); | |
222 | + cloudReqObjectNode.put("paras", paras); | |
223 | + cloudReqObjectNode.put("hasMore", 0); | |
224 | + cloudReqObjectNode.put("mid", 2016); | |
225 | + return cloudReqObjectNode; | |
226 | + } | |
227 | + | |
228 | + /* | |
229 | + * 初始化:设备对平台的响应码流 | |
230 | + */ | |
231 | + private static byte[] initDeviceRspByte() { | |
232 | + /* | |
233 | + * 测试用例:有命令短mid 设备应答消息:AA7201000107E0 | |
234 | + */ | |
235 | + byte[] byteDeviceRsp = new byte[12]; | |
236 | + byteDeviceRsp[0] = (byte) 0xAA; | |
237 | + byteDeviceRsp[1] = (byte) 0x72; | |
238 | + byteDeviceRsp[2] = (byte) 0x01; | |
239 | + byteDeviceRsp[3] = (byte) 0x00; | |
240 | + byteDeviceRsp[4] = (byte) 0x01; | |
241 | + byteDeviceRsp[5] = (byte) 0x07; | |
242 | + byteDeviceRsp[6] = (byte) 0xE0; | |
243 | + return byteDeviceRsp; | |
244 | + } | |
245 | + | |
246 | + /* | |
247 | + * 初始化:平台对设备的应答数据 | |
248 | + */ | |
249 | + private static ObjectNode initCloudRspObjectNode(byte[] device2CloudByte) { | |
250 | + | |
251 | + ObjectMapper mapper = new ObjectMapper(); | |
252 | + ObjectNode cloudRspObjectNode = mapper.createObjectNode(); | |
253 | + cloudRspObjectNode.put("msgType", "cloudRsp"); | |
254 | + // 设备上报的码流 | |
255 | + cloudRspObjectNode.put("request", device2CloudByte); | |
256 | + cloudRspObjectNode.put("errcode", 0); | |
257 | + cloudRspObjectNode.put("hasMore", 0); | |
258 | + return cloudRspObjectNode; | |
259 | + } | |
260 | +} | ... | ... |