调整时间通知为每秒
新增wifi设备连入退出判断 为下发开门指令做准备
This commit is contained in:
@@ -19,7 +19,7 @@ public class ApplicationInit implements ApplicationRunner {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
String time = new SimpleDateFormat("HH:mm").format(new Date());
|
||||
String time = new SimpleDateFormat("HH:mm:ss").format(new Date());
|
||||
if (time.equals(oldTime)) {
|
||||
return;
|
||||
}
|
||||
@@ -36,6 +36,6 @@ public class ApplicationInit implements ApplicationRunner {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
},0, 35 * 1000);
|
||||
},0, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.yutou.qqbot.interfaces.DownloadInterface;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.net.*;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -102,11 +99,8 @@ public class HttpTools {
|
||||
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36";
|
||||
}
|
||||
|
||||
private static String getKuKuUA() {
|
||||
return "/KUKU_APP(Android/#/cn.kuku.sdk/ttsdk17228/29401/A-2.9.4.01.KUSDK/868139039134314/fcddf839c8c135fa/F4:60:E2:AB:25:1A/460019406520644/+8618569400341/#/9/Redmi 6 Pro/xiaomi/1736/76fda4d6-cd6b-485f-987b-8d347b007f24/#/KUKU/Native/92972ea9651fbd2e)";
|
||||
}
|
||||
|
||||
public String toUrlParams(JSONObject json) {
|
||||
public static String toUrlParams(JSONObject json) {
|
||||
StringBuilder string = new StringBuilder();
|
||||
Set<String> keys = json.keySet();
|
||||
for (String key : keys) {
|
||||
@@ -257,4 +251,24 @@ public class HttpTools {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static String getLocalMacAddress(){
|
||||
try {
|
||||
InetAddress address=InetAddress.getLocalHost();
|
||||
byte[] bytes=NetworkInterface.getByInetAddress(address).getHardwareAddress();
|
||||
StringBuilder builder=new StringBuilder();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
if (i != 0) {
|
||||
builder.append(":");
|
||||
}
|
||||
String tmp=Integer.toHexString(bytes[i]&0xFF);
|
||||
builder.append(tmp.length()==1?0+tmp:tmp);
|
||||
|
||||
}
|
||||
return builder.toString();
|
||||
} catch (UnknownHostException | java.net.SocketException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class RedisTools {
|
||||
Jedis jedis = getRedis();
|
||||
jedis.select(dbIndex);
|
||||
String ret = jedis.set(key, value);
|
||||
Log.i("Redis set =" + ret,"key = "+key+" value = "+value);
|
||||
//Log.i("Redis set =" + ret,"key = "+key+" value = "+value);
|
||||
jedis.close();
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
|
||||
40
src/main/java/com/yutou/qqbot/utlis/XiaoMiRouter.java
Normal file
40
src/main/java/com/yutou/qqbot/utlis/XiaoMiRouter.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.yutou.qqbot.utlis;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
public class XiaoMiRouter {
|
||||
private final static String key = "a2ffa5c9be07488bbb04a3a47d3c5f6a";
|
||||
|
||||
public static String getToken() {
|
||||
String nonce = nonceCreat();
|
||||
String oldPwd = DigestUtils.sha1Hex(nonce + DigestUtils.sha1Hex("34864394" + key));
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("username", "admin");
|
||||
json.put("password", oldPwd);
|
||||
json.put("logtype", 2);
|
||||
json.put("nonce", nonce);
|
||||
json = JSONObject.parseObject(HttpTools.http_post("http://192.168.31.1/cgi-bin/luci/api/xqsystem/login", HttpTools.toUrlParams(json).getBytes(StandardCharsets.UTF_8), 1, null));
|
||||
if (json.getInteger("code") == 0) {
|
||||
return json.getString("token");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getDeviceListUrl() {
|
||||
return "http://192.168.31.1/cgi-bin/luci/;stok=" + getToken() + "/api/misystem/devicelist";
|
||||
}
|
||||
|
||||
private static String nonceCreat() {
|
||||
return String.format("%s_%s_%s_%s", 0, HttpTools.getLocalMacAddress(), (int) (System.currentTimeMillis() / 1000), (int) (Math.random() * 10000));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user