feat:【IoT 物联网】实现 OTA 升级推送任务 IotOtaUpgradeJob

This commit is contained in:
YunaiV
2025-07-04 00:05:38 +08:00
parent 14cbdad374
commit af1f993a4f
8 changed files with 168 additions and 2 deletions

View File

@@ -42,6 +42,10 @@ public enum IotDeviceMessageMethodEnum implements ArrayValuable<String> {
CONFIG_PUSH("thing.config.push", "配置推送", true),
// ========== OTA 固件 ==========
OTA_UPGRADE("thing.ota.upgrade", "OTA 推送固定信息", false),
OTA_PROGRESS("thing.ota.progress", "OTA 上报升级进度", true),
;
public static final String[] ARRAYS = Arrays.stream(values()).map(IotDeviceMessageMethodEnum::getMethod)

View File

@@ -39,4 +39,8 @@ public enum IotDeviceStateEnum implements ArrayValuable<Integer> {
return ONLINE.getState().equals(state);
}
public static boolean isNotOnline(Integer state) {
return !isOnline(state);
}
}

View File

@@ -140,4 +140,12 @@ public class IotDeviceMessage {
MapUtil.of("state", IotDeviceStateEnum.OFFLINE.getState()));
}
public static IotDeviceMessage buildOtaUpgrade(String version, String fileUrl, Long fileSize,
String fileDigestAlgorithm, String fileDigestValue) {
return requestOf(IotDeviceMessageMethodEnum.OTA_UPGRADE.getMethod(), MapUtil.builder()
.put("version", version).put("fileUrl", fileUrl).put("fileSize", fileSize)
.put("fileDigestAlgorithm", fileDigestAlgorithm).put("fileDigestValue", fileDigestValue)
.build());
}
}