ota:update converter.js

V0.5.x
荭琪枫 2023-07-06 23:20:55 +08:00
parent 2f1717d629
commit 92f63efb47
4 changed files with 26 additions and 2 deletions

View File

@ -154,6 +154,9 @@ this.encode = function (service, device) {
} else if (type == "service") {
method += identifier;
topic += identifier;
} else if (type == "ota") {
method += identifier;
topic = "/ota/device/upgrade/" + service.productKey + "/" + service.deviceName;
} else if (type == "config") {
//设备配置下发
method += identifier;
@ -202,4 +205,4 @@ this.encode = function (service, device) {
}
};
};

View File

@ -38,7 +38,7 @@ this.decode = function (msg) {
time: new Date().getTime(), //时间戳,消息上报时间
data: payload.params,
};
} else if (topic.indexOf("/ota/") > 0) {
} else if (topic.indexOf("/ota/") >= 0) {
//事件上报
return {
mid: msg.mid,

View File

@ -79,4 +79,10 @@ public class OtaController {
return otaService.otaResult(request);
}
@ApiOperation("ota升级测试")
@PostMapping("/testStartUpgrade")
public void testStartUpgrade(@RequestBody Request<Void> request) {
otaService.testStartUpgrade();
}
}

View File

@ -125,4 +125,19 @@ public class OtaService {
return deviceOtaInfoData.findAll(request.to(DeviceOtaInfo.class)).to(DeviceOtaInfoVo.class);
}
public void testStartUpgrade() {
String deviceId = "16885697173790test100001230000123";
OtaPackage otaPackage = OtaPackage.builder()
.createAt(System.currentTimeMillis())
.desc("升级测试")
.md5("AAAABCC")
.sign("AAAAAAAA")
.isDiff(false)
.size(1024L)
.url("http://www.baidu.com/resource/test.jpg")
.version("1.2.1")
.build();
deviceService.otaUpgrade(deviceId, true, otaPackage);
}
}