离线情况处理,快速响应
This commit is contained in:
parent
4d29635648
commit
1f0768c69e
|
@ -263,7 +263,8 @@ public class IotServiceImpl implements IotService {
|
|||
private CommandResponse sendCommand(IotDevice device, String command, String reason, int tryCount) {
|
||||
if (tryCount > 0) {
|
||||
CommandResponse res = sendCommand(device, command, null, reason);
|
||||
if (IotUtil.isSuccess(res) || tryCount <= 1) {
|
||||
// 若操作成功 or 设备离线 or 尝试次数小于等于1,则直接返回结果
|
||||
if (IotUtil.isSuccess(res) || IotUtil.isOffline(res) || tryCount <= 1) {
|
||||
return res;
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -211,6 +211,13 @@ public class IotUtil {
|
|||
return result.isSuccess();
|
||||
}
|
||||
|
||||
public static boolean isOffline(CommandResponse result) {
|
||||
if (result == null) {
|
||||
return false;
|
||||
}
|
||||
return result.isNotOnline();
|
||||
}
|
||||
|
||||
public static String getMsg(CommandResponse result) {
|
||||
if (result == null) {
|
||||
return "未知错误";
|
||||
|
|
Loading…
Reference in New Issue
Block a user