diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java b/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java index 7b254c7..04df23e 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java @@ -144,8 +144,11 @@ public class IotController { req.setIndex(GZUtil.getMessageIndex()); req.setStatus(GZRequestStatus.RESPONSE_ALL); req.setContent(askLocation); +// System.out.println(ByteUtil.bytesToHexString(req.toByte())); + log.info(imei + ",上报开机信息," + ByteUtil.bytesToHexString(req.toByte())); byte[] res = httpUtil.send(imei, "", req); - System.out.println(ByteUtil.bytesToHexString(res)); + log.info(imei + ",上报开机信息返回," + ByteUtil.bytesToHexString(res)); +// System.out.println(ByteUtil.bytesToHexString(res)); // 调用IOTAPI激活设备 log.info(imei + "激活设备"); diff --git a/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java b/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java index 866a912..33d9081 100644 --- a/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java +++ b/src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java @@ -23,6 +23,7 @@ public class GZHttpUtil { public byte[] send(String imei, String phone, GZRequest req) throws IOException { Headers headers = new Headers.Builder().add("meid-id", imei).add("imsi-id", phone).build(); byte[] b = req.toByte(); + b = GZUtil.encode(b); try { byte[] res = httpUtil.postBytes(url, b, headers); return res; @@ -45,6 +46,7 @@ public class GZHttpUtil { public byte[] send(String imei, String phone, GZResponse req) throws IOException { Headers headers = new Headers.Builder().add("meid-id", imei).add("imsi-id", phone).build(); byte[] b = req.toBytes(); + b = GZUtil.encode(b); try { byte[] res = httpUtil.postBytes(url, b, headers); return res; diff --git a/src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java b/src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java index 576887d..fe709de 100644 --- a/src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java +++ b/src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java @@ -187,7 +187,7 @@ class CenterApplicationTests { } @Test public void test2(){ - String str = "52303432363131353031313b543b555430312e343b565450453430313b5874656c706f3b5931383636343237323734333b5a5450453339302c50434241302e32412e4431302c41492e302e302e322e443130"; + String str = "6572726f72206c656e"; byte[] b = ByteUtil.hexToByteArray(str); System.out.println(new String(b)); }