obuspa: Remove dependency of mosquitto_pub in init

This commit is contained in:
vdutta 2021-07-13 20:53:46 +05:30
parent f87742703b
commit 78c895f23a
2 changed files with 1 additions and 25 deletions

View file

@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=obuspa
PKG_VERSION:=4.0.0.9
PKG_VERSION:=4.0.0.10
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)

View file

@ -648,31 +648,7 @@ remove_db() {
}
service_running() {
local AgentEndpointID serial oui user pass
local opt=""
ubus -t 10 wait_for usp.raw
config_load obuspa
config_get AgentEndpointID localagent EndpointID ""
if [ -z "${AgentEndpointID}" ]; then
serial=$(ubus -t 1 call usp.raw get '{"path":"Device.DeviceInfo.SerialNumber"}'|jsonfilter -e '@["parameters"][0].value')
oui=$(ubus -t 1 call usp.raw get '{"path":"Device.DeviceInfo.ManufacturerOUI"}'|jsonfilter -e '@["parameters"][0].value')
AgentEndpointID="os::${oui}-${serial}"
fi
config_get user localmqtt Username
if [ -n "${user}" ]; then
opt="-u ${user}"
fi
config_get pass localmqtt Password
if [ -n "${pass}" ]; then
opt="${opt} -P ${pass}"
fi
# publish Agent's EndpointID in mosquito broker for discovery
# This is a work around till obuspa does not support advertising
log "Publishing EndpointID ${AgentEndpointID} to local mqtt broker"
mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}" ${opt}
procd_running ${CONFIGURATION}
}