obuspa: Fix stomp mtp

This commit is contained in:
vdutta 2022-08-10 19:35:17 +05:30
parent 97ef5bcc7b
commit dd1fc7ff7d
3 changed files with 36 additions and 14 deletions

View file

@ -5,7 +5,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=obuspa
PKG_VERSION:=5.0.0.18
PKG_VERSION:=5.0.0.19
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
@ -100,6 +100,7 @@ define Package/obuspa/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/obuspa
$(INSTALL_DIR) $(1)/etc/bbfdm/json
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) $(PKG_BUILD_DIR)/obuspa $(1)/usr/sbin/
$(INSTALL_BIN) ./files/etc/init.d/obuspa $(1)/etc/init.d/
$(INSTALL_DATA) ./files/etc/config/obuspa $(1)/etc/config/
@ -107,6 +108,7 @@ define Package/obuspa/install
$(INSTALL_DATA) ./files/etc/obuspa/dmcaching_exclude.json $(1)/etc/obuspa/dmcaching_exclude.json
$(INSTALL_DATA) ./files/etc/bbfdm/json/USPAgent.json $(1)/etc/bbfdm/json/USPAgent.json
$(INSTALL_DATA) ./files/etc/bbfdm/json/TransferComplete.json $(1)/etc/bbfdm/json/TransferComplete.json
$(INSTALL_BIN) ./files/etc/uci-defaults/01-fix-upgrade-uci $(1)/etc/uci-defaults/
endef
$(eval $(call BuildPackage,obuspa))

View file

@ -175,13 +175,13 @@ get_role_index_from_json()
validate_obuspa_section()
{
uci_validate_section ${CONFIGURATION} obuspa "${1}" \
'enabled:bool:true' \
'enabled:bool:1' \
'trust_cert:file' \
'client_cert:file' \
'interface:string' \
'ifname:string' \
'debug:bool:false' \
'prototrace:bool:false' \
'debug:bool:0' \
'prototrace:bool:0' \
'log_level:uinteger' \
'log_dest:string' \
'db_file:string' \
@ -197,7 +197,7 @@ validate_localagent_section()
validate_controller_section()
{
uci_validate_section ${CONFIGURATION} controller "${1}" \
'Enable:bool:true' \
'Enable:bool:1' \
'EndpointID:string' \
'assigned_role_name:string' \
'Protocol:or("STOMP","CoAP","MQTT", "WebSocket")' \
@ -215,17 +215,17 @@ validate_controller_section()
validate_subscription_section()
{
uci_validate_section ${CONFIGURATION} subscription "${1}" \
'Enable:bool:true' \
'Enable:bool:1' \
'NotifType:or("ValueChange","ObjectCreation","ObjectDeletion","OperationComplete","Event")' \
'ReferenceList:list(string)' \
'Persistent:bool:true' \
'Persistent:bool:1' \
'controller:string'
}
validate_mtp_section()
{
uci_validate_section ${CONFIGURATION} mtp "${1}" \
'Enable:bool:true' \
'Enable:bool:1' \
'Protocol:or("STOMP","CoAP","MQTT", "WebSocket")' \
'ResponseTopicConfigured:string' \
'Destination:string' \
@ -239,19 +239,20 @@ validate_mtp_section()
validate_stomp_connection_section()
{
uci_validate_section ${CONFIGURATION} stomp "${1}" \
'Enable:bool:true' \
'Enable:bool:1' \
'Host:host' \
'Port:port:61613' \
'Username:string' \
'Password:string' \
'EnableEncryption:bool:true' \
'EnableEncryption:bool:1' \
'EnableHeartbeats:bool:1' \
'VirtualHost:string:/'
}
validate_mqtt_client_section()
{
uci_validate_section ${CONFIGURATION} mqtt "${1}" \
'Enable:bool:true' \
'Enable:bool:1' \
'BrokerAddress:host' \
'BrokerPort:port:1883' \
'Username:string' \
@ -264,7 +265,7 @@ validate_mqtt_client_section()
validate_challenge_section()
{
uci_validate_section ${CONFIGURATION} challenge "${1}" \
'Enable:bool:true' \
'Enable:bool:1' \
'Description:string' \
'role_name:string' \
'Role:string' \
@ -572,7 +573,7 @@ configure_mtp() {
configure_stomp_connection() {
local Host Username Password Enable Port VirtualHost
local EnableEncryption
local EnableEncryption EnableHeartbeats
validate_stomp_connection_section "${1}" || {
log "Validation of stomp section failed"
@ -593,6 +594,7 @@ configure_stomp_connection() {
db_set "${BASEPATH}.Enable" "${Enable}"
db_set "${BASEPATH}.Port" "${Port}"
db_set "${BASEPATH}.EnableEncryption" "${EnableEncryption}"
db_set "${BASEPATH}.EnableHeartbeats" "${EnableHeartbeats}"
db_set "${BASEPATH}.VirtualHost" "${VirtualHost}"
db_set
}
@ -725,7 +727,7 @@ db_init()
config_foreach configure_challenges challenge
global_init
# [ -f "${DB_DUMP}" ] && rm -f ${DB_DUMP}
[ -f "${DB_DUMP}" ] && rm -f ${DB_DUMP}
return 0;
}

View file

@ -0,0 +1,18 @@
#!/bin/sh
. /lib/functions.sh
fix_stomp_section() {
local encryption
config_get_bool encryption $1 encryption "1"
uci_set obuspa $1 encryption ""
uci_set obuspa $1 EnableEncryption "$encryption"
}
# Copy defaults by the factory to the cwmp UCI user section.
config_load obuspa
config_foreach fix_stomp_section stomp
uci_commit
# No need for commit here, it is done by uci_apply_defaults().