diff --git a/controller-host/main.lua b/controller-host/main.lua index 7298ebf..3efc7ae 100644 --- a/controller-host/main.lua +++ b/controller-host/main.lua @@ -137,7 +137,7 @@ function love.load() local requirePaths = love.filesystem.getRequirePath() love.filesystem.setRequirePath(requirePaths .. ";client/?.lua;client/?/init.lua") local mqttThread = love.thread.newThread("mqttthread.lua") - mqttThread:start() + mqttThread:start(love.math.random(0, 999999)) mqttEventChannel = love.thread.getChannel("mqtt_event") mqttCommandChannel = love.thread.getChannel("mqtt_command") end diff --git a/controller-host/mqttthread.lua b/controller-host/mqttthread.lua index cb171bb..5e4d875 100644 --- a/controller-host/mqttthread.lua +++ b/controller-host/mqttthread.lua @@ -2,6 +2,8 @@ local mqtt = require("mqtt") local client +local maxClientId = ... + local eventChannel = love.thread.getChannel("mqtt_event") local commandChannel = love.thread.getChannel("mqtt_command") @@ -46,7 +48,7 @@ end local function main() client = mqtt.client { uri = "mqtt.seeseepuff.be", - username = "mqtt_controller-" .. math.random(0, 999999999), + username = "mqtt_controller-" .. math.random(0, maxClientId), clean = true, reconnect = 5, }