@@ -144,8 +144,11 @@ public class IotController { | |||||
req.setIndex(GZUtil.getMessageIndex()); | req.setIndex(GZUtil.getMessageIndex()); | ||||
req.setStatus(GZRequestStatus.RESPONSE_ALL); | req.setStatus(GZRequestStatus.RESPONSE_ALL); | ||||
req.setContent(askLocation); | req.setContent(askLocation); | ||||
// System.out.println(ByteUtil.bytesToHexString(req.toByte())); | |||||
log.info(imei + ",上报开机信息," + ByteUtil.bytesToHexString(req.toByte())); | |||||
byte[] res = httpUtil.send(imei, "", req); | 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激活设备 | // 调用IOTAPI激活设备 | ||||
log.info(imei + "激活设备"); | log.info(imei + "激活设备"); | ||||
@@ -23,6 +23,7 @@ public class GZHttpUtil { | |||||
public byte[] send(String imei, String phone, GZRequest req) throws IOException { | 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(); | Headers headers = new Headers.Builder().add("meid-id", imei).add("imsi-id", phone).build(); | ||||
byte[] b = req.toByte(); | byte[] b = req.toByte(); | ||||
b = GZUtil.encode(b); | |||||
try { | try { | ||||
byte[] res = httpUtil.postBytes(url, b, headers); | byte[] res = httpUtil.postBytes(url, b, headers); | ||||
return res; | return res; | ||||
@@ -45,6 +46,7 @@ public class GZHttpUtil { | |||||
public byte[] send(String imei, String phone, GZResponse req) throws IOException { | 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(); | Headers headers = new Headers.Builder().add("meid-id", imei).add("imsi-id", phone).build(); | ||||
byte[] b = req.toBytes(); | byte[] b = req.toBytes(); | ||||
b = GZUtil.encode(b); | |||||
try { | try { | ||||
byte[] res = httpUtil.postBytes(url, b, headers); | byte[] res = httpUtil.postBytes(url, b, headers); | ||||
return res; | return res; | ||||
@@ -187,7 +187,7 @@ class CenterApplicationTests { | |||||
} | } | ||||
@Test | @Test | ||||
public void test2(){ | public void test2(){ | ||||
String str = "52303432363131353031313b543b555430312e343b565450453430313b5874656c706f3b5931383636343237323734333b5a5450453339302c50434241302e32412e4431302c41492e302e302e322e443130"; | |||||
String str = "6572726f72206c656e"; | |||||
byte[] b = ByteUtil.hexToByteArray(str); | byte[] b = ByteUtil.hexToByteArray(str); | ||||
System.out.println(new String(b)); | System.out.println(new String(b)); | ||||
} | } | ||||