|
|
@ -12,6 +12,7 @@ import java.io.IOException; |
|
|
|
import java.text.DecimalFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@Service |
|
|
@ -57,9 +58,11 @@ public class SerialServiceImpl implements SerialService { |
|
|
|
System.out.println("打开串口" + serial_com); |
|
|
|
|
|
|
|
//lora初始化话
|
|
|
|
initLora(openSerial); |
|
|
|
// initLora(openSerial);
|
|
|
|
//上报数据
|
|
|
|
sendData(openSerial); |
|
|
|
// sendData(openSerial);
|
|
|
|
//测试足底
|
|
|
|
sendPelmaData(openSerial); |
|
|
|
} catch (Exception e) { |
|
|
|
System.out.println(e.getMessage()); |
|
|
|
} |
|
|
@ -206,6 +209,39 @@ public class SerialServiceImpl implements SerialService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 上传数据 |
|
|
|
* @param openSerial |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void sendPelmaData(SerialPort openSerial) throws Exception { |
|
|
|
System.out.println("开始读取数据"); |
|
|
|
while (true){ |
|
|
|
String res_ack = joinData(openSerial); |
|
|
|
if (res_ack != null ){ |
|
|
|
try { |
|
|
|
PelmaDataAcceptImpl pelmaDataAccept = new PelmaDataAcceptImpl(); |
|
|
|
pelmaDataAccept.handle(res_ack); |
|
|
|
// String send_data = res_ack.substring(6, res_ack.length() - 2);
|
|
|
|
// RestTemplate restTemplate = new RestTemplate();
|
|
|
|
// System.out.println(send_data);
|
|
|
|
//
|
|
|
|
// HashMap<String, String> map = new HashMap<>();
|
|
|
|
// map.put("pelma", send_data);
|
|
|
|
// map.put("device", "1");
|
|
|
|
// map.put("type", "1");
|
|
|
|
//
|
|
|
|
// String url = pelma_url + "/storePelma";
|
|
|
|
// String res = restTemplate.postForObject(url, map, String.class);
|
|
|
|
// System.out.println(res);
|
|
|
|
} catch (Exception e){ |
|
|
|
System.out.println(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 拼接命令 |
|
|
|