From 9e115a08e80fa89413335716477f8436523141dd Mon Sep 17 00:00:00 2001 From: Roman Bazalevskiy Date: Sun, 19 Mar 2017 23:34:30 +0300 Subject: [PATCH] MQTT timeout/disconnect processing. --- mqtt-bt/scan-beacons | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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() -- 2.34.1