Ver Fonte

ota:update converter.js

荭琪枫 há 2 anos atrás
pai
commit
92f63efb47

+ 4 - 1
data/converters/6260396d67aced2696184053/converter.js

@@ -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) {
     }
 
 
-};
+};

+ 1 - 1
iot-components/iot-mqtt-component/src/main/resources/convert.js

@@ -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,

+ 6 - 0
iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/OtaController.java

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

+ 15 - 0
iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/OtaService.java

@@ -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);
+    }
+
 }