From: Roman Bazalevskiy Date: Sun, 19 Mar 2017 20:34:30 +0000 (+0300) Subject: MQTT timeout/disconnect processing. X-Git-Url: https://git.rvb.name/openhab-process.git/commitdiff_plain/9e115a08e80fa89413335716477f8436523141dd MQTT timeout/disconnect processing. --- diff --git a/mqtt-bt/scan-beacons b/mqtt-bt/scan-beacons index 98c3993..3c6a230 100644 --- a/mqtt-bt/scan-beacons +++ b/mqtt-bt/scan-beacons @@ -1,4 +1,4 @@ -#!/usr/bin/env lua +#!/usr/bin/lua function getConfig(configname) @@ -151,13 +151,16 @@ function process_packet(packet) end if type=="ibeacon" then printLog(string.format("{type:'ibeacon',mac:'%s',uuid:'%s',major:'%s',minor:'%s',power:%d,tx:%d}",mac,uuid,major,minor,power,tx)) - details=uuid..'/'..major..'/'..minor..'/' + details=uuid..'/'..major..'/'..minor else type='unknown' details=dump(bytes) printLog(details) end if mqtt_client then + if not mqtt_client.connected then + mqtt_client:connect(mqtt_id) + end mqtt_path=string.gsub(mqtt_topic,"{(.-)}", function (name) if name=="type" then @@ -215,7 +218,6 @@ if mqtt_host then if mqtt_user then mqtt_client:auth(mqtt_user, mqtt_passwd) end - mqtt_client:connect(mqtt_id) end inp = open_dump()