Selaa lähdekoodia

发送报文没有转义的问题

develop
bin 3 vuotta sitten
vanhempi
commit
bb2eca7ead
3 muutettua tiedostoa jossa 7 lisäystä ja 2 poistoa
  1. +4
    -1
      src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java
  2. +2
    -0
      src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java
  3. +1
    -1
      src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java

+ 4
- 1
src/main/java/com/ssjl/zhaobiao/guizhou/controller/IotController.java Näytä tiedosto

@@ -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 + "激活设备");


+ 2
- 0
src/main/java/com/ssjl/zhaobiao/guizhou/utils/GZHttpUtil.java Näytä tiedosto

@@ -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;


+ 1
- 1
src/test/java/com/ssjl/zhaobiao/guizhou/CenterApplicationTests.java Näytä tiedosto

@@ -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));
}


Loading…
Peruuta
Tallenna