服務(wù)器
服務(wù)器搭建在
?http://172.93.46.196:8300
頁面菜單點(diǎn)擊【更新】
或者通過鏈接?
http://172.93.46.196:8300/update?
可以訪問最新的10條記錄的頁面?

WEB API
http://172.93.46.196:8300/addRecords
以Post方法向服務(wù)器提交json數(shù)據(jù)
json數(shù)據(jù)格式
{"time":"12:03","freq":14.853,"ultrasound":0.17,"energy":0.10,"power":0.946,"count":1860,"status":true}
Socket 模擬Http訪問
String postParams = "{\"time\":\"12:05\",\"freq\":14.853,\"ultrasound\":0.17,\"energy\":0.10,\"power\":0.946,\"count\":1860,\"status\":true}";
//上面java雙引號需要斜線轉(zhuǎn)義
int paramsLen = postParams.length();
StringBuffer post = new StringBuffer(512);
post.append("POST /addRecords HTTP/1.1\r\n");
post.append("Host: 172.93.46.196\r\n");
post.append("Accept: text/html\r\n");
post.append("Connection: Close\r\n");
post.append("Content-Length: " + paramsLen + "\r\n");
post.append("Content-Type: application/json\r\n");
post.append("\r\n");
post.append(postParams);
Socket socket = new Socket("172.93.46.196", 8300);
PrintWriter outWriter = new PrintWriter(socket.getOutputStream());
outWriter.println(post);
outWriter.flush();