国内综合精彩aⅤ无码不卡_日本少妇做爰全过程_欧美性爱在线播放免费_午夜?V日韩一区二区_免费a级毛片无码免费播放_成在人线av无码喷水_亚洲精品网站色视频_国产婷婷精品成人_老师撩起裙子让我桶的视频_秋霞影院国产

8266+天貓精靈窗簾開(kāi)度控制心得,有需要的可以看看

作者:情.若隔至千里 | 更新時(shí)間:2019-04-06 | 瀏覽量:3716

以下是部分代碼,官方示例里面的,加粗部分是自己搞出來(lái)的。

local function run()
  local cu = net.createConnection(net.TCP)
  cu:on("receive", function(cu, c) 
    print(c)
    isConnect = true
    r = cjson.decode(c)
    if r.M == "say" then
       
        s=r.C                                                       --把接收到天貓精靈的數(shù)據(jù)"C"后面的字符串賦值給s
        date = "%d%d"                                      --匹配需要提出開(kāi)度的數(shù)據(jù)格式
        hh=string.sub(s, string.find(s, date))   --取出字符串s里面的數(shù)字,也就是我們最終需要的開(kāi)度,比如25%,30%,取出來(lái)的數(shù)據(jù)還是string型,并非int型

        
      if hh=="25" then  
        gpio.write(LED, gpio.LOW)  
        ok, played = pcall(cjson.encode, {M="say",ID=r.ID,C="LED turn on!"})
        cu:send( played.."\n" )
      end
      if r.C == "stop" then   
        gpio.write(LED, gpio.HIGH)
        ok, stoped = pcall(cjson.encode, {M="say",ID=r.ID,C="LED turn off!"})
        cu:send( stoped.."\n" ) 
      end
       
    end
  end)


評(píng)論:共2條

douzs 評(píng)論于:2019-04-27 12:33:34
感謝,正需要
YHZ2012 評(píng)論于:2020-03-26 15:58:22
b = cjson.decode(r.C)
hh=b.v
返回頂部