obuspa: Use local mqtt credential for endpointid publish

This commit is contained in:
vdutta 2021-02-16 19:28:22 +05:30
parent f54729e36e
commit 6e1c57dc91
2 changed files with 12 additions and 3 deletions

View file

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

View file

@ -505,7 +505,8 @@ remove_db() {
}
service_running() {
local AgentEndpointID serial oui
local AgentEndpointID serial oui user pass
local opt=""
ubus -t 10 wait_for usp.raw
config_load obuspa
@ -516,10 +517,18 @@ service_running() {
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}"
mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}" ${opt}
procd_running ${CONFIGURATION}
}