Ver Fonte

update:修改关于三元组存储kv区的if判断的位置

zhaihaoyu há 2 anos atrás
pai
commit
7aabc6bbbd
1 ficheiros alterados com 5 adições e 6 exclusões
  1. 5 6
      demo/aliyun/main.lua

+ 5 - 6
demo/aliyun/main.lua

@@ -111,10 +111,14 @@ local function connectCbFnc(result)
         local cid = fskv.get("clientid")
         --储存到kv分区的返回值
         -- log.info("kv分区的返回值",used,total,cid)
-
         local Secret = aliyun.getDeviceSecret()
         local Token = aliyun.getDeviceToken()
         local Clid = aliyun.getClientid()
+        --如果三元组不为空,就把三元组写入到kv区
+        if tPara.DeviceName and tPara.ProductKey then
+            fskv.set("DeviceName",tPara.DeviceName)
+            fskv.set("ProductKey",tPara.ProductKey)
+        end
         if not tPara.Registration then
             if Secret == nil then
                 log.info("掉电重连")
@@ -146,11 +150,6 @@ sys.taskInit(function()
     sys.wait(500)
     log.info("已联网", "开始初始化aliyun库")
     fskv.init()
-    --如果三元组不为空,就把三元组写入到kv区
-    if not tPara.DeviceName and not tPara.ProductKey then
-        fskv.set("DeviceName",tPara.DeviceName)
-        fskv.set("ProductKey",tPara.ProductKey)
-    end
     local name = fskv.get("DeviceName")
     local key = fskv.get("ProductKey")
     local used = fskv.get("deviceSecret")