mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
usp-js: depend on OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL
This avoids the need for duplicating local MQTT broker setup.
This commit is contained in:
parent
ee38bf37d9
commit
0924ffc34a
3 changed files with 2 additions and 131 deletions
|
|
@ -6,7 +6,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=usp-js
|
||||
PKG_VERSION:=1.2.4
|
||||
PKG_VERSION:=1.2.6
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/usp-js.git
|
||||
|
|
@ -23,7 +23,7 @@ define Package/usp-js
|
|||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=A JS library for USP(TR369) protocol
|
||||
DEPENDS:=+quickjs +quickjs-websocket
|
||||
DEPENDS:=+quickjs +quickjs-websocket +@OBUSPA_ENABLE_TEST_CONTROLLER_LOCAL
|
||||
EXTRA_DEPENDS:=obuspa mosquitto-ssl
|
||||
endef
|
||||
|
||||
|
|
@ -37,9 +37,7 @@ endef
|
|||
|
||||
define Package/usp-js/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/usp-js
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(CP) $(PKG_BUILD_DIR)/qjs/* $(1)/usr/lib/usp-js/
|
||||
$(CP) ./files/etc/* $(1)/etc/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,usp-js))
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
STOP=01
|
||||
USE_PROCD=1
|
||||
|
||||
log()
|
||||
{
|
||||
echo "$*"|logger -t usp-js -p debug
|
||||
}
|
||||
|
||||
get_oui_from_db()
|
||||
{
|
||||
db -q get device.deviceinfo.ManufacturerOUI
|
||||
}
|
||||
|
||||
get_serial_from_db()
|
||||
{
|
||||
db -q get device.deviceinfo.SerialNumber
|
||||
}
|
||||
|
||||
publish_endpoint()
|
||||
{
|
||||
local AgentEndpointID serial oui user pass
|
||||
|
||||
if ! uci -q get obuspa.testmqtt; then
|
||||
return 0;
|
||||
fi
|
||||
|
||||
# return if mosquitto_pub is not present
|
||||
if [ ! "$(command -v mosquitto_pub)" ]; then
|
||||
log "mosquitto_pub not present can't publish EndpointID"
|
||||
return 0;
|
||||
fi
|
||||
|
||||
# Get endpoint id from obuspa config first
|
||||
config_load obuspa
|
||||
config_get AgentEndpointID localagent EndpointID ""
|
||||
if [ -z "${AgentEndpointID}" ]; then
|
||||
serial=$(get_serial_from_db)
|
||||
oui=$(get_oui_from_db)
|
||||
AgentEndpointID="os::${oui}-${serial//+/%2B}"
|
||||
fi
|
||||
|
||||
config_get user testmqtt Username ""
|
||||
config_get pass testmqtt Password ""
|
||||
|
||||
# publish Agent's EndpointID in mosquito broker for discovery by usp-js
|
||||
# This is a work around till obuspa adds supports for mDNS discovery
|
||||
if [ -n "${user}" ] && [ -n "${pass}" ]; then
|
||||
log "Publishing EndpointID ${AgentEndpointID} to local mqtt broker with username, password"
|
||||
mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}" -u "${user}" -P "${pass}"
|
||||
elif [ -n "${user}" ]; then
|
||||
log "Publishing EndpointID ${AgentEndpointID} to local mqtt broker with username only"
|
||||
mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}" -u "${user}"
|
||||
else
|
||||
log "Publishing EndpointID ${AgentEndpointID} to local mqtt broker"
|
||||
mosquitto_pub -r -t "obuspa/EndpointID" -m "${AgentEndpointID}"
|
||||
fi
|
||||
}
|
||||
|
||||
start_service() {
|
||||
publish_endpoint
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "obuspa"
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
if [ ! -f "/etc/config/obuspa" ]; then
|
||||
echo "Local obuspa not available"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ ! -f "/etc/config/mosquitto" ]; then
|
||||
echo "Local mosquitto broker not available"
|
||||
return 0
|
||||
fi
|
||||
|
||||
add_obuspa_test_mtp()
|
||||
{
|
||||
uci_add obuspa mtp test_mtp
|
||||
uci_set obuspa test_mtp Protocol 'MQTT'
|
||||
uci_set obuspa test_mtp ResponseTopicConfigured '/usp/endpoint'
|
||||
uci_set obuspa test_mtp mqtt 'testmqtt'
|
||||
}
|
||||
|
||||
add_obuspa_test_mqtt()
|
||||
{
|
||||
# Adds Device.MQTT.Client.
|
||||
uci_add obuspa mqtt testmqtt
|
||||
uci_set obuspa testmqtt BrokerAddress '127.0.0.1'
|
||||
uci_set obuspa testmqtt BrokerPort '1883'
|
||||
uci_set obuspa testmqtt TransportProtocol 'TCP/IP'
|
||||
}
|
||||
|
||||
add_obuspa_test_controller()
|
||||
{
|
||||
# Adds Device.LocalAgent.Controller.
|
||||
uci_add obuspa controller testcontroller
|
||||
uci_set obuspa testcontroller EndpointID 'proto::interop-usp-controller'
|
||||
uci_set obuspa testcontroller Protocol 'MQTT'
|
||||
uci_set obuspa testcontroller Topic '/usp/controller'
|
||||
uci_set obuspa testcontroller mqtt 'testmqtt'
|
||||
uci_set obuspa testcontroller assigned_role_name 'full_access'
|
||||
}
|
||||
|
||||
add_obuspa_config()
|
||||
{
|
||||
uci_add mosquitto listener obuspa
|
||||
uci_set mosquitto obuspa enabled 1
|
||||
uci_set mosquitto obuspa port '1883'
|
||||
uci_set mosquitto obuspa no_remote_access '1'
|
||||
uci_set mosquitto obuspa allow_anonymous '1'
|
||||
}
|
||||
|
||||
# Add local controller for usp-js
|
||||
uci_load mosquitto
|
||||
add_obuspa_config
|
||||
|
||||
uci_load obuspa
|
||||
add_obuspa_test_mtp
|
||||
add_obuspa_test_mqtt
|
||||
add_obuspa_test_controller
|
||||
Loading…
Add table
Reference in a new issue