26.11.2018, 14:06
(26.11.2018, 10:29)admin Wrote: Post whole code that you're using.
Code:
mqtt = require("mosquitto")
client = mqtt.new()
client.ON_CONNECT = function()
client:publish("world", "hello")
local qos = 0
local retain = false
local mid = client:publish("/Office/PM/PM710/Voltage", string.format("%.2f", grp.getvalue('7/0/0')), qos, retain)
local mid = client:publish("/Office/MT300/Temp", string.format("%.2f",grp.getvalue('7/0/2')), qos, retain)
local mid = client:publish("/Office/PAC3200/Voltage/Fase1", string.format("%.2f",grp.getvalue('7/0/3')), qos, retain)
local mid = client:publish("/Office/PAC3200/Corriente/Fase1", string.format("%.2f",grp.getvalue('7/0/10')), qos, retain)
local mid = client:publish("/Office/PAC3200/Corriente/Fase2", string.format("%.2f",grp.getvalue('7/0/11')), qos, retain)
local mid = client:publish("/Office/PAC3200/Corriente/Fase3", string.format("%.2f",grp.getvalue('7/0/12')), qos, retain)
local mid = client:publish("/Office/PAC3200/PATotal", string.format("%.2f",grp.getvalue('7/0/13')), qos, retain)
end
client.ON_PUBLISH = function()
client:disconnect()
end
broker = 'url'
cafile = '/home/ftp/home/ftp/CA-Root.pem'
certfile = '/home/ftp/home/ftp/8f8253e1f4-certificate.pem.crt'
keyfile = '/home/ftp/home/ftp/8f8253e1f4-private.pem.key'
client:tls_set(cafile, nil, certfile, keyfile)
--client:login_set("undefine",jwt) --Testing GCS
client:connect(broker, 8883)
client:loop_forever()
This is the code is now working ok with a Mosquitto install in a different server but with no security.....
Should be done differently?
Thanks for all the help so far.