Quellcode durchsuchen

发送报文没有转义的问题

develop
bin vor 3 Jahren
Ursprung
Commit
bb2eca7ead
3 geänderte Dateien mit 7 neuen und 2 gelöschten Zeilen
  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 Datei anzeigen

@@ -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 Datei anzeigen

@@ -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 Datei anzeigen

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


Laden…
Abbrechen
Speichern