Compare commits

..

3 Commits

Author SHA1 Message Date
Janusz Dziedzic
57fa4ec5c3 map_agent: reload wireless after uci commit
Signed-off-by: Janusz Dziedzic <janusz.dziedzic@iopsys.eu>
2023-12-18 20:37:28 +01:00
Janusz Dziedzic
40da2597a9 libwifi: don't use private mt.c impl
Signed-off-by: Janusz Dziedzic <janusz.dziedzic@iopsys.eu>
2023-12-18 20:36:50 +01:00
Janusz Dziedzic
db246c24f4 agent/ctrl use git instead of https 2023-12-18 20:36:44 +01:00
33 changed files with 146 additions and 2031 deletions

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=bbfdm
PKG_VERSION:=1.4.23.2
PKG_VERSION:=1.4.23
USE_LOCAL:=0
ifneq ($(USE_LOCAL),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/bbfdm.git
PKG_SOURCE_VERSION:=6974c9cf6d4ea87d668dd349d0f281f8c9a056a9
PKG_SOURCE_VERSION:=c10303fc51a1034cb87040e0eaf23c95d2b1c658
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2018-2024 iopsys Software Solutions AB
# Copyright (C) 2018 iopsys Software Solutions AB
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -8,15 +8,14 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=dslmngr
PKG_VERSION:=1.2.1
PKG_VERSION:=1.2.0
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=cb8b8fd2549751bcd38808391b76a1a9a908c4de
PKG_SOURCE_URL:=https://dev.iopsys.eu/hal/dslmngr.git
PKG_SOURCE_VERSION:=43dec92b1c86be7859521da337e7bd1168848b26
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/dslmngr.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MAINTAINER:=Rahul Thakur <rahul.thakur@iopsys.eu>
PKG_MIRROR_HASH:=skip
endif
@@ -60,7 +59,7 @@ MAKE_FLAGS += \
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
rsync -r --exclude=.* ./dslmngr/ $(PKG_BUILD_DIR)/
rsync -r --exclude=.* ~/git/dslmngr/ $(PKG_BUILD_DIR)/
endef
endif

View File

@@ -1,21 +1,18 @@
#
# Copyright (C) 2020-2024 Iopsys
# Copyright (C) 2020 Iopsys
#
include $(TOPDIR)/rules.mk
PKG_NAME:=ethmngr
PKG_VERSION:=2.1.2
PKG_VERSION:=2.1.1
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=e5cccdd45a93d969d51c4085cb52b543df544811
PKG_SOURCE_URL:=https://dev.iopsys.eu/hal/ethmngr.git
PKG_MAINTAINER:=Rahul Thakur <rahul.thakur@iopsys.eu>
PKG_SOURCE_VERSION:=b81d06867d895245ef47004c6949f9d6dedd10ef
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/ethmngr.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=GPL-2.0-only
PKG_LICENSE_FILES:=LICENSE
@@ -35,12 +32,6 @@ define Package/ethmngr/description
It uses APIs from the libethernet.so library.
endef
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
$(CP) -rf ./ethmngr/* $(PKG_BUILD_DIR)/
endef
endif
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include \
-I$(STAGING_DIR)/usr/include/libnl3 \

View File

@@ -5,12 +5,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=hostmngr
PKG_VERSION:=1.1.6
PKG_VERSION:=1.1.4
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=2563c39a0296ee41d4fc471f8c5574c3410642f2
PKG_SOURCE_VERSION:=edb5bbe57c5bc83035e217c73071c9b3e878dc22
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/hostmngr.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip

View File

@@ -8,13 +8,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=icwmp
PKG_VERSION:=9.5.29.5
PKG_VERSION:=9.5.27
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/icwmp.git
PKG_SOURCE_VERSION:=fffc05ae711e94c8d0f5d5546c4dddb5fa32c87a
PKG_SOURCE_VERSION:=ce1f7e01f0f5e7cc3a5dfeb5378d488f3e2938a0
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif
@@ -103,8 +103,8 @@ define Package/icwmp/default/install
$(INSTALL_BIN) ./files/etc/uci-defaults/90-cwmpfirewall $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./files/etc/uci-defaults/95-set-random-inform-time $(1)/etc/uci-defaults/
$(INSTALL_DATA) ./files/lib/upgrade/keep.d/icwmp $(1)/lib/upgrade/keep.d/icwmp
$(INSTALL_BIN) ./files/etc/udhcpc.user.d/udhcpc_icwmp_opt125.user $(1)/etc/udhcpc.user.d/udhcpc_icwmp_opt125.user
$(INSTALL_BIN) ./files/etc/udhcpc.user.d/udhcpc_icwmp_opt43.user $(1)/etc/udhcpc.user.d/udhcpc_icwmp_opt43.user
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/etc/udhcpc.user.d/udhcpc_icwmp_opt125.user $(1)/etc/udhcpc.user.d/udhcpc_icwmp_opt125.user
$(INSTALL_BIN) $(PKG_BUILD_DIR)/files/etc/udhcpc.user.d/udhcpc_icwmp_opt43.user $(1)/etc/udhcpc.user.d/udhcpc_icwmp_opt43.user
$(call BbfdmInstallPlugin,$(1),./files/etc/bbfdm/json/CWMPManagementServer.json)
$(call BbfdmInstallPlugin,$(1),$(PKG_BUILD_DIR)/libcwmpdm.so)
endef

View File

@@ -541,6 +541,7 @@ start_service() {
"${respawn_threshold:-5}" \
"${respawn_timeout:-10}" "${respawn_retry:-3}"
procd_set_param watch network.interface
procd_close_instance
}
@@ -568,20 +569,6 @@ reload_service() {
log "Reloading cwmp service ..."
stop
start
return 0
fi
tr069_status="$(ubus -t 1 call tr069 status)"
ret="$?"
if [ "$ret" = "7" ]; then
# ubus timed out may be due to uloop is busy in some task so return
log "Skipping ubus reload due to ubus timeout"
return 0
fi
status="$(echo "${tr069_status}" | jsonfilter -qe '@.cwmp.status')"
if [ "$status" = "up" ]; then
ubus -t 1 call tr069 command '{"command":"reload"}'
fi
}

View File

@@ -1,139 +0,0 @@
#!/bin/sh
. /lib/functions.sh
CLASS=""
OUI=""
SERIAL=""
get_vivsoi() {
# opt125 environment variable has data in below format
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
# | enterprise-number1 |
# | |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
# | data-len1 | |
# +-+-+-+-+-+-+-+-+ option-data1 |
# / /
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -----
# | enterprise-number2 | ^
# | | |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
# | data-len2 | | optional
# +-+-+-+-+-+-+-+-+ option-data2 | |
# / / |
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
# ~ ... ~ V
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -----
# Enterprise Id Len Sub Op SLen Data Sub Op SLen Data Sub Op SLen Data
# +-------------+-----+------+------+----+------+-----+----+-----+------+-----+----+
# | id | n | 1 | n1 | D1 | 2 | n2 | D2 | ... | 6 | n6 | D6 |
# +-------------+-----+------+------+----+------+-----+----+-----+------+-----+----+
local opt125="$1"
local len="$2"
local ent_id
#hex-string 2 character=1 Byte
# length in hex string will be twice of actual Byte length
[ "$len" -gt "8" ] || return
data="${opt125}"
rem_len="${len}"
while [ $rem_len -gt 0 ]; do
ent_id=${data:0:8}
ent_id=$(printf "%d\n" "0x$ent_id")
if [ $ent_id -ne 3561 ]; then
len_val=${data:8:2}
data_len=$(printf "%d\n" "0x$len_val")
# add 4 byte for ent_id and 1 byte for len
data_len=$(( data_len * 2 + 10 ))
# move ahead data to next enterprise id
data=${data:"${data_len}":"${rem_len}"}
rem_len=$(( rem_len - $data_len ))
continue
fi
# read the length of enterprise data
len_val=${data:8:2}
data_len=$(printf "%d\n" "0x$len_val")
# add 4 byte for ent_id and 1 byte for len
data_len=$(( data_len * 2 + 10 ))
opt_len=$(printf "%d\n" "0x$len_val")
[ $opt_len -eq 0 ] && return
# populate the option data of enterprise id
sub_data_len=$(( opt_len * 2))
# starting 10 means ahead of length field
sub_data=${data:10:"${sub_data_len}"}
# parsing of suboption of option 125
while [ $sub_data_len -gt 0 ]; do
# get the suboption id
sub_opt_id=${sub_data:0:2}
sub_opt_id=$(printf "%d\n" "0x$sub_opt_id")
# get the length of suboption
sub_opt_len=${sub_data:2:2}
sub_opt_len=$(printf "%d\n" "0x$sub_opt_len")
sub_opt_len=$(( sub_opt_len * 2 ))
# get the value of sub option starting 4 means starting after length
sub_opt_val=${sub_data:4:${sub_opt_len}}
# assign the value found in sub option
case "${sub_opt_id}" in
"4") OUI=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
"5") SERIAL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
"6") CLASS=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
esac
# add 2 bytes for sub_opt id and sub_opt len field
sub_opt_end=$(( sub_opt_len + 4 ))
# update the remaining sub option hex string length
sub_data_len=$((sub_data_len - sub_opt_end))
# fetch next sub option hex string
sub_data=${sub_data:${sub_opt_end}:${sub_data_len}}
done
# move ahead data to next enterprise id
data=${data:"${data_len}":"${rem_len}"}
rem_len=$(( rem_len - data_len ))
done
}
config_load cwmp
config_get_bool enable_cwmp cpe enable 1
config_get wan_intf cpe default_wan_interface "wan"
if [ "$enable_cwmp" = "0" ]; then
return 0
fi
if [ "${wan_intf}" == "${INTERFACE}" ]; then
if [ -n "$opt125" ]; then
len=$(printf "$opt125"|wc -c)
get_vivsoi "$opt125" "$len"
fi
mkdir -p /var/state
touch /var/state/icwmp
sec=$(uci -q -c /var/state get icwmp.gatewayinfo)
if [ -z "${sec}" ]; then
sec=$(uci -q -c /var/state add icwmp gatewayinfo)
uci -q -c /var/state rename icwmp."${sec}"="gatewayinfo"
fi
uci -q -c /var/state set icwmp.gatewayinfo.class="$CLASS"
uci -q -c /var/state set icwmp.gatewayinfo.oui="$OUI"
uci -q -c /var/state set icwmp.gatewayinfo.serial="$SERIAL"
uci -q -c /var/state commit icwmp
fi

View File

@@ -1,141 +0,0 @@
#!/bin/sh
. /lib/functions.sh
DHCP_ACS_URL=""
DHCP_PROV_CODE=""
MIN_WAIT_INVL=""
INVL_MULTIPLIER=""
log() {
echo "$@" |logger -t cwmp.update -p info
}
get_opt43() {
# Check if option value is in encapsulated form
local opt43="$1"
local len="$2"
[ "$len" -gt "2" ] || return
first_byte=${opt43:0:2}
first_byte=$(printf "%d\n" "0x$first_byte")
if [ $len -ge 4 ] && [ $first_byte -ge 1 ] && [ $first_byte -le 4 ]; then
# it is in encapsulated form
# opt43 encapsulated vendor-specific option has data in below format
# Code Len Data item Code Len Data item Code
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
# | T1 | n | d1 | d2 | ... | T2 | n | D1 | D2 | ... | ... |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
#hex-string 2 character=1 Byte
# length in hex string will be twice of actual Byte length
data="${opt43}"
rem_len="${len}"
# parsing of suboption of option 43
while [ $rem_len -gt 0 ]; do
# get the suboption id
sub_opt_id=${data:0:2}
sub_opt_id=$(printf "%d\n" "0x$sub_opt_id")
# get the length of suboption
sub_opt_len=${data:2:2}
sub_opt_len=$(printf "%d\n" "0x$sub_opt_len")
sub_opt_len=$(( sub_opt_len * 2 ))
# get the value of sub option starting 4 means starting after length
sub_opt_val=${data:4:${sub_opt_len}}
# assign the value found in sub option
case "${sub_opt_id}" in
"1") DHCP_ACS_URL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
"2") DHCP_PROV_CODE=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
"3") MIN_WAIT_INVL=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
"4") INVL_MULTIPLIER=$(echo -n $sub_opt_val | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
;;
esac
# add 2 bytes for sub_opt id and sub_opt len field
sub_opt_end=$(( sub_opt_len + 4 ))
# fetch next sub option hex string
data=${data:${sub_opt_end}:${len}}
# update the remaining sub option hex string length
rem_len=$((rem_len - sub_opt_end))
done
else
DHCP_ACS_URL=$(echo -n $opt43 | sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' | xargs printf && echo '')
fi
}
config_load cwmp
config_get wan_intf cpe default_wan_interface "wan"
config_get dhcp_discovery acs dhcp_discovery "0"
config_get dhcp_url acs dhcp_url ""
config_get min_wait_intvl acs dhcp_retry_min_wait_interval "0"
config_get intvl_multi acs dhcp_retry_interval_multiplier "0"
config_change=0
discovery_enable=0
if [ "$dhcp_discovery" = "1" ] || [ "$dhcp_discovery" = "true" ] || [ "$dhcp_discovery" = "enable" ]; then
discovery_enable=1
fi
if [ "$discovery_enable" = "0" ]; then
return 0
fi
if [ "${wan_intf}" == "${INTERFACE}" ]; then
if [ -n "$opt43" ]; then
len=$(printf "$opt43"|wc -c)
get_opt43 "$opt43" "$len"
fi
if [ -z "$DHCP_ACS_URL" ]; then
return 0
fi
sec=$(uci -q get cwmp.acs)
if [ -z "${sec}" ]; then
return 0
fi
if [ "${dhcp_url}" != "${DHCP_ACS_URL}" ]; then
uci -q set cwmp.acs.dhcp_url="$DHCP_ACS_URL"
config_change=1
fi
if [ -n "$MIN_WAIT_INVL" ] && [ "${MIN_WAIT_INVL}" != "${min_wait_intvl}" ]; then
uci -q set cwmp.acs.dhcp_retry_min_wait_interval="$MIN_WAIT_INVL"
config_change=1
fi
if [ -n "$INVL_MULTIPLIER" ] && [ "${INVL_MULTIPLIER}" != "${intvl_multi}" ]; then
uci -q set cwmp.acs.dhcp_retry_interval_multiplier="$INVL_MULTIPLIER"
config_change=1
fi
sec=$(uci -q get cwmp.cpe)
if [ -n "${sec}" ] && [ -n "$DHCP_PROV_CODE" ]; then
uci -q set cwmp.cpe.dhcp_provisioning_code="$DHCP_PROV_CODE"
config_change=1
fi
if [ $config_change -eq 0 ]; then
return 0
fi
# ACS url has been set, inform icwmpd to reload new configuration
sleep 10 # wait for some time to avoid interface fluctuation
ubus call uci commit '{"config":"cwmp"}'
fi

56
inbd/Makefile Normal file
View File

@@ -0,0 +1,56 @@
#
# Copyright (C) 2016 iopsys
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=inbd
PKG_VERSION:=1.2.3
PKG_RELEASE:=1
PKG_SOURCE_VERSION:=d4e910a31039e0c0b7a539311eafcd716c36be77
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/inbd
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=GPLv2
PKG_LICENSE_FILES:=LICENSE
# support parallel build
PKG_BUILD_PARALLEL:=1
#re create configure scripts if not present.
PKG_FIXUP:=autoreconf
# run install target when cross compiling. basically, make install DESTDIR=$(PKG_INSTALL_DIR)
# this way we don't need to pick out the resulting files from the build dir.
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/inbd
CATEGORY:=Utilities
TITLE:=iopsys Netlink Bridge Daemon
URL:=
DEPENDS:=+libuci +libubus +libblobmsg-json +libnl-genl
endef
define Package/inbd/description
Application handling netlink messages from kernel and sending them out on ubus.
endef
define Package/inbd/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/inbd $(1)/usr/bin/
cp $(PKG_BUILD_DIR)/files/etc/init.d/inbd $(1)/etc/init.d/
endef
$(eval $(call BuildPackage,inbd))

View File

@@ -64,6 +64,7 @@ CONFIG_LOCALMIRROR="https://download.iopsys.eu/iopsys/mirror/"
################
# EasySoC HAL #
CONFIG_PACKAGE_inbd=y
CONFIG_PACKAGE_qosmngr=y
CONFIG_PACKAGE_libwifiutils=y
CONFIG_PACKAGE_wifimngr=y
@@ -178,8 +179,6 @@ CONFIG_PACKAGE_iptables-mod-ipmark=y
CONFIG_PACKAGE_iptables-mod-ipopt=y
CONFIG_PACKAGE_iptables-mod-nflog=y
CONFIG_PACKAGE_iptables-mod-nfqueue=y
CONFIG_PACKAGE_iputils-arping=y
CONFIG_PACKAGE_iputils-ping=y
CONFIG_PACKAGE_ndisc6=y
CONFIG_PACKAGE_rdisc6=y
CONFIG_PACKAGE_resolveip=y
@@ -249,6 +248,7 @@ CONFIG_PACKAGE_nginx-mod-luci=y
CONFIG_BUSYBOX_CUSTOM=y
CONFIG_BUSYBOX_CONFIG_ADDUSER=y
CONFIG_BUSYBOX_CONFIG_ARPING=y
CONFIG_BUSYBOX_CONFIG_ASH_IDLE_TIMEOUT=y
CONFIG_BUSYBOX_CONFIG_ASH_RANDOM_SUPPORT=y
CONFIG_BUSYBOX_CONFIG_CTTYHACK=y
@@ -330,7 +330,3 @@ CONFIG_BUSYBOX_CONFIG_FEATURE_VOLUMEID_UBIFS=y
CONFIG_BUSYBOX_CONFIG_TIMEOUT=y
CONFIG_BUSYBOX_CONFIG_NOHUP=y
CONFIG_BUSYBOX_CONFIG_FEATURE_DEFAULT_PASSWD_ALGO="sha512"
# CONFIG_BUSYBOX_CONFIG_ARPING is not set
# CONFIG_BUSYBOX_CONFIG_PING is not set
# CONFIG_BUSYBOX_CONFIG_PING6 is not set
# CONFIG_BUSYBOX_CONFIG_FEATURE_FANCY_PING is not set

View File

@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=libvoice-airoha
PKG_RELEASE:=1
PKG_VERSION:=1.0.11
PKG_VERSION:=1.0.10
PKG_LICENSE:=PROPRIETARY
PKG_LICENSE_FILES:=LICENSE
@@ -17,7 +17,7 @@ LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/$(PKG_NAME).git
PKG_SOURCE_VERSION:=287c4b5bd649dd4c4800a5fbb7d8f02e9fdfcbd3
PKG_SOURCE_VERSION:=e6ba6fca814f6c83a3d6ff4a5b7560fbc36d3101
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -1,21 +0,0 @@
#!/bin/sh
hasVoice=$(db -q get hw.board.hasVoice)
[ "$hasVoice" = "1" ] || { rm -f "/etc/config/asterisk"; return; }
source /lib/voice/config_asterisk.sh
default_asterisk_config
SLIC=`cat /proc/device-tree/airoha-voice/slic-type`
[ "${SLIC#pef}" != "${SLIC}" ] || return
echo Configure TxGain and RxGain for MXL SLIC $SLIC
ports=$(db -q get hw.board.VoicePorts)
for p in $(seq 0 $((ports-1))); do
uci set asterisk.extension${p}.txgain='10'
uci set asterisk.extension${p}.rxgain='-15'
done
uci commit asterisk

View File

@@ -1,556 +0,0 @@
diff --git a/airoha-connection.c b/airoha-connection.c
index 85447de..3872aff 100644
--- a/airoha-connection.c
+++ b/airoha-connection.c
@@ -21,7 +21,7 @@ int voice_connection_create(int line, int connection) {
// Check that the new connection is unique
if(voice_connection_find(line, connection) != -1) {
- ENDPT_DBG("Error: duplicated connection %d on line %d\n", connection, line);
+ ENDPT_ERR("Error: duplicated connection %d on line %d\n", connection, line);
return -1;
}
@@ -30,7 +30,7 @@ int voice_connection_create(int line, int connection) {
con_idx < max_num_connections && connections[con_idx].line != -1 && connections[con_idx].connection_id != -1;
con_idx++);
if(con_idx >= max_num_connections) {
- ENDPT_DBG("Error: out of connection array, line: %d, connection: %d\n", line, connection);
+ ENDPT_ERR("Error: out of connection array, line: %d, connection: %d\n", line, connection);
return -1;
}
diff --git a/airoha-helper.c b/airoha-helper.c
index f245f2b..45ca382 100644
--- a/airoha-helper.c
+++ b/airoha-helper.c
@@ -499,7 +499,7 @@ codec_e airoha_get_dsp_codec_type(enum VOICE_CODEC codec) {
case VOICE_CODEC_G729:
return CODEC_G729;
default:
- ENDPT_DBG("Unknown codec %d\n", codec);
+ ENDPT_WARN("Unknown codec %d\n", codec);
return CODEC_G711A;
}
}
diff --git a/airoha-line.c b/airoha-line.c
index 76fe945..08127f3 100644
--- a/airoha-line.c
+++ b/airoha-line.c
@@ -95,13 +95,13 @@ int voice_get_terminal_info(const struct terminal_info_t *voice_port_cfg, struct
ENDPT_DBG("ADAM Initialize\n");
ret = adamInit();
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("ADAM initialization failed with error: %d <%s>!\n", ret, etosError(ret));
+ ENDPT_ERR("ADAM initialization failed with error: %d <%s>!\n", ret, etosError(ret));
return -1;
}
ret = adamQuery(&cfg);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("ADAM Query failed with error: %d <%s>!\n", ret, etosError(ret));
+ ENDPT_ERR("ADAM Query failed with error: %d <%s>!\n", ret, etosError(ret));
return -1;
}
@@ -109,7 +109,7 @@ int voice_get_terminal_info(const struct terminal_info_t *voice_port_cfg, struct
ret = adamDspInvoke(DSP_MTK);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("DSP Invoke failed with error: %d <%s>!\n", ret, etosError(ret));
+ ENDPT_ERR("DSP Invoke failed with error: %d <%s>!\n", ret, etosError(ret));
return -1;
}
@@ -117,7 +117,7 @@ int voice_get_terminal_info(const struct terminal_info_t *voice_port_cfg, struct
ret = adamDspQuery(DSP_MTK, &active, &feature);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("DSP Query failed with error: %d <%s>!\n", ret, etosError(ret));
+ ENDPT_ERR("DSP Query failed with error: %d <%s>!\n", ret, etosError(ret));
return -1;
}
@@ -156,8 +156,7 @@ int voice_set_country(const char *country_code) {
}
}
- ENDPT_DBG("Warning: country_code '%s' is not supported on the current platform. Keep the default one\n",
- country_code);
+ ENDPT_WARN("country_code '%s' is not supported on the current platform. Keep the default one\n", country_code);
return 0;
}
@@ -168,7 +167,7 @@ static int airoha_channel_configure(chanId_e ch)
ret = adamChanQuery(DSP_MTK, ch, &cc);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("adamChanQuery() failed for channel %d with error: %d <%s>", ch, ret, etosError(ret));
+ ENDPT_ERR("adamChanQuery() failed for channel %d with error: %d <%s>", ch, ret, etosError(ret));
return EXEC_FAIL;
}
@@ -186,7 +185,7 @@ static int airoha_channel_configure(chanId_e ch)
ret = adamChanConfig(DSP_MTK, ch, &cc);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("adamChanConfig() failed for channel %d with error: %d <%s>", ch, ret, etosError(ret));
+ ENDPT_ERR("adamChanConfig() failed for channel %d with error: %d <%s>", ch, ret, etosError(ret));
return EXEC_FAIL;
}
@@ -194,11 +193,11 @@ static int airoha_channel_configure(chanId_e ch)
ret = adamChanStart(DSP_MTK, ch);
if(EXEC_SUCCESS != ret) {
- ENDPT_DBG("Cannot start channel %d, adamChanStart() failed with error: %d <%s>\n", ch, ret, etosError(ret));
+ ENDPT_ERR("Cannot start channel %d, adamChanStart() failed with error: %d <%s>\n", ch, ret, etosError(ret));
return EXEC_FAIL;
}
- ENDPT_DBG("Channel %d started OK!\n", ch);
+ ENDPT_INFO("Channel %d started OK!\n", ch);
return EXEC_SUCCESS;
}
@@ -222,7 +221,7 @@ static int airoha_create_stream(int streamNo, strmId_e streamsPerChan)
if (strmId == STRM0) {
ret = airoha_channel_configure(chId);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: Cannot configure channel %d\n", chId);
+ ENDPT_ERR("Error: Cannot configure channel %d\n", chId);
return ret;
}
}
@@ -236,7 +235,7 @@ static int airoha_create_stream(int streamNo, strmId_e streamsPerChan)
ret = adamStrmQuery(DSP_MTK, chId, strmId, &active, &airoha_streams[streamNo]);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: Cannot retrieve stream %d configuration for channel %d\n", strmId, chId);
+ ENDPT_ERR("Error: Cannot retrieve stream %d configuration for channel %d\n", strmId, chId);
return ret;
}
@@ -265,13 +264,13 @@ static int airoha_create_stream(int streamNo, strmId_e streamsPerChan)
ret = adamStrmConfig(DSP_MTK, chId, strmId, &airoha_streams[streamNo]);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: Cannot set stream %d configuration for channel %d\n", strmId, chId);
+ ENDPT_ERR("Error: Cannot set stream %d configuration for channel %d\n", strmId, chId);
return ret;
}
ret = adamStrmQuery(DSP_MTK, chId, strmId, &active, &airoha_streams[streamNo]);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: Cannot retrieve stream %d configuration for channel %d\n", strmId, chId);
+ ENDPT_ERR("Error: Cannot retrieve stream %d configuration for channel %d\n", strmId, chId);
return ret;
}
@@ -334,7 +333,7 @@ static void *airoha_media_process(void *arg)
struct epoll_event events[32];
if (voice_cb_egress_media == NULL) {
- ENDPT_DBG("No callback attached for egress media\n");
+ ENDPT_WARN("No callback attached for egress media\n");
goto __error_ret;
}
@@ -345,14 +344,14 @@ static void *airoha_media_process(void *arg)
int epoll_fd = epoll_create1(EPOLL_CLOEXEC);
if (epoll_fd < 0) {
- ENDPT_DBG("epoll_create1() failed: %s\n", strerror(errno));
+ ENDPT_ERR("epoll_create1() failed: %s\n", strerror(errno));
goto __error_ret;
}
for (int socketId = 0; socketId < airoha_sockets_count; socketId++) {
struct epoll_event ev_recv = { .events = EPOLLIN, .data.fd = airoha_sockets[socketId], };
if (epoll_ctl(epoll_fd, EPOLL_CTL_ADD, ev_recv.data.fd, &ev_recv) != 0) {
- ENDPT_DBG("epoll_ctl() failed: %s\n", strerror(errno));
+ ENDPT_ERR("epoll_ctl() failed: %s\n", strerror(errno));
goto __error_ret;
}
}
@@ -361,7 +360,7 @@ static void *airoha_media_process(void *arg)
int count;
count = epoll_wait(epoll_fd, events, sizeof(events) / sizeof(events[0]), -1);
if (count < 0) {
- ENDPT_DBG("epoll_wait() failed: %s\n", strerror(errno));
+ ENDPT_ERR("epoll_wait() failed: %s\n", strerror(errno));
break;
}
@@ -369,17 +368,17 @@ static void *airoha_media_process(void *arg)
memset(buf, 0, sizeof(buf));
res = recv(events[i].data.fd, (void *)buf, sizeof(buf), 0);
if (res < 0) {
- ENDPT_DBG("recv() failed: %s\n", strerror(errno));
+ ENDPT_ERR("recv() failed: %s\n", strerror(errno));
continue;
} else if (res < RTP_HEADER_SIZE) {
- ENDPT_DBG("Too short media packet received from DSP\n");
+ ENDPT_WARN("Too short media packet received from DSP\n");
continue;
}
int packet_size = sizeof(struct media_packet_t) - 1 + res;
struct media_packet_t *ap = malloc(packet_size);
if (!ap) {
- ENDPT_DBG("Out of memory\n");
+ ENDPT_ERR("Out of memory\n");
goto __error_ret;
}
@@ -412,13 +411,13 @@ static int airoha_media_init(void)
// create/bind RTP & RTCP socket
if ( (airoha_sockets[socketId] = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0 )
{
- ENDPT_DBG("Socket create error for stream %d: %s\n", socketId, strerror(errno));
+ ENDPT_ERR("Socket create error for stream %d: %s\n", socketId, strerror(errno));
return -1;
}
myaddr.sin_port = htons ((unsigned short)(airoha_remote_rtp_port_start + socketId));
if ( bind(airoha_sockets[socketId], (const struct sockaddr *)&myaddr, sizeof(myaddr)) < 0 )
{
- ENDPT_DBG("Socket bind error for stream %d: %s\n", socketId, strerror(errno));
+ ENDPT_ERR("Socket bind error for stream %d: %s\n", socketId, strerror(errno));
return -1;
}
@@ -430,7 +429,7 @@ static int airoha_media_init(void)
if (airoha_media_thread == THREAD_NULL) {
if (pthread_create(&airoha_media_thread, NULL, &airoha_media_process, NULL) < 0) {
- ENDPT_DBG("Failed to create airoha_media_thread, error: %s\n", strerror(errno));
+ ENDPT_ERR("Failed to create airoha_media_thread, error: %s\n", strerror(errno));
airoha_media_thread = THREAD_NULL;
return -1;
}
@@ -507,7 +506,7 @@ static void airoha_evt_hook(event_t* pEvt)
voice_cb_event_report(pEvt->infcId, "FLASH", 0);
break;
default:
- ENDPT_DBG("Hook event %d not implemented!\n", pEvt->context.hook.status);
+ ENDPT_INFO("Hook event %d not implemented!\n", pEvt->context.hook.status);
break;
}
}
@@ -525,10 +524,10 @@ static void airoha_evt_tone(event_t* pEvt)
for(ev = event_map; mtekDtmfToVoiceEvt(tone) != ev->event && ev->event != VOICE_EVT_END; ev++)
continue;
if(ev->event == VOICE_EVT_END) {
- ENDPT_DBG("%s: Event %d from line %d is ignored\n", __func__, tone, pEvt->infcId);
+ ENDPT_DBG("Event %d from line %d is ignored\n", tone, pEvt->infcId);
return;
}
- ENDPT_DBG("%s: report event from line %d: %s\n", __func__, pEvt->infcId, ev->name);
+ ENDPT_DBG("report event from line %d: %s\n", pEvt->infcId, ev->name);
if(voice_cb_event_report)
voice_cb_event_report(pEvt->infcId, ev->name, 0);
@@ -581,19 +580,19 @@ int voice_line_init(int has_dect) {
airoha_streams = (strmConfig_t *)calloc(terminal_info.num_voice_ports * AIROHA_STREAMS_PER_CHAN, sizeof(strmConfig_t));
if (!airoha_streams) {
- ENDPT_DBG("Out of memory\n");
+ ENDPT_ERR("Out of memory\n");
return -1;
}
airoha_sockets = (int *)calloc(airoha_sockets_count, sizeof(int));
if (!airoha_sockets) {
- ENDPT_DBG("Out of memory\n");
+ ENDPT_ERR("Out of memory\n");
return -1;
}
ret = adamDspQuery(DSP_MTK, &active, &feature);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("DSP Query failed with error: %d <%s>!\n", ret, etosError(ret));
+ ENDPT_ERR("DSP Query failed with error: %d <%s>!\n", ret, etosError(ret));
return -1;
}
@@ -603,7 +602,7 @@ int voice_line_init(int has_dect) {
ENDPT_DBG("Invoking DSP ...\n");
ret = adamDspInvoke(DSP_MTK);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("DSP Invoke failed with error: %d <%s>!\n", ret, etosError(ret));
+ ENDPT_ERR("DSP Invoke failed with error: %d <%s>!\n", ret, etosError(ret));
return -1;
}
active = STATE_ACTIVE;
@@ -613,7 +612,7 @@ int voice_line_init(int has_dect) {
for (int i = 0; i < (terminal_info.num_voice_ports * AIROHA_STREAMS_PER_CHAN); i++) {
ret = airoha_create_stream(i, feature.strmsPerChan);
if (0 > ret) {
- ENDPT_DBG("Error: airoha_create_stream() returned %d\n", ret);
+ ENDPT_ERR("Error: airoha_create_stream() returned %d\n", ret);
return -1;
}
}
@@ -623,7 +622,7 @@ int voice_line_init(int has_dect) {
lines[i].pending_digits = pe_list_new();
lines[i].priv = calloc(1, sizeof(struct airoha_priv_t));
if(!lines[i].pending_digits || !lines[i].priv) {
- ENDPT_DBG("Out of memory\n");
+ ENDPT_ERR("Out of memory\n");
return -1;
}
@@ -634,7 +633,7 @@ int voice_line_init(int has_dect) {
// "Create" the line.
ret = adamInfcQuery(i, &infcConf);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: adamInfcQuery() failed for ifc: %d, error: %d <%s>!\n", i, ret, etosError(ret));
+ ENDPT_ERR("Error: adamInfcQuery() failed for ifc: %d, error: %d <%s>!\n", i, ret, etosError(ret));
return -1;
}
@@ -651,7 +650,7 @@ int voice_line_init(int has_dect) {
ret = adamInfcConfigHookTs(i, &infcConf.hookTs);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: adamInfcConfigHookTs() failed for ifc: %d, error: %d <%s>!\n", i, ret, etosError(ret));
+ ENDPT_ERR("Error: adamInfcConfigHookTs() failed for ifc: %d, error: %d <%s>!\n", i, ret, etosError(ret));
return -1;
}
@@ -678,7 +677,7 @@ int voice_line_init(int has_dect) {
evt.eventNotify = airoha_evt_cb;
ret = adamPollEvent(BLOCKING, &evt);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: No callback attached, error: %d <%s>\n", ret, etosError(ret));
+ ENDPT_ERR("Error: No callback attached, error: %d <%s>\n", ret, etosError(ret));
return -1;
}
ENDPT_DBG("Callback attached for events!\n");
@@ -698,7 +697,7 @@ int voice_line_is_ready(int line)
ret = adamInfcQuery(infc, &infcConf);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: adamInfcQuery failed for ifc: %d with error: %d <%s>!\n", infc, ret, etosError(ret));
+ ENDPT_ERR("Error: adamInfcQuery failed for ifc: %d with error: %d <%s>!\n", infc, ret, etosError(ret));
ret = 0;
} else {
if ((LINE_DOWN == infcConf.lineState) || (LINE_ERROR == infcConf.lineState))
@@ -717,7 +716,7 @@ int voice_line_is_offhook(int line)
infcConfig_t infcConf;
if (EXEC_SUCCESS != adamInfcQuery(infc, &infcConf)) {
- ENDPT_DBG("Error: adamInfcQuery failed for ifc: %d\n", infc);
+ ENDPT_ERR("Error: adamInfcQuery failed for ifc: %d\n", infc);
return 0;
}
@@ -745,7 +744,7 @@ int voice_line_get_connection_count(int line)
int voice_line_close(int line)
{
if (line < 0 || line >= terminal_info.num_voice_ports) {
- ENDPT_DBG("%s: line number %d is out of range\n", __func__, line);
+ ENDPT_ERR("%s: line number %d is out of range\n", __func__, line);
return -1;
}
@@ -795,7 +794,7 @@ static exCode_e airoha_ring_signal(int infc, char* data, int start)
ret = adamInfcQuery(infc, &infcConf);
if(EXEC_SUCCESS != ret) {
- ENDPT_DBG("adamInfcQuery() failed for ifc %d with error: %d <%s>\n", infc, ret, etosError(ret));
+ ENDPT_ERR("adamInfcQuery() failed for ifc %d with error: %d <%s>\n", infc, ret, etosError(ret));
return ret;
}
@@ -823,20 +822,20 @@ static exCode_e airoha_ring_signal(int infc, char* data, int start)
// Display type II caller ID if number is not empty during off-hook state
ret = adamChanPlayType2Cid(DSP_MTK, airoha_get_chan_by_infc(infc), &infcConf.ring.cid);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("adamChanPlayType2Cid() failed for ifc %d with error: %d <%s>\n",
+ ENDPT_ERR("adamChanPlayType2Cid() failed for ifc %d with error: %d <%s>\n",
infc, ret, etosError(ret));
}
}
} else {
ret = adamInfcRing(infc, infcConf.ring.dur, &infcConf.ring.cid);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("adamInfcRing() failed for ifc %d with error: %d <%s>\n", infc, ret, etosError(ret));
+ ENDPT_ERR("adamInfcRing() failed for ifc %d with error: %d <%s>\n", infc, ret, etosError(ret));
}
}
} else {
ret = adamInfcStopRing(infc);
if(EXEC_SUCCESS != ret) {
- ENDPT_DBG("adamInfcStopRing failed for ifc %d with error: %d <%s>\n", infc, ret, etosError(ret));
+ ENDPT_ERR("adamInfcStopRing failed for ifc %d with error: %d <%s>\n", infc, ret, etosError(ret));
}
}
@@ -866,7 +865,7 @@ static exCode_e airoha_play_tone(int channel, enum TONE_ID toneId, int start)
ret = adamChanPlayTone(DSP_MTK, channel, &toneList, rpt, dur);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: adamChanPlayTone() failed for channel %d, tone '%s'!\n", channel, etosToneDef(toneId));
+ ENDPT_ERR("Error: adamChanPlayTone() failed for channel %d, tone '%s'!\n", channel, etosToneDef(toneId));
return ret;
}
@@ -884,7 +883,7 @@ static exCode_e airoha_play_dtmf(int channel, char digit, int start)
ret = adamChanPlayDtmf(DSP_MTK, channel, digit, dur);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: adamChanPlayDtmf() failed for channel %d, digit '%c'!\n", channel, digit);
+ ENDPT_ERR("Error: adamChanPlayDtmf() failed for channel %d, digit '%c'!\n", channel, digit);
return ret;
}
@@ -900,7 +899,7 @@ static exCode_e airoha_set_channel_ec(chanId_e channel, int ecEnable)
ret = adamChanQuery(DSP_MTK, channel, &cc);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: airoha_set_channel_ec() failed to query channel %d!\n", channel);
+ ENDPT_ERR("Error: airoha_set_channel_ec() failed to query channel %d!\n", channel);
return ret;
}
@@ -911,7 +910,7 @@ static exCode_e airoha_set_channel_ec(chanId_e channel, int ecEnable)
ret = adamChanConfig(DSP_MTK, channel, &cc);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: airoha_set_channel_ec() failed to config channel %d!\n", channel);
+ ENDPT_ERR("Error: airoha_set_channel_ec() failed to config channel %d!\n", channel);
return ret;
}
@@ -926,13 +925,13 @@ exCode_e airoha_start_stream(int channel, int st)
ret = airoha_set_channel_ec(channel, 1);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Cannot set ec on channel %d, stream %d. Error: %s\n", channel, st, etosError(ret));
+ ENDPT_ERR("Cannot set ec on channel %d, stream %d. Error: %s\n", channel, st, etosError(ret));
return ret;
}
ret = adamStrmStart(DSP_MTK, channel, st);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Cannot start stream on channel %d, stream %d. Error: %s\n", channel, st, etosError(ret));
+ ENDPT_ERR("Cannot start stream on channel %d, stream %d. Error: %s\n", channel, st, etosError(ret));
return ret;
}
@@ -949,7 +948,7 @@ exCode_e airoha_update_stream_param(int channel, int st, struct config_update_st
ret = adamStrmQuery(DSP_MTK, channel, st, &active, &tmp_streams);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: Cannot retrieve stream %d configuration for channel %d\n", st, channel);
+ ENDPT_ERR("Error: Cannot retrieve stream %d configuration for channel %d\n", st, channel);
return ret;
}
/* get and set stream parameter */
@@ -980,19 +979,19 @@ exCode_e airoha_update_stream_param(int channel, int st, struct config_update_st
if (count) {
ret = adamStrmStop(DSP_MTK, channel, st);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Cannot stop stream on channel %d, stream %d. Error: %s\n", channel, st, etosError(ret));
+ ENDPT_ERR("Cannot stop stream on channel %d, stream %d. Error: %s\n", channel, st, etosError(ret));
return ret;
}
ret = adamStrmConfig(DSP_MTK, channel, st, &tmp_streams);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Error: Cannot set stream %d configuration for channel %d\n", st, channel);
+ ENDPT_ERR("Error: Cannot set stream %d configuration for channel %d\n", st, channel);
return ret;
}
ret = adamStrmStart(DSP_MTK, channel, st);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Cannot start stream on channel %d, stream %d. Error: %s\n", channel, st, etosError(ret));
+ ENDPT_ERR("Cannot start stream on channel %d, stream %d. Error: %s\n", channel, st, etosError(ret));
return ret;
}
}
@@ -1005,13 +1004,13 @@ exCode_e airoha_stop_stream(int channel, int st)
ret = airoha_set_channel_ec(channel, 0);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Cannot set ec on channel %d, stream %d. Error: %s\n", channel, st, etosError(ret));
+ ENDPT_ERR("Cannot set ec on channel %d, stream %d. Error: %s\n", channel, st, etosError(ret));
return ret;
}
ret = adamStrmStop(DSP_MTK, channel, st);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("Cannot stop stream on channel %d, stream %d. Error: %s\n", channel, st, etosError(ret));
+ ENDPT_ERR("Cannot stop stream on channel %d, stream %d. Error: %s\n", channel, st, etosError(ret));
return ret;
}
@@ -1070,12 +1069,12 @@ int voice_line_signal(int line, int connection, enum VOICE_SIGNAL signal, int st
break;
case VOICE_SIG_INGRESS_DTMF:
default:
- ENDPT_DBG("Unhandled voice signal: %s!\n", etosVoiceEvent(signal));
+ ENDPT_WARN("Unhandled voice signal: %s!\n", etosVoiceEvent(signal));
break;
}
if (status != EXEC_SUCCESS) {
- ENDPT_DBG("%s: failed to %s signal %s, err: %d\n", __func__, start ? "start" : "stop", etosVoiceEvent(signal), status);
+ ENDPT_ERR("%s: failed to %s signal %s, err: %d\n", __func__, start ? "start" : "stop", etosVoiceEvent(signal), status);
return -1;
}
@@ -1091,14 +1090,14 @@ int voice_engine_shutdown(void)
ENDPT_DBG("Revoking DSP ...\n");
ret = adamDspRevoke(DSP_MTK);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("DSP shutdown failed with error: %d <%s>!\n", ret, etosError(ret));
+ ENDPT_ERR("DSP shutdown failed with error: %d <%s>!\n", ret, etosError(ret));
return -1;
}
ENDPT_DBG("Shutdown ADAM ...\n");
ret = adamExit();
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("ADAM shutdown failed with error %d <%s>!\n", ret, etosError(ret));
+ ENDPT_ERR("ADAM shutdown failed with error %d <%s>!\n", ret, etosError(ret));
return -1;
}
@@ -1159,7 +1158,7 @@ int voice_get_rtp_stats(int line, int connection, int reset, struct rtp_stats_t
memset(&pMediaInfo, 0, sizeof(mediaInfo_t));
ret = adamStrmQueryMediaInfo(DSP_MTK, line, STRM0, &pMediaInfo);
if ( EXEC_SUCCESS != ret) {
- ENDPT_DBG("adamStrmQueryMediaInfo() returned with error %d\n", ret);
+ ENDPT_ERR("adamStrmQueryMediaInfo() returned with error %d\n", ret);
return -1;
}
@@ -1278,7 +1277,7 @@ int voice_get_codec_capability(struct codec_capability *pcodecs)
ret = adamDspQuery(DSP_MTK, &active, &feature);
if (EXEC_SUCCESS != ret) {
- ENDPT_DBG("DSP Query failed with error: %d <%s>!\n", ret, etosError(ret));
+ ENDPT_ERR("DSP Query failed with error: %d <%s>!\n", ret, etosError(ret));
return 1;
}
@@ -1339,14 +1338,14 @@ int voice_write_media_packet(const struct media_packet_t *packet) {
server_addr.sin_port = htons ((unsigned short)airoha_streams[packet->line*AIROHA_STREAMS_PER_CHAN].session.srcAddr.rtcpPort);
if(sendto(airoha_priv->socket_id[STRM_0_RTCP_SOCK], packet->rtp, packet->rtp_size, 0,
(struct sockaddr*)&server_addr, server_struct_length) < 0){
- ENDPT_DBG("Error while sending RTCP packet to MTEK DSP\n");
+ ENDPT_ERR("Error while sending RTCP packet to MTEK DSP\n");
return -1;
}
} else {
server_addr.sin_port = htons ((unsigned short)airoha_streams[packet->line*AIROHA_STREAMS_PER_CHAN].session.srcAddr.port);
if(sendto(airoha_priv->socket_id[STRM_0_RTP_SOCK], packet->rtp, packet->rtp_size, 0,
(struct sockaddr*)&server_addr, server_struct_length) < 0){
- ENDPT_DBG("Error while sending RTP packet to MTEK DSP\n");
+ ENDPT_ERR("Error while sending RTP packet to MTEK DSP\n");
return -1;
}
}

View File

@@ -53,7 +53,7 @@ else ifeq ($(CONFIG_TARGET_ipq53xx),y)
TARGET_CFLAGS +=-DIPQ53XX
else ifeq ($(CONFIG_TARGET_mediatek),y)
TARGET_PLATFORM=LINUX
TARGET_WIFI_TYPE=MEDIATEK MAC80211
TARGET_WIFI_TYPE=MAC80211
TARGET_CFLAGS +=-DIOPSYS_LINUX
else
$(info Unexpected CONFIG_TARGET, use default MAC80211)

View File

@@ -16,7 +16,7 @@ PKG_LICENSE_FILES:=LICENSE
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/map-agent
PKG_SOURCE_URL:=git@dev.iopsys.eu:multi-ap/map-agent.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -120,6 +120,7 @@ generate_multiap_config() {
uci set wireless.$secname.default_disabled="1"
uci set wireless.$secname.multi_ap="1"
uci commit wireless
wifi reload
else
ubus call uci set "{\"config\":\"wireless\",\"type\":\"wifi-iface\", \
\"match\":{\"mode\":\"sta\", \"ifname\":\"$ifname\", \"device\":\"$device\"},\"values\":{\"multi_ap\":\"1\"}}" 2>/dev/null

View File

@@ -13,7 +13,7 @@ PKG_MAINTAINER:=Jakob Olsson <jakob.olsson@iopsys.eu>
LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/multi-ap/map-controller
PKG_SOURCE_URL:=git@dev.iopsys.eu:multi-ap/map-controller.git
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)_$(PKG_SOURCE_VERSION).tar.xz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -15,7 +15,7 @@ snooping_bridges=
__device_is_bridge() {
local device="$2"
local devsec__="$(uci show network | grep -F ".name='$device'" | cut -d'.' -f2)"
local devsec__="$(uci show network | grep name=.*$device | grep -v ifname | cut -d'.' -f2)"
local sectype="$(uci -q get network.$devsec__)"
local devtype="$(uci -q get network.$devsec__.type)"
[ "$sectype" != "device" -o "$devtype" != "bridge" ] && return 1

View File

@@ -22,12 +22,4 @@ config OBUSPA_CONTROLLER_MTP_VERIFY
config OBUSPA_ENABLE_TEST_CONTROLLER
bool "Adds a test controller by default"
default n
config OBUSPA_MAX_CONTROLLERS_NUM
int "The maximum number of controllers to be supported"
range 1 10
default 5
help
This value must be in range of 1 to 10. (default 5)
endif

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=obuspa
PKG_VERSION:=7.0.5.5.3
PKG_VERSION:=7.0.5.5
LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/bbf/obuspa.git
PKG_SOURCE_VERSION:=1908e4105b7a2b58f91fbb0d86a2f9a28a9a5e97
PKG_SOURCE_VERSION:=ad32d70ccbe3942b945bf6caf74988bd5660cf96
PKG_MAINTAINER:=Vivek Dutta <vivek.dutta@iopsys.eu>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
@@ -81,10 +81,6 @@ else
CMAKE_OPTIONS += -DENABLE_WEBSOCKETS=OFF
endif
ifdef $(CONFIG_OBUSPA_MAX_CONTROLLERS_NUM)
TARGET_CFLAGS += -DOBUSPA_MAX_CONTROLLERS_NUM=$(CONFIG_OBUSPA_MAX_CONTROLLERS_NUM)
endif
ifeq ($(LOCAL_DEV),1)
define Build/Prepare
$(CP) -rf ~/git/obuspa/* $(PKG_BUILD_DIR)/

View File

@@ -92,10 +92,10 @@ get_base_path()
count=0
if [ -f "${DB_DUMP}" ]; then
path=$(grep -E "${refpath}\d+.Alias \"${value}\"" ${DB_DUMP})
path=$(grep "${refpath}\d.Alias \"${value}\"" ${DB_DUMP})
path=${path%.*}
if [ -z "${path}" ]; then
path=$(grep -oE "${refpath}\d+" ${DB_DUMP} |sort -r|head -n 1)
path=$(grep -o "${refpath}\d" ${DB_DUMP} |sort -r|head -n 1)
if [ -n "${path}" ]; then
count=${path##*.}
count=$(( count + 1 ))
@@ -122,9 +122,9 @@ get_refrence_path()
path=""
if [ -f "${DB_DUMP}" ]; then
path=$(grep -E "${dmref}\d+.Alias " ${DB_DUMP}|grep -w "${value}")
path=$(grep "${dmref}\d.Alias " ${DB_DUMP}|grep -w "${value}")
elif [ -f "${RESET_FILE}" ]; then
path=$(grep -E "${dmref}\d+.Alias " ${RESET_FILE}|grep -w "${value}")
path=$(grep "${dmref}\d.Alias " ${RESET_FILE}|grep -w "${value}")
fi
path=${path%.*}
echo "${path}"
@@ -728,13 +728,13 @@ get_instances_from_db_dump()
{
local obj inst
obj="${1}\d+"
obj="${1}\d"
if [ ! -f "${DB_DUMP}" ]; then
echo ""
return 0;
fi
inst="$(grep -oE "${obj}" "${DB_DUMP}"|uniq)"
inst="$(grep -oe "${obj}" "${DB_DUMP}"|uniq)"
echo "$inst"
}
@@ -942,7 +942,7 @@ check_n_delete_db()
r="${3}"
sec="${sec/${t}_/cpe-}"
path=$(grep -E "${r}\d+.Alias \"${sec}\"" ${DB_DUMP})
path=$(grep "${r}\d.Alias \"${sec}\"" ${DB_DUMP})
path=${path%.*}
delete_sql_db_entry_with_pattern "${path}"

View File

@@ -544,23 +544,6 @@
"PERMIT_SUBS_OBJ_DEL",
"PERMIT_SUBS_EVT_OPER_COMP"
]
},
{
"object":"Device.SSH.",
"perm": [
"PERMIT_GET",
"PERMIT_GET_INST",
"PERMIT_OBJ_INFO",
"PERMIT_CMD_INFO",
"PERMIT_SET",
"PERMIT_ADD",
"PERMIT_DEL",
"PERMIT_OPER",
"PERMIT_SUBS_VAL_CHANGE",
"PERMIT_SUBS_OBJ_ADD",
"PERMIT_SUBS_OBJ_DEL",
"PERMIT_SUBS_EVT_OPER_COMP"
]
}
]
},
@@ -775,6 +758,27 @@
"PERMIT_SUBS_EVT_OPER_COMP"
]
},
{
"object":"Device.SoftwareModules.",
"perm": [
"PERMIT_GET",
"PERMIT_GET_INST",
"PERMIT_OBJ_INFO",
"PERMIT_CMD_INFO",
"PERMIT_SUBS_VAL_CHANGE",
"PERMIT_SUBS_EVT_OPER_COMP"
]
},
{
"object":"Device.Users.",
"perm": [
"PERMIT_GET",
"PERMIT_GET_INST",
"PERMIT_OBJ_INFO",
"PERMIT_CMD_INFO",
"PERMIT_SUBS_EVT_OPER_COMP"
]
},
{
"object": "Device.LocalAgent.Subscription.",
"perm": [

View File

@@ -1,42 +0,0 @@
diff --git a/src/core/mqtt.c b/src/core/mqtt.c
index 04a1a9c..8cb2ad7 100644
--- a/src/core/mqtt.c
+++ b/src/core/mqtt.c
@@ -234,6 +234,8 @@ void HandleMqttDisconnect(mqtt_client_t *client);
#define DEFINE_MQTT_TrustCertVerifyCallbackIndex(index) \
int MQTT_TrustCertVerifyCallback_##index (int preverify_ok, X509_STORE_CTX *x509_ctx) \
{\
+ if (index >= MAX_MQTT_CLIENTS) \
+ return 0; \
return DEVICE_SECURITY_TrustCertVerifyCallbackWithCertChain(preverify_ok, x509_ctx, &mqtt_clients[index].cert_chain);\
}
@@ -244,6 +246,11 @@ DEFINE_MQTT_TrustCertVerifyCallbackIndex(1);
DEFINE_MQTT_TrustCertVerifyCallbackIndex(2);
DEFINE_MQTT_TrustCertVerifyCallbackIndex(3);
DEFINE_MQTT_TrustCertVerifyCallbackIndex(4);
+DEFINE_MQTT_TrustCertVerifyCallbackIndex(5);
+DEFINE_MQTT_TrustCertVerifyCallbackIndex(6);
+DEFINE_MQTT_TrustCertVerifyCallbackIndex(7);
+DEFINE_MQTT_TrustCertVerifyCallbackIndex(8);
+DEFINE_MQTT_TrustCertVerifyCallbackIndex(9);
// Add more, with incrementing indexes here, if you change MAX_MQTT_CLIENTS
//------------------------------------------------------------------------------------
@@ -254,10 +261,15 @@ ssl_verify_callback_t* mqtt_verify_callbacks[] = {
MQTT_TrustCertVerifyCallbackIndex(2),
MQTT_TrustCertVerifyCallbackIndex(3),
MQTT_TrustCertVerifyCallbackIndex(4),
+ MQTT_TrustCertVerifyCallbackIndex(5),
+ MQTT_TrustCertVerifyCallbackIndex(6),
+ MQTT_TrustCertVerifyCallbackIndex(7),
+ MQTT_TrustCertVerifyCallbackIndex(8),
+ MQTT_TrustCertVerifyCallbackIndex(9),
// Add more, with incrementing indexes here, if you change MAX_MQTT_CLIENTS
};
-USP_COMPILEASSERT( ((sizeof(mqtt_verify_callbacks)/sizeof(ssl_verify_callback_t*)) == MAX_MQTT_CLIENTS),
+USP_COMPILEASSERT( ((sizeof(mqtt_verify_callbacks)/sizeof(ssl_verify_callback_t*)) >= MAX_MQTT_CLIENTS),
"There must be MAX_MQTT_CLIENTS callbacks defined");
/*********************************************************************//**

View File

@@ -15,6 +15,10 @@ include /lib/ethernet
. /lib/qos/shaper.sh
. /lib/qos/airoha.sh
get_rate_per_queue() {
echo "0"
}
get_burst_size_per_queue() {
echo "0"
}

View File

@@ -34,6 +34,10 @@ get_port_number() {
done
}
get_rate_per_queue() {
echo "0"
}
get_burst_size_per_queue() {
echo "0"
}

View File

@@ -31,7 +31,7 @@ generate_queue(){
uci set qos.@queue[-1].ifname="$ifname"
uci set qos.@queue[-1].precedence="$order"
uci set qos.@queue[-1].scheduling="SP"
uci set qos.@queue[-1].rate="0"
uci set qos.@queue[-1].rate=$(get_rate_per_queue)
uci set qos.@queue[-1].burst_size=$(get_burst_size_per_queue)
uci set qos.@queue[-1].weight="1"
done

View File

@@ -15,6 +15,10 @@ Q_COUNT=0
SP_Q_PRIO=7
SOQ_wgt=0
get_rate_per_queue() {
echo "1000000"
}
get_burst_size_per_queue() {
echo "1500"
}
@@ -401,20 +405,18 @@ pre_configure_queue() {
}
get_link_rate() {
local ifname="$1"
local phycap="$(ethtool $ifname | grep -A 10 "Supported link modes" | grep 00 | tail -n 1 | awk '{print$NF}')"
local speed=1000
intf="$1"
speed=1000
# Get the max capability of this port
case "$phycap" in
10000*) speed=10000 ;;
5000*) speed=5000 ;;
2500*) speed=2500 ;;
1000*) speed=1000 ;;
100*) speed=100 ;;
10*) speed=10 ;;
*) speed=1000 ;;
esac
if [ -d "/sys/class/net/$intf/" ]; then
speed=$(cat /sys/class/net/$intf/speed 2>/dev/null)
[ -z "$speed" ] & speed=1000
fi
if [ $speed -le 0 ]; then
# assuming default 1000
speed=1000
fi
echo "$speed"
}

View File

@@ -5,11 +5,11 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sulu-base
PKG_VERSION:=3.1.48
PKG_VERSION:=3.1.42
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/sulu.git
PKG_SOURCE_VERSION:=5debc3b288afdce678f906f70aa25129d5a45d1e
PKG_SOURCE_VERSION:=6a0cc2795607895bbe8c8e3598e3f5f435af3499
PKG_MIRROR_HASH:=skip
SULU_MOD:=core

View File

@@ -5,12 +5,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sulu-builder
PKG_VERSION:=3.1.48
PKG_VERSION:=3.1.42
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/websdk/sulu-builder.git
PKG_SOURCE_VERSION:=cf80e7df81b840765297cf776baaceba38e462de
PKG_SOURCE_VERSION:=76cb288b1496756e8ed43368348127ecfef5751d
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_SOURCE_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz
PKG_BUILD_DIR:=$(BUILD_DIR)/sulu-$(PKG_VERSION)/sulu-builder-$(PKG_SOURCE_VERSION)
@@ -179,13 +179,7 @@ endef
define Package/sulu-builder/install
$(Package/sulu/install/Default)
$(INSTALL_DIR) $(1)/sulu/presets
$(INSTALL_DIR) $(1)/sulu/settings
$(INSTALL_DIR) $(1)/sulu/widget-presets
$(CP) $(PKG_BUILD_DIR)/build/dist/* $(1)/sulu
$(INSTALL_DATA) $(PKG_BUILD_DIR)/build/device/presets/*.json $(1)/sulu/presets/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/build/device/settings/*.json $(1)/sulu/settings/
$(INSTALL_DATA) $(PKG_BUILD_DIR)/build/device/widget-presets/*.json $(1)/sulu/widget-presets/
$(Package/sulu/install/Post)
endef

View File

@@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=tr104
PKG_VERSION:=1.0.13.1
PKG_VERSION:=1.0.12
LOCAL_DEV:=0
ifeq ($(LOCAL_DEV),0)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/voice/tr104.git
PKG_SOURCE_VERSION:=6a079febd5b0ab83a620e2462a714836d961a90e
PKG_SOURCE_VERSION:=393ad165e64413067de84b452126aebf4bcbcb2d
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=voicemngr
PKG_RELEASE:=1
PKG_VERSION:=1.1.4
PKG_VERSION:=1.1.2
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
@@ -19,7 +19,7 @@ LOCAL_DEV=0
ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/iopsys/$(PKG_NAME).git
PKG_SOURCE_VERSION:=0d6359b41d4983fdfeee9e1fb1fdc0c89c40715c
PKG_SOURCE_VERSION:=25571796f18c91a2070f98881bd1205f15575fea
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip
endif

View File

@@ -1,921 +0,0 @@
diff --git a/Makefile b/Makefile
index 1662f3d..6237ba9 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,6 @@
#
HEADERS := $(shell ls ./*.h)
SRCS := $(shell ls ./*.c)
-LIBVOICE := ./libvoice/libvoice.so
VOICEMNGR := voicemngr
CFLAGS += -O2 -fcaller-saves -fsection-anchors
@@ -24,10 +23,10 @@ all: debug $(VOICEMNGR)
%.o: %.c $(HEADERS) Makefile
$(CC) $(CFLAGS) -c -o $@ $<
-$(LIBVOICE):
+LIBVOICE:
$(MAKE) -C libvoice
-$(VOICEMNGR): $(LIBVOICE) $(OBJS)
+$(VOICEMNGR): LIBVOICE $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
clean:
diff --git a/libvoice/common.c b/libvoice/common.c
index cee4598..a7d1311 100644
--- a/libvoice/common.c
+++ b/libvoice/common.c
@@ -81,12 +81,12 @@ void (*voice_cb_event_report)(int line, const char *event, int data) = NULL;
// Callback function which is invoked when an encoded media packet is generated by the voice engine
void (*voice_cb_egress_media)(const struct media_packet_t *packet, int size) = NULL;
-void voice_syslog(const char *fmt, ...)
+void voice_syslog(int level, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- vsyslog(LOG_DEBUG, fmt, ap);
+ vsyslog(level, fmt, ap);
va_end(ap);
}
@@ -115,7 +115,7 @@ int voice_line_preinit(void) {
// Initialize all contents as 0 by calloc
lines = calloc(terminal_info.num_voice_ports, sizeof(struct line_t));
if(!lines) {
- ENDPT_DBG("%s: out out memory\n", __func__);
+ ENDPT_ERR("%s: out out memory\n", __func__);
return -1;
}
for(i = 0; i < terminal_info.num_voice_ports; i++) {
diff --git a/libvoice/libvoice.h b/libvoice/libvoice.h
index 0446a23..dcb5d90 100644
--- a/libvoice/libvoice.h
+++ b/libvoice/libvoice.h
@@ -8,6 +8,7 @@
#include <stdint.h>
#include <sys/time.h>
#include <time.h>
+#include <syslog.h>
#include <libpicoevent.h>
#include "voice-types.h"
@@ -230,10 +231,15 @@ struct codec_capability {
printf(fmt, ##__VA_ARGS__); \
} while (0)
#else
-#define ENDPT_DBG(...) voice_syslog("voice: " __VA_ARGS__)
+#define ENDPT_DBG(format, ...) voice_syslog(LOG_DEBUG, "%s:%d %s: " format, \
+ __FILE__, __LINE__, __func__, ##__VA_ARGS__)
#endif
#define CHECK_POINT() ENDPT_DBG("Check point at %s@%s:%d\n", __func__, __FILE__, __LINE__)
+#define ENDPT_INFO(...) voice_syslog(LOG_INFO, __VA_ARGS__)
+#define ENDPT_WARN(...) voice_syslog(LOG_WARNING, __VA_ARGS__)
+#define ENDPT_ERR(...) voice_syslog(LOG_ERR, __VA_ARGS__)
+
extern struct terminal_info_t terminal_info;
extern struct line_t *lines;
extern struct connection_t *connections;
@@ -267,7 +273,7 @@ int voice_line_signal(int line, int connection, enum VOICE_SIGNAL signal, int st
int voice_line_simulate_hook(int line, enum VOICE_EVENT event);
// Misc
-void voice_syslog(const char *fmt, ...);
+void voice_syslog(int level, const char *fmt, ...);
int voice_engine_shutdown(void);
int voice_get_min_tx_gain(void);
int voice_get_max_tx_gain(void);
diff --git a/line-dect.c b/line-dect.c
index a9c97d4..efec60b 100644
--- a/line-dect.c
+++ b/line-dect.c
@@ -52,8 +52,8 @@ int ubus_process_queued_reqs_to_dectmngr(void) {
if (!req)
return 0;
- ENDPT_DBG("%s: Poped DECT req %p from list, action: %d pcmId: %d, caller_id: %s, callerName: %s\n", __func__, req, req->action,
- req->pcm_id, req->caller_id, req->caller_name);
+ ENDPT_DBG("Poped DECT req %p from list, action: %d pcmId: %d, caller_id: %s, callerName: %s\n",
+ req, req->action, req->pcm_id, req->caller_id, req->caller_name);
pcm_states_dump(__func__, req->line);
switch (req->action) {
@@ -102,7 +102,7 @@ int simulate_digits_pressing(int line, const char *pressed_digits) {
if(lines[line].type != VOICE_LINE_DECT)
return 0;
- ENDPT_DBG("%s(): line: %d pressed_digits: %s\n", __func__, line, (pressed_digits ? pressed_digits : ""));
+ ENDPT_DBG("line: %d pressed_digits: %s\n", line, (pressed_digits ? pressed_digits : ""));
// Store digits in a list.
if(pressed_digits && lines[line].pending_digits) {
@@ -138,7 +138,7 @@ int ubus_cb_dectmngr_replied(struct line_req_t *req, enum ubus_msg_status reply_
if(!req)
return -1;
- ENDPT_DBG("%s got answer req %p from dectmngr, action: %d, line: %d, pcmId: %d, conId: %d\n", __func__,
+ ENDPT_DBG("got answer req %p from dectmngr, action: %d, line: %d, pcmId: %d, conId: %d\n",
req, req->action, req->line, req->pcm_id, req->connection_id);
pcm_states_dump(__func__, req->line);
@@ -190,10 +190,12 @@ int ubus_cb_asterisk_replied(struct line_event_t *lineEv, enum ubus_msg_status r
struct line_req_t *req;
int epEvntIdx, dectEvntIdx;
- if(!lineEv || !voice_line_is_ready(lineEv->line))
+ if(!lineEv || !voice_line_is_ready(lineEv->line)) {
+ ENDPT_ERR("Invalid argument\n");
return -1;
+ }
- ENDPT_DBG("%s started\n", __func__);
+ ENDPT_DBG("started\n");
if(lines[lineEv->line].simulated_hook) {
voice_hook_simulation_maintain(lineEv->line);
@@ -218,7 +220,7 @@ int ubus_cb_asterisk_replied(struct line_event_t *lineEv, enum ubus_msg_status r
return 0; // None found, then do nothing
assert(req->ubus.ctx);
- ENDPT_DBG("%s: poped Asterisk req %p line %d event %s from list, action %d\n", __func__,
+ ENDPT_DBG("poped Asterisk req %p line %d event %s from list, action %d\n",
req, lineEv->line, lineEv->name, req->action);
if(reply_status == UBUS_STATUS_OK) {
diff --git a/line.c b/line.c
index 282bf0a..77d97ef 100644
--- a/line.c
+++ b/line.c
@@ -87,7 +87,7 @@ static int perhaps_simulate_busy(int line, struct voice_ubus_req_t *ubus_req)
msg->line = line;
send_event_main(msg, EVENT_MAIN_LINE);
} else {
- ENDPT_DBG("%s: out of memory\n", __func__);
+ ENDPT_ERR("%s: out of memory\n", __func__);
}
return 1;
@@ -97,13 +97,13 @@ static int perhaps_simulate_busy(int line, struct voice_ubus_req_t *ubus_req)
static int dect_tone_play(int line, int pcm, enum VOICE_SIGNAL signal, const char *data, struct voice_ubus_req_t *ubus_req)
{
struct line_req_t *line_req = NULL;
- ENDPT_DBG("%s: line=%d, pcm=%d, data=%s\n", __func__, line, pcm, data);
+ ENDPT_DBG("line=%d, pcm=%d, data=%s\n", line, pcm, data);
pcm_states_dump(__func__, line);
assert(ubus_req);
line_req = calloc(1, sizeof(struct line_req_t));
if(!line_req) {
- ENDPT_DBG("%s: out of memory\n", __func__);
+ ENDPT_ERR("%s: out of memory\n", __func__);
return -1;
}
line_req->line = line;
@@ -120,7 +120,7 @@ static int dect_tone_play(int line, int pcm, enum VOICE_SIGNAL signal, const cha
return -1;
}
- ENDPT_DBG("%s: line %d set pcm to %d\n", __func__, line, line_req->pcm_id);
+ ENDPT_DBG("line %d set pcm to %d\n", line, line_req->pcm_id);
memcpy(&line_req->ubus, ubus_req, sizeof(struct voice_ubus_req_t));
assert(lines[line].type == VOICE_LINE_DECT);
@@ -158,7 +158,7 @@ static int line_signal_ring(int line, int pcm, enum VOICE_SIGNAL signal, const c
struct line_req_t *line_req = NULL;
int start_ring = data && strcmp(data, "0") != 0;
- ENDPT_DBG("%s: line=%d, pcm=%d, data=%s\n", __func__, line, pcm, data);
+ ENDPT_DBG("line=%d, pcm=%d, data=%s\n", line, pcm, data);
pcm_states_dump(__func__, line);
// Relay the request to dectmngr if the line is DECT
@@ -166,13 +166,13 @@ static int line_signal_ring(int line, int pcm, enum VOICE_SIGNAL signal, const c
assert(ubus_req);
line_req = calloc(1, sizeof(struct line_req_t));
if(!line_req) {
- ENDPT_DBG("%s: out of memory\n", __func__);
+ ENDPT_ERR("%s: out of memory\n", __func__);
return -1;
}
line_req->line = line;
line_req->connection_id = -1;
line_req->pcm_id = pcm;
- ENDPT_DBG("%s: line %d set pcm to %d\n", __func__, line, line_req->pcm_id);
+ ENDPT_DBG("line %d set pcm to %d\n", line, line_req->pcm_id);
memcpy(&line_req->ubus, ubus_req, sizeof(struct voice_ubus_req_t));
// Parse the called ID string generated by Asterisk
@@ -240,7 +240,7 @@ static int line_signal_answer(int line, int pcm, const char *data, struct voice_
{
struct line_req_t *line_req = NULL;
- ENDPT_DBG("%s() line %d pcm: %d data: %s\n", __func__, line, pcm, data);
+ ENDPT_DBG("line %d pcm: %d data: %s\n", line, pcm, data);
pcm_states_dump(__func__, line);
assert(ubus_req);
@@ -269,12 +269,12 @@ int line_signal(int line, const char *signame, const char *data, struct voice_ub
const struct voice_signal_t *sig;
int res = 0;
- ENDPT_DBG("%s: line=%d(type:%d), signame=%s, data=%s\n", __func__, line, lines[line].type, signame, data);
+ ENDPT_DBG("line=%d(type:%d), signame=%s, data=%s\n", line, lines[line].type, signame, data);
for(sig = signal_map; sig->signal != VOICE_SIG_LAST && strcmp(signame, sig->name) != 0; sig++)
continue;
if(sig->signal == VOICE_SIG_LAST) {
- ENDPT_DBG("%s: signal %s is not supported\n", __func__, signame);
+ ENDPT_ERR("%s: signal %s is not supported\n", __func__, signame);
return -1;
}
@@ -362,9 +362,9 @@ int line_signal(int line, const char *signame, const char *data, struct voice_ub
}
if (res == 0) {
- ENDPT_DBG("%s: signal %s(%s) was set for line %d\n", __func__, sig->name, data, line);
+ ENDPT_INFO("signal %s(%s) was set for line %d\n", sig->name, data, line);
} else {
- ENDPT_DBG("%s: error setting signal %s(%s)\n", __func__, sig->name, data);
+ ENDPT_ERR("%s: error setting signal %s(%s)\n", __func__, sig->name, data);
}
return res;
@@ -398,7 +398,7 @@ int line_new_connection_by_asterisk(int line, int connection, struct voice_ubus_
* chance to relay it to dectmngr. */
line_req = calloc(1, sizeof(struct line_req_t));
if(!line_req) {
- ENDPT_DBG("%s: out of memory\n", __func__);
+ ENDPT_ERR("%s: out of memory\n", __func__);
return -1;
}
line_req->line = line;
@@ -425,7 +425,7 @@ int line_connection_parm_update_by_asterisk(int line, int connection, struct con
if (!voice_line_is_ready(line))
return -1;
- ENDPT_DBG("parm_update request for %s line: %d, connection: %d, mask: %d, codec: %d, ptime: %d \n", __func__, line, connection, data->mask, data->codec, data->ptime);
+ ENDPT_DBG("parm_update request for line: %d, connection: %d, mask: %d, codec: %d, ptime: %d \n", line, connection, data->mask, data->codec, data->ptime);
pcm_states_dump(__func__, line);
res = voice_connection_parm_update(line, line, data);
@@ -554,8 +554,7 @@ int line_update_connection_by_pbx(int line, int pcm_callid)
if (!voice_line_is_ready(line))
return -1;
- ENDPT_DBG("%s Received update connection for line: %d with pcm_callid: %d\n",
- __func__, line, pcm_callid);
+ ENDPT_DBG("Received update connection for line: %d with pcm_callid: %d\n", line, pcm_callid);
pcm_states_dump(__func__, line);
if(lines[line].type != VOICE_LINE_DECT)
@@ -580,7 +579,7 @@ int line_new_connection_by_dect(int line, const char *cid, int pcm, struct voice
if (!voice_line_is_ready(line) || lines[line].type != VOICE_LINE_DECT)
return -1;
- ENDPT_DBG("%s: line=%d, pcm=%d, cid=%s\n", __func__, line, pcm, cid);
+ ENDPT_DBG("line=%d, pcm=%d, cid=%s\n", line, pcm, cid);
pcm_states_dump(__func__, line);
if (pcm <= PCM_1) {
@@ -640,17 +639,17 @@ int line_close_connection_by_dect(int line, int pcm, struct voice_ubus_req_t *ub
return -1;
if(lines[line].type != VOICE_LINE_DECT) {
- ENDPT_DBG("%s: lines[%d].type != VOICE_LINE_DECT\n", __func__, line);
+ ENDPT_ERR("%s: lines[%d].type != VOICE_LINE_DECT\n", __func__, line);
return -1;
}
- ENDPT_DBG("%s() for line %d, pcm: %d\n", __func__, line, pcm);
+ ENDPT_DBG("line %d: pcm = %d\n", line, pcm);
pcm_states_dump(__func__, line);
if (pcm == CALL_DECT_UNAVAILABLE) {
struct line_event_t *msg;
- ENDPT_DBG("%s: There is no available DECT handsets for the call. "
- "Send DECT_UNAVAILABLE event to Asterisk\n", __func__);
+ ENDPT_DBG("There is no available DECT handsets for the call. "
+ "Send DECT_UNAVAILABLE event to Asterisk\n");
msg = malloc(sizeof(struct line_event_t));
if (msg) {
@@ -668,8 +667,8 @@ int line_close_connection_by_dect(int line, int pcm, struct voice_ubus_req_t *ub
if (get_callid_state(lines[line].pcm_callid[(pcm >> 16)]) == CALLID_OBTAINING) {
struct line_event_t *msg;
- ENDPT_DBG("%s: DECT handsets may have not answered the call yet. "
- "Send CALL_REJECT event to Asterisk\n", __func__);
+ ENDPT_DBG("DECT handsets may have not answered the call yet. "
+ "Send CALL_REJECT event to Asterisk\n");
msg = malloc(sizeof(struct line_event_t));
if (msg) {
diff --git a/main.c b/main.c
index 83aa443..f083c8d 100644
--- a/main.c
+++ b/main.c
@@ -19,6 +19,8 @@
#include "main.h"
#include "ubus.h"
+
+int log_level = LOG_INFO;
static int audio_rx_fd;
static int audio_tx_fd;
static int event_fd;
@@ -44,7 +46,7 @@ void send_media_to_voice_engine(pe_packet_t *p) {
conIdx = voice_connection_find(packet->line, packet->connection_id);
if (conIdx == -1 || (packet->rtp[0] != 0x80 && packet->rtp[0] != 0x81) || !packet->rtp_size) {
- ENDPT_DBG("%s: bad packet\n", __func__);
+ ENDPT_ERR("%s: bad packet\n", __func__);
return;
}
@@ -103,7 +105,7 @@ static void event_stream_handler(pe_stream_t *stream __attribute__((unused)), pe
break;
default:
- ENDPT_DBG("Warning: unknown event '%c'\n", *event->in);
+ ENDPT_WARN("unknown event '%c'\n", *event->in);
break;
}
}
@@ -194,7 +196,7 @@ static void voicemngr_event_report(int line, const char *event, int data) {
struct line_event_t *msg = malloc(sizeof(struct line_event_t));
if (!msg) {
- ENDPT_DBG("%s: out of memory\n", __func__);
+ ENDPT_ERR("%s: out of memory\n", __func__);
return;
}
msg->name = event;
@@ -211,7 +213,7 @@ static int voicemngr_get_voice_port_cfg(const char *hw_board_voice_names, struct
char *str, *token, *saveptr;
if (!hw_board_voice_names || *hw_board_voice_names == '\0') {
- ENDPT_DBG("%s: environmental variable hw_board_VoicePortNames is not defined or empty\n", __func__);
+ ENDPT_ERR("%s: environmental variable hw_board_VoicePortNames is not defined or empty\n", __func__);
return -1;
}
@@ -221,28 +223,28 @@ static int voicemngr_get_voice_port_cfg(const char *hw_board_voice_names, struct
* might cause the wrong value being returned when running the program multiple times */
duplication = strdup(hw_board_voice_names);
if (!duplication) {
- ENDPT_DBG("%s: out of memory\n", __func__);
+ ENDPT_ERR("%s: out of memory\n", __func__);
return -1;
}
- ENDPT_DBG("%s: hw_board_voice_names=[%s]\n", __func__, hw_board_voice_names);
+ ENDPT_DBG("hw_board_voice_names=[%s]\n", hw_board_voice_names);
for (str = duplication; (token = strtok_r(str, " ,;:\t", &saveptr)) != NULL; str = NULL) {
if ((size_t)voice_port_cfg->num_voice_ports >=
sizeof(voice_port_cfg->voice_ports) / sizeof(voice_port_cfg->voice_ports)[0]) {
- ENDPT_DBG("%s: too many voice ports\n", __func__);
+ ENDPT_ERR("%s: too many voice ports\n", __func__);
res = -1;
break;
}
if (strcasestr(token, "Tel") != NULL || strcasestr(token, "FXS") != NULL) {
- ENDPT_DBG("%s: port %d is FXS\n", __func__, voice_port_cfg->num_voice_ports);
+ ENDPT_INFO("%s: port %d is FXS\n", __func__, voice_port_cfg->num_voice_ports);
voice_port_cfg->voice_ports[voice_port_cfg->num_voice_ports++] = VOICE_LINE_FXS;
voice_port_cfg->num_fxs++;
} else if (strcasestr(token, "DECT") != NULL) {
- ENDPT_DBG("%s: port %d is DECT\n", __func__, voice_port_cfg->num_voice_ports);
+ ENDPT_INFO("%s: port %d is DECT\n", __func__, voice_port_cfg->num_voice_ports);
voice_port_cfg->voice_ports[voice_port_cfg->num_voice_ports++] = VOICE_LINE_DECT;
voice_port_cfg->num_dect++;
} else {
- ENDPT_DBG("%s: invalid port type, %s\n", __func__, token);
+ ENDPT_ERR("%s: invalid port type, %s\n", __func__, token);
res = -1;
break;
}
@@ -252,7 +254,8 @@ static int voicemngr_get_voice_port_cfg(const char *hw_board_voice_names, struct
return res;
}
-int main(void) {
+int main(int argc, char **argv) {
+ (void) argc;
struct uci_context *context = NULL;
struct uci_package *package = NULL;
struct terminal_info_t voice_port_cfg;
@@ -261,29 +264,35 @@ int main(void) {
const char *hw_board_has_dect;
const char *hw_board_voice_names;
+ openlog(argv[0], LOG_PID, LOG_DAEMON);
+
// Load the UCI package
context = uci_alloc_context();
if (!context) {
- ENDPT_DBG("uci_alloc_context() failed\n");
+ ENDPT_ERR("uci_alloc_context() failed\n");
return EXIT_FAILURE;
}
res = uci_load(context, uciStrConfig, &package);
if (res != 0 || !package) {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to load uci package %s, %s\n", uciStrConfig, error);
+ ENDPT_ERR("Failed to load uci package %s, %s\n", uciStrConfig, error);
free(error);
uci_free_context(context);
context = NULL;
return EXIT_FAILURE;
}
+ config_syslog(context, package);
+ ENDPT_INFO("syslog level is set to %d\n", log_level);
+ setlogmask(LOG_UPTO(log_level));
+
// Unbuffered stdout
if(isatty(STDOUT_FILENO))
setbuf(stdout, NULL);
// Check that ASCII to DTMF convertion works.
if(!isdigit('0') || !isalpha('a')) {
- ENDPT_DBG("Source has invalid encoding.\n");
+ ENDPT_ERR("Source has invalid encoding.\n");
goto __error_ret;
}
@@ -322,12 +331,12 @@ int main(void) {
// Enable UBUS when all initializations have finished
if(ubus_enable_receive()) goto __error_ret;
- ENDPT_DBG("voicemngr has started successfully\n");
+ ENDPT_INFO("voicemngr has started successfully\n");
// Listen for events and dispatch them to handlers. Run forever and does not return.
pe_base_dispatch(picoBase);
- ENDPT_DBG("pe_base_dispatch() exited unexpectedly\n");
+ ENDPT_WARN("pe_base_dispatch() exited unexpectedly\n");
__error_ret:
if (package)
diff --git a/ubus.c b/ubus.c
index ef8c15b..d018545 100644
--- a/ubus.c
+++ b/ubus.c
@@ -19,6 +19,8 @@
#define UBUS_DECTMNGR_TIMEOUT 15 // Long enough for blocked last handset terminal delete to finish
#define UBUS_ASTERISK_TIMEOUT 5
+extern int log_level;
+
enum {
STATUS_LINE,
};
@@ -135,6 +137,7 @@ static const char broadcast_path[] = "voice.endpoint"; // UBUS path name for b
static const char uciStrComSect[] = "tel_options"; // Common endpoint section name
static const char uciStrLineSect[] = "extension"; // Line specific section name
static const char uciStrCountry[] = "country"; // Endpoint country
+static const char uciStrLoglevel[] = "vmloglevel"; // syslog level of voicemngr
static const char ubusStrObjAdd[] = "ubus.object.add"; // UBUS objects added to global context
static const char ubusStrObjRm[] = "ubus.object.remove"; // UBUS objects added removed from global context
@@ -232,7 +235,7 @@ static void timerHandler(pe_stream_t *stream, pe_event_t *event __attribute__((u
expired = 0;
res = read(outReq->timerFd, &expired, sizeof(expired));
if(res == -1 && errno != EAGAIN) {
- perror("Error, reading timer fd");
+ ENDPT_ERR("reading timer fd: %s", strerror(errno));
}
if(!expired)
return;
@@ -336,7 +339,7 @@ static void uci_query_lineX(struct uci_context *context, struct uci_section *sec
char *error;
if(phoneLine < 0 || phoneLine >= terminal_info.num_voice_ports) {
- ENDPT_DBG("Error, invalid phone line %d\n", phoneLine);
+ ENDPT_ERR("Error, invalid phone line %d\n", phoneLine);
return;
}
@@ -344,7 +347,7 @@ static void uci_query_lineX(struct uci_context *context, struct uci_section *sec
strVal = uci_lookup_option_string(context, section, option);
if (!strVal || !*strVal) {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to look up line option %s, %s\n", option, error);
+ ENDPT_ERR("Failed to look up line option %s, %s\n", option, error);
free(error);
} else {
ENDPT_DBG(" %s=%s\n", option, strVal);
@@ -356,7 +359,7 @@ static void uci_query_lineX(struct uci_context *context, struct uci_section *sec
strVal = uci_lookup_option_string(context, section, option);
if (!strVal || !*strVal) {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to look up line option %s, %s\n", option, error);
+ ENDPT_ERR("Failed to look up line option %s, %s\n", option, error);
free(error);
} else {
intVal = strtol(strVal, NULL, 10);
@@ -365,7 +368,7 @@ static void uci_query_lineX(struct uci_context *context, struct uci_section *sec
lines[phoneLine].line_conf.silence = (intVal ? 1 : 0);
ENDPT_DBG(" %s=%d\n", option, intVal);
} else {
- ENDPT_DBG(" Error: %s range is 0-1\n", option);
+ ENDPT_ERR("Error comfort_noise value: '%s', not in range '0' - '1'\n", strVal);
}
}
@@ -373,7 +376,7 @@ static void uci_query_lineX(struct uci_context *context, struct uci_section *sec
strVal = uci_lookup_option_string(context, section, option);
if (!strVal || !*strVal) {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to look up line option %s, %s\n", option, error);
+ ENDPT_ERR("Failed to look up line option %s, %s\n", option, error);
free(error);
} else {
intVal = strtol(strVal, NULL, 10);
@@ -381,7 +384,7 @@ static void uci_query_lineX(struct uci_context *context, struct uci_section *sec
lines[phoneLine].line_conf.echo_cancel = (intVal ? 1 : 0);
ENDPT_DBG(" %s=%d\n", option, intVal);
} else {
- ENDPT_DBG(" Error: %s range is 0-1\n", option);
+ ENDPT_ERR("Error echo_cancel value: '%s', not in range '0' - '1'\n", strVal);
}
}
@@ -389,7 +392,7 @@ static void uci_query_lineX(struct uci_context *context, struct uci_section *sec
strVal = uci_lookup_option_string(context, section, option);
if (!strVal || !*strVal) {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to look up line option %s, %s\n", option, error);
+ ENDPT_ERR("Failed to look up line option %s, %s\n", option, error);
free(error);
} else {
intVal = strtol(strVal, NULL, 10);
@@ -397,7 +400,7 @@ static void uci_query_lineX(struct uci_context *context, struct uci_section *sec
lines[phoneLine].line_conf.txgain = intVal;
ENDPT_DBG(" %s=%d\n", option, intVal);
} else {
- ENDPT_DBG(" Error: %s range is %d - %d\n", option, voice_get_min_tx_gain(), voice_get_max_tx_gain());
+ ENDPT_ERR("Error txgain value: '%s', not in range %d - %d\n", strVal, voice_get_min_tx_gain(), voice_get_max_tx_gain());
}
}
@@ -405,7 +408,7 @@ static void uci_query_lineX(struct uci_context *context, struct uci_section *sec
strVal = uci_lookup_option_string(context, section, option);
if (!strVal || !*strVal) {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to look up line option %s, %s\n", option, error);
+ ENDPT_ERR("Failed to look up line option %s, %s\n", option, error);
free(error);
} else {
intVal = strtol(strVal, NULL, 10);
@@ -413,7 +416,7 @@ static void uci_query_lineX(struct uci_context *context, struct uci_section *sec
lines[phoneLine].line_conf.rxgain = intVal;
ENDPT_DBG(" %s=%d\n", option, intVal);
} else {
- ENDPT_DBG(" Error: %s range is %d - %d\n", option, voice_get_min_rx_gain(), voice_get_max_rx_gain());
+ ENDPT_ERR("Error value: %s='%s', not in range %d - %d\n", option, strVal, voice_get_min_rx_gain(), voice_get_max_rx_gain());
}
}
@@ -435,7 +438,7 @@ static void uci_query_lineX(struct uci_context *context, struct uci_section *sec
lines[phoneLine].line_conf.hookflash_min = min;
lines[phoneLine].line_conf.hookflash_max = max;
} else {
- ENDPT_DBG("Line %d: error hookflash timer '%s'\n", phoneLine, strVal);
+ ENDPT_ERR("Line %d: error hookflash timer '%s'\n", phoneLine, strVal);
}
ENDPT_DBG("Line %d: hookflash timer '%d:%d'\n", phoneLine,
@@ -542,19 +545,19 @@ static int ubus_request_signal(struct ubus_context *uctx, struct ubus_object *ob
/* Check that we have all arguments */
if (!keys[SIGNAL_LINE] || !keys[SIGNAL_TYPE] || !keys[SIGNAL_STATE]) {
- ENDPT_DBG("Error! missing argument\n");
+ ENDPT_ERR("Error! missing argument\n");
return UBUS_STATUS_INVALID_ARGUMENT;
}
/* Check that endpt exist */
line = blobmsg_get_u32(keys[SIGNAL_LINE]);
if (line < 0 || line >= terminal_info.num_voice_ports) {
- ENDPT_DBG("Error! No such line value: %d\n", line);
+ ENDPT_ERR("Error! No such line value: %d\n", line);
return UBUS_STATUS_INVALID_ARGUMENT;
}
signame = blobmsg_get_string(keys[SIGNAL_TYPE]);
- ENDPT_DBG("%s() %d %s\n", __func__, line, signame);
+ ENDPT_DBG("line=%d, signame=%s\n", line, signame);
// on or off signal?
enable = "0";
@@ -566,7 +569,7 @@ static int ubus_request_signal(struct ubus_context *uctx, struct ubus_object *ob
if (keys[SIGNAL_DATA])
data = blobmsg_get_string(keys[SIGNAL_DATA]);
} else if (strcmp(state, "off")) {
- ENDPT_DBG("Error! invalid state %s\n", state);
+ ENDPT_ERR("Error! invalid state %s\n", state);
return UBUS_STATUS_INVALID_ARGUMENT;
}
@@ -599,20 +602,20 @@ static int ubus_request_connection(struct ubus_context *uctx, struct ubus_object
/* Check that we have all arguments */
if (!keys[CONNECTION_LINE] || !keys[CONNECTION_ACTION] || !keys[CONNECTION_ID]) {
- ENDPT_DBG("Error! missing argument\n");
+ ENDPT_ERR("Error! missing argument\n");
return UBUS_STATUS_INVALID_ARGUMENT;
}
/* Check that endpt exist */
line = blobmsg_get_u32(keys[CONNECTION_LINE]);
if (line < 0 || line >= terminal_info.num_voice_ports) {
- ENDPT_DBG("Error! No such line value: %d\n", line);
+ ENDPT_ERR("Error! No such line value: %d\n", line);
return UBUS_STATUS_INVALID_ARGUMENT;
}
id = blobmsg_get_u32(keys[CONNECTION_ID]);
if (id < 0) {
- ENDPT_DBG("Error! Invalid connection id: %d\n", id);
+ ENDPT_ERR("Error! Invalid connection id: %d\n", id);
return UBUS_STATUS_INVALID_ARGUMENT;
}
@@ -638,7 +641,7 @@ static int ubus_request_connection(struct ubus_context *uctx, struct ubus_object
data.mask = data.mask|UBUS_DATA_PTIME_BIT;
}
- ENDPT_DBG("%s() line: %d connection_id: %d action: %s\n", __func__, line, id, action_str);
+ ENDPT_DBG("line: %d connection_id: %d action: %s\n", line, id, action_str);
if (strcmp("create", action_str) == 0) {
if(line_new_connection_by_asterisk(line, id, &ubusReq))
return UBUS_STATUS_UNKNOWN_ERROR;
@@ -658,11 +661,11 @@ static int ubus_request_connection(struct ubus_context *uctx, struct ubus_object
if(line_update_connection_by_pbx(line, id))
return UBUS_STATUS_UNKNOWN_ERROR;
} else if (strcmp("parm_update", action_str) == 0) {
- ENDPT_DBG("parm_update request for %s line: %d, id: %d, mask: %d, codec: %d, ptime: %d \n", __func__, line, id, data.mask, data.codec, data.ptime);
+ ENDPT_DBG("parm_update request for line: %d, id: %d, mask: %d, codec: %d, ptime: %d \n", line, id, data.mask, data.codec, data.ptime);
if(line_connection_parm_update_by_asterisk(line, id, &data))
return UBUS_STATUS_UNKNOWN_ERROR;
} else {
- ENDPT_DBG("Error! No such action: %s\n", action_str);
+ ENDPT_ERR("Error! No such action: %s\n", action_str);
return UBUS_STATUS_INVALID_ARGUMENT;
}
@@ -709,7 +712,7 @@ static int ubus_request_status(struct ubus_context *uctx, struct ubus_object *ob
blobmsg_add_u32(&blob, "offhook", voice_line_is_offhook(line + unpopulatedDectEndpoints));
res = UBUS_STATUS_OK;
} else {
- ENDPT_DBG("Error! No such line value: %d\n", line);
+ ENDPT_ERR("Error! No such line value: %d\n", line);
res = UBUS_STATUS_INVALID_ARGUMENT;
}
} else {
@@ -749,14 +752,14 @@ static int ubus_request_rtp_stats(struct ubus_context *uctx, struct ubus_object
/* Check that we have all arguments */
if (!keys[RTP_STATS_LINE] || !keys[RTP_STATS_RESET]) {
- ENDPT_DBG("Error! missing argument\n");
+ ENDPT_ERR("Error! missing argument\n");
return UBUS_STATUS_INVALID_ARGUMENT;
}
/* Check that endpt exist */
line = blobmsg_get_u32(keys[RTP_STATS_LINE]);
if (line < 0 || line >= terminal_info.num_voice_ports) {
- ENDPT_DBG("Error! No such line value: %d\n", line);
+ ENDPT_ERR("Error! No such line value: %d\n", line);
return UBUS_STATUS_INVALID_ARGUMENT;
}
@@ -766,7 +769,7 @@ static int ubus_request_rtp_stats(struct ubus_context *uctx, struct ubus_object
for(conIdx = 0; conIdx < max_num_connections && connections[conIdx].line != line; conIdx++)
continue;
if (conIdx >= max_num_connections) {
- ENDPT_DBG("Error: connection is not found on line %d from maximum %d existing connections\n",
+ ENDPT_ERR("Error: connection is not found on line %d from maximum %d existing connections\n",
line, max_num_connections);
return UBUS_STATUS_UNKNOWN_ERROR;
}
@@ -849,11 +852,11 @@ static int ubus_request_codec_capability(struct ubus_context *uctx, struct ubus_
{
static const char *codecfile = "/lib/voice/codecs.json";
- ENDPT_DBG("Codec capability query failed (%d) and get the information from %s\n", status, codecfile);
+ ENDPT_INFO("Codec capability query failed (%d). Use the information from %s\n", status, codecfile);
int res = blobmsg_add_json_from_file(&blob, codecfile);
if(!res)
{
- ENDPT_DBG("%s is missing or invalid\n", codecfile);
+ ENDPT_ERR("%s is missing or invalid\n", codecfile);
return UBUS_STATUS_UNKNOWN_ERROR;
}
}
@@ -957,7 +960,7 @@ static int ubus_request_call(struct ubus_context *uctx, struct ubus_object *obj
static void got_asterisk_complete(struct ubus_request *req, int ret __attribute__((unused)))
{
if(req->peer != asterisk_id || req->status_code != UBUS_STATUS_OK) {
- ENDPT_DBG("Failed sending event to Asterisk\n");
+ ENDPT_ERR("Failed sending event to Asterisk\n");
}
ubus_cb_asterisk_replied((struct line_event_t*) req->priv, req->status_code);
@@ -995,7 +998,7 @@ int ubus_call_asterisk(const struct line_event_t* const ev)
res = ubus_invoke_async(ctx, asterisk_id, "event", bb.head, req);
if(res != UBUS_STATUS_OK) {
- ENDPT_DBG("Error invoking\n");
+ ENDPT_ERR("Error ubus invoking\n");
res = -1;
goto out;
}
@@ -1031,7 +1034,7 @@ int ubus_broadcast_event(const struct line_event_t* const ev)
blobmsg_add_string(&blob, "event", ev->name);
if(ubus_send_event(ctx, broadcast_path, blob.head) != UBUS_STATUS_OK) {
- ENDPT_DBG("Error sending ubus message %s\n", ev->name);
+ ENDPT_ERR("Error sending ubus message %s\n", ev->name);
res = -1;
}
@@ -1139,7 +1142,7 @@ int ubus_call_dectmngr(int terminal, int add, int release, const char *cid, cons
res = ubus_invoke_async(ctx, dectmngr_id, "call", bb.head, req);
if(res != UBUS_STATUS_OK) {
- ENDPT_DBG("Error invoking\n");
+ ENDPT_ERR("Error ubus invoking\n");
res = -1;
goto out;
}
@@ -1176,17 +1179,17 @@ int perhaps_erase_unused_lines(struct uci_context *context)
strncpy(uciSection2, uciSection, sizeof(uciSection2)); // uci_lookup_ptr() can modify uciSection
if (uci_lookup_ptr(context, &ptr, uciSection, true) == UCI_OK) {
if(uci_delete(context, &ptr) == 0) {
- ENDPT_DBG("Remove voice line %s since DECT is not supported\n", uciSection2);
+ ENDPT_INFO("Remove voice line %s, since DECT is not supported\n", uciSection2);
didErase++;
} else {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to remove the uci section %s, %s\n", uciSection2, error);
+ ENDPT_ERR("Failed to remove the uci section %s, %s\n", uciSection2, error);
free(error);
return -1;
}
} else {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to look up the uci section %s, %s\n", uciSection2, error);
+ ENDPT_ERR("Failed to look up the uci section %s, %s\n", uciSection2, error);
free(error);
return -1;
}
@@ -1197,13 +1200,13 @@ int perhaps_erase_unused_lines(struct uci_context *context)
if (uci_lookup_ptr(context, &ptr, uciSection, true) == UCI_OK) {
if(uci_commit(context, &ptr.p, false) != UCI_OK) {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to commit uci package %s, %s\n", uciStrConfig, error);
+ ENDPT_ERR("Failed to commit uci package %s, %s\n", uciStrConfig, error);
free(error);
return -1;
}
} else {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to look up package %s, %s\n", uciStrConfig, error);
+ ENDPT_ERR("Failed to look up package %s, %s\n", uciStrConfig, error);
free(error);
return -1;
}
@@ -1212,6 +1215,27 @@ int perhaps_erase_unused_lines(struct uci_context *context)
return 0;
}
+void config_syslog(struct uci_context *context, struct uci_package *package)
+{
+ struct uci_section *section = NULL;
+ char *error;
+ const char *loglevel;
+
+ section = uci_lookup_section(context, package, uciStrComSect);
+ if (!section) {
+ uci_get_errorstr(context, &error, "");
+ ENDPT_ERR("Failed to look up section %s.%s, %s\n", uciStrConfig, uciStrComSect, error);
+ free(error);
+ return;
+ }
+
+ // configure the syslog level for voicemngr
+ loglevel = uci_lookup_option_string(context, section, uciStrLoglevel);
+ if (loglevel && *loglevel) {
+ log_level = atoi(loglevel);
+ }
+}
+
// Read settings from UCI for this application.
int config_init(struct uci_context *context, struct uci_package *package)
{
@@ -1225,18 +1249,19 @@ int config_init(struct uci_context *context, struct uci_package *package)
section = uci_lookup_section(context, package, uciStrComSect);
if (!section) {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to look up section %s.%s, %s\n", uciStrConfig, uciStrComSect, error);
+ ENDPT_ERR("Failed to look up section %s.%s, %s\n", uciStrConfig, uciStrComSect, error);
free(error);
return -1;
}
country = uci_lookup_option_string(context, section, uciStrCountry);
if (!country || !*country) {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to look up option %s.%s.%s, %s\n", uciStrConfig, uciStrComSect, uciStrCountry, error);
+ ENDPT_ERR("Failed to look up option %s.%s.%s, %s\n", uciStrConfig, uciStrComSect, uciStrCountry, error);
free(error);
return -1;
}
if (voice_set_country(country) != 0) {
+ ENDPT_ERR("Failed to set country %s\n", country);
return -1;
}
@@ -1246,7 +1271,7 @@ int config_init(struct uci_context *context, struct uci_package *package)
section = uci_lookup_section(context, package, uciSection);
if (!section) {
uci_get_errorstr(context, &error, "");
- ENDPT_DBG("Failed to look up section %s.%s, %s\n", uciStrConfig, uciSection, error);
+ ENDPT_ERR("Failed to look up section %s.%s, %s\n", uciStrConfig, uciSection, error);
free(error);
return -1;
}
@@ -1273,17 +1298,17 @@ int ubus_disable_receive(void) {
res = 0;
if(ubus_remove_object(ctx, &rpcObj) != UBUS_STATUS_OK) {
- ENDPT_DBG("Error deregistering ubus endpt object\n");
+ ENDPT_ERR("Error deregistering ubus endpt object\n");
res = -1;
}
if(ubus_unregister_event_handler(ctx, &ObjRmListener) != UBUS_STATUS_OK) {
- ENDPT_DBG("Error deregistering ubus event handler %s", ubusStrObjRm);
+ ENDPT_ERR("Error deregistering ubus event handler %s", ubusStrObjRm);
res = -1;
}
if(ubus_unregister_event_handler(ctx, &ObjAddListener) != UBUS_STATUS_OK) {
- ENDPT_DBG("Error deregistering ubus event handler %s", ubusStrObjAdd);
+ ENDPT_ERR("Error deregistering ubus event handler %s", ubusStrObjAdd);
res = -1;
}
@@ -1306,7 +1331,7 @@ int ubus_enable_receive(void) {
ObjAddListener.cb = ubus_event_new_obj;
if(ubus_register_event_handler(ctx, &ObjAddListener,
ubusStrObjAdd) != UBUS_STATUS_OK) {
- ENDPT_DBG("Error registering ubus event handler %s", ubusStrObjAdd);
+ ENDPT_ERR("Error registering ubus event handler %s", ubusStrObjAdd);
return -1;
}
@@ -1314,13 +1339,13 @@ int ubus_enable_receive(void) {
ObjRmListener.cb = ubus_event_new_obj;
if(ubus_register_event_handler(ctx, &ObjRmListener,
ubusStrObjRm) != UBUS_STATUS_OK) {
- ENDPT_DBG("Error registering ubus event handler %s", ubusStrObjRm);
+ ENDPT_ERR("Error registering ubus event handler %s", ubusStrObjRm);
return -1;
}
// Invoke our RPC handler when ubus calls (not events) arrive
if (ubus_add_object(ctx, &rpcObj) != UBUS_STATUS_OK) {
- ENDPT_DBG("Failed to register UBUS endpt object\n");
+ ENDPT_ERR("Failed to register UBUS endpt object\n");
return -1;
}
@@ -1350,7 +1375,7 @@ int ubus_init(void) {
ubus_pending_requests = pe_list_new();
if(!ubus_pending_requests) {
- ENDPT_DBG("%s: out of memory\n", __func__);
+ ENDPT_ERR("%s: out of memory\n", __func__);
return -1;
}
diff --git a/ubus.h b/ubus.h
index a465de6..1bfa3d7 100644
--- a/ubus.h
+++ b/ubus.h
@@ -17,6 +17,7 @@ int send_reply_dectmngr(struct voice_ubus_req_t *req, int terminal, int pcmId, e
int ubus_call_dectmngr(int terminal, int add, int release, const char *cid, const char *caller_name, int pcmId, struct line_req_t *lineReq);
int perhaps_erase_unused_lines(struct uci_context *context);
int config_init(struct uci_context *context, struct uci_package *package);
+void config_syslog(struct uci_context *context, struct uci_package *package);
int ubus_disable_receive(void);
int ubus_enable_receive(void);
int ubus_init(void);

View File

@@ -1,91 +0,0 @@
diff --git a/main.c b/main.c
index 3aa7ad4..307d3da 100644
--- a/main.c
+++ b/main.c
@@ -326,7 +326,6 @@ int main(int argc, char **argv) {
if(voice_line_init(has_dect)) goto __error_ret;
if(line_dect_init()) goto __error_ret;
if(voice_connection_init()) goto __error_ret;
- if(perhaps_erase_unused_lines(context)) goto __error_ret;
// Enable UBUS when all initializations have finished
if(ubus_enable_receive()) goto __error_ret;
diff --git a/ubus.c b/ubus.c
index 9214463..bee80ed 100644
--- a/ubus.c
+++ b/ubus.c
@@ -1159,62 +1159,6 @@ out:
return res;
}
-// Runtime erase of lines from UCI if they are not populated
-// in HW. This prevents them from showing up in the web GUI.
-int perhaps_erase_unused_lines(struct uci_context *context)
-{
- char uciSection[strlen(uciStrConfig) + strlen(uciStrLineSect) + 12];
- char uciSection2[sizeof(uciSection)];
- int line, didErase = 0;
- struct uci_ptr ptr;
- char *error;
-
- for(line = 0; line < terminal_info.num_voice_ports; line++) {
- if(!lines[line].simulated_busy)
- continue;
- if(!lines[line].line_conf.config_loaded)
- continue; // Erase only if exist in UCI
-
- snprintf(uciSection, sizeof(uciSection), "%s.%s%d", uciStrConfig, uciStrLineSect, line);
- strncpy(uciSection2, uciSection, sizeof(uciSection2)); // uci_lookup_ptr() can modify uciSection
- if (uci_lookup_ptr(context, &ptr, uciSection, true) == UCI_OK) {
- if(uci_delete(context, &ptr) == 0) {
- ENDPT_INFO("Remove voice line %s, since DECT is not supported\n", uciSection2);
- didErase++;
- } else {
- uci_get_errorstr(context, &error, "");
- ENDPT_ERR("Failed to remove the uci section %s, %s\n", uciSection2, error);
- free(error);
- return -1;
- }
- } else {
- uci_get_errorstr(context, &error, "");
- ENDPT_ERR("Failed to look up the uci section %s, %s\n", uciSection2, error);
- free(error);
- return -1;
- }
- }
-
- if(didErase) {
- strncpy(uciSection, uciStrConfig, sizeof(uciSection)); // uci_lookup_ptr() can modify uciSection
- if (uci_lookup_ptr(context, &ptr, uciSection, true) == UCI_OK) {
- if(uci_commit(context, &ptr.p, false) != UCI_OK) {
- uci_get_errorstr(context, &error, "");
- ENDPT_ERR("Failed to commit uci package %s, %s\n", uciStrConfig, error);
- free(error);
- return -1;
- }
- } else {
- uci_get_errorstr(context, &error, "");
- ENDPT_ERR("Failed to look up package %s, %s\n", uciStrConfig, error);
- free(error);
- return -1;
- }
- }
-
- return 0;
-}
-
void config_syslog(struct uci_context *context, struct uci_package *package)
{
struct uci_section *section = NULL;
diff --git a/ubus.h b/ubus.h
index 1bfa3d7..5fb5129 100644
--- a/ubus.h
+++ b/ubus.h
@@ -15,7 +15,6 @@ int ubus_broadcast_event(const struct line_event_t* const ev);
int send_reply_asterisk(struct voice_ubus_req_t *req, enum ubus_msg_status ubusRet);
int send_reply_dectmngr(struct voice_ubus_req_t *req, int terminal, int pcmId, enum ubus_msg_status ubusRet);
int ubus_call_dectmngr(int terminal, int add, int release, const char *cid, const char *caller_name, int pcmId, struct line_req_t *lineReq);
-int perhaps_erase_unused_lines(struct uci_context *context);
int config_init(struct uci_context *context, struct uci_package *package);
void config_syslog(struct uci_context *context, struct uci_package *package);
int ubus_disable_receive(void);