Commit a8bd4079 authored by zhushanglei's avatar zhushanglei

init

parent fffed4bb
......@@ -81,19 +81,20 @@ public class TcpServer {
InetAddress addr = InetAddress.getLocalHost();
logger.info("Local HostAddress:"+addr.getHostAddress());
String hostname = addr.getHostName();
byte[] mac = NetworkInterface.getByInetAddress(addr).getHardwareAddress();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < mac.length; i++) {
if (i != 0) {
sb.append("-");
}
// mac[i] & 0xFF 是为了把byte转化为正整数
String s = Integer.toHexString(mac[i] & 0xFF);
sb.append(s.length() == 1 ? 0 + s : s);
}
deviceId = sb.toString();
logger.info("mac: "+sb.toString());
// byte[] mac = NetworkInterface.getByInetAddress(addr).getHardwareAddress();
//
// StringBuffer sb = new StringBuffer();
// for (int i = 0; i < mac.length; i++) {
// if (i != 0) {
// sb.append("-");
// }
// // mac[i] & 0xFF 是为了把byte转化为正整数
// String s = Integer.toHexString(mac[i] & 0xFF);
// sb.append(s.length() == 1 ? 0 + s : s);
// }
// deviceId = sb.toString();
// logger.info("mac: "+sb.toString());
deviceId = hostname;
logger.info("Local host name: "+hostname);
b.bind(addr.getHostAddress(), PORT).sync();
// b.bind(IP, PORT).sync();
......
serverUrl:http://192.168.0.111:8001/gps
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment