瀏覽代碼

add 添加设备属性设置

jay 2 年之前
父節點
當前提交
26d48a890f

+ 26 - 5
data/converters/6260396d67aced2696184053/converter.js

@@ -109,7 +109,7 @@ this.encode = function (service,device) {
   var method="thing.service.";
   var topic="/sys/"+service.productKey+"/"+service.deviceName+"/c/service/";
   var params={};
-  
+
   //透传下发
   if(device.transparent){
 	var rst=component.transparentEncode(service,device);
@@ -152,12 +152,29 @@ this.encode = function (service,device) {
 	method+=identifier;
 	topic="/sys/"+service.productKey+"/"+service.deviceName+"/c/deregister";
   }
-  
-  for(var p in service.params){
+  if(type=="property" && identifier=="get"  ){
+	var listParams = []
+	for(var p in service.params){
+	listParams.push(service.params[p]);
+  }
+	return {
+	productKey:service.productKey,
+	deviceName:service.deviceName,
+	mid:deviceMid,
+	content:{
+	  topic:topic,
+	  payload:JSON.stringify({
+		id:deviceMid,
+		method:method,
+		params: listParams
+	  })
+	}
+  }
+  }else{
+   for(var p in service.params){
 	params[p]=service.params[p];
   }
-  
-  return {
+	return {
 	productKey:service.productKey,
 	deviceName:service.deviceName,
 	mid:deviceMid,
@@ -170,4 +187,8 @@ this.encode = function (service,device) {
 	  })
 	}
   }
+
+  }
+ 
+  
 };

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

@@ -152,22 +152,43 @@ this.encode = function (service,device) {
         method+=identifier;
         topic="/sys/"+service.productKey+"/"+service.deviceName+"/c/deregister";
     }
+    if(type=="property" && identifier=="get"  ){
+        var listParams = []
+        for(var p in service.params){
+            listParams.push(service.params[p]);
+        }
+        return {
+            productKey:service.productKey,
+            deviceName:service.deviceName,
+            mid:deviceMid,
+            content:{
+                topic:topic,
+                payload:JSON.stringify({
+                    id:deviceMid,
+                    method:method,
+                    params: listParams
+                })
+            }
+        }
+    }else{
+        for(var p in service.params){
+            params[p]=service.params[p];
+        }
+        return {
+            productKey:service.productKey,
+            deviceName:service.deviceName,
+            mid:deviceMid,
+            content:{
+                topic:topic,
+                payload:JSON.stringify({
+                    id:deviceMid,
+                    method:method,
+                    params:params
+                })
+            }
+        }
 
-    for(var p in service.params){
-        params[p]=service.params[p];
     }
 
-    return {
-        productKey:service.productKey,
-        deviceName:service.deviceName,
-        mid:deviceMid,
-        content:{
-            topic:topic,
-            payload:JSON.stringify({
-                id:deviceMid,
-                method:method,
-                params:params
-            })
-        }
-    }
-};
+
+};