NodeMCU tmr - 'alarm' 的错误参数 #1(预期为布尔值)

NodeMCU tmr - bad argument #1 to 'alarm' (boolean expected)

我有一个函数在连接 wifi 后调用以设置我的 mqtt 连接。但是由于某种原因,当我应该设置重新连接计时器时它会出现恐慌。

alarm 的参数是否正确?!

local setupMqtt = function()

  m = mqtt.Client("esp1", 10)

  local mqtt_connect = function()
    m:connect("192.168.43.110", 1883, false)
  end

  local handle_failure = function()
    tmr.create():alarm(2500, tmr.ALARM_SINGLE, mqtt_connect)
  end

  m:lwt("/lwt", "offline", 0, 0)

  m:on("connect", function(client)
    print("connected")
    m:publish("/lwt", "online", 0, 1)
  end)

  m:on("connfail", function(client, reason)
    print("failure", reason)
    handle_failure()
  end)

  m:on("offline", function(client)
    print("offline")
    handle_failure()
  end)

  mqtt_connect()

end

我正在使用 3.0.0.0 dev 分支,因为 master 分支中的 mqtt 存在错误

NodeMCU 3.0.0.0 
        branch: dev
        commit: b4c148eff07c9aaeeb29a89fbf838f78960fe655
        release: 3.0-master_20200610 +23
        release DTS: 202008301904
        SSL: false
        build type: float
        LFS: 0x0 bytes total capacity
        modules: adc,bit,dht,file,gpio,http,i2c,mdns,mqtt,net,node,ow,tmr,uart,wifi
 build 2020-09-04 09:25 powered by Lua 5.1.4 on SDK 3.0.1-dev(fce080e)

这是有效的

local M = {}

function M.setup()

  local m = mqtt.Client("esp1", 10)

  local mqtt_connect = function()
    print("connect")
    m:connect("192.168.1.100", 1883, false)
  end

  local t = tmr.create()
  t:register(10000, tmr.ALARM_SEMI, mqtt_connect)

  m:lwt("/lwt", "offline", 0, 0)

  m:on("connect", function(client)
    print("connected")
    m:publish("/lwt", "online", 0, 1)
  end)

  m:on("connfail", function(client, reason)
    print("failure", reason)
    t:start()
  end)

  m:on("offline", function(client)
    print("offline")
    t:start()
  end)

  mqtt_connect()

end

return M

这是一个已知错误,将通过 PR #3263 修复。我们将在接下来的几个小时或几天内合并它。