[rdkb][common][app][Refactor tdk to support tri-band]
[Description]
Refactor tdk to support tri-band and runtime get radio band number.
[Release-log]
N/A
Change-Id: If06ef106feb258c66d3b9fb810067b1623ca8701
diff --git a/recipes-extended/tdkb/0001-Fix-GetApAssociatedDeviceRxStatsResult-and-GetApAsso.patch b/recipes-extended/tdkb/files/0001-Fix-GetApAssociatedDeviceRxStatsResult-and-GetApAsso.patch
similarity index 100%
rename from recipes-extended/tdkb/0001-Fix-GetApAssociatedDeviceRxStatsResult-and-GetApAsso.patch
rename to recipes-extended/tdkb/files/0001-Fix-GetApAssociatedDeviceRxStatsResult-and-GetApAsso.patch
diff --git a/recipes-extended/tdkb/0002-Add-tdk-utility-functions.patch b/recipes-extended/tdkb/files/0002-Add-tdk-utility-functions.patch
similarity index 100%
rename from recipes-extended/tdkb/0002-Add-tdk-utility-functions.patch
rename to recipes-extended/tdkb/files/0002-Add-tdk-utility-functions.patch
diff --git a/recipes-extended/tdkb/files/0003-Add-Set-property-script.patch b/recipes-extended/tdkb/files/0003-Add-Set-property-script.patch
new file mode 100644
index 0000000..e088ee5
--- /dev/null
+++ b/recipes-extended/tdkb/files/0003-Add-Set-property-script.patch
@@ -0,0 +1,26 @@
+From 1c6bef3e8c640970c30f7e09414dab52f5587875 Mon Sep 17 00:00:00 2001
+From: "Allen.Ye" <allen.ye@mediatek.com>
+Date: Mon, 31 Oct 2022 10:59:27 +0800
+Subject: [PATCH] Add Set property script
+
+---
+ platform/turris/agent/scripts/StartTDK.sh | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/platform/turris/agent/scripts/StartTDK.sh b/platform/turris/agent/scripts/StartTDK.sh
+index f9f0d58..689898b 100755
+--- a/platform/turris/agent/scripts/StartTDK.sh
++++ b/platform/turris/agent/scripts/StartTDK.sh
+@@ -40,6 +40,9 @@ then
+ sh tdk_firewall_service.sh &
+ fi
+
++echo "Going to set tdk platform properties"
++sh Set_properties.sh &
++
+ echo "Going to start Agent"
+ cd $TDK_BIN_PATH/
+ ./rdk_tdk_agent_process &
+--
+2.18.0
+
diff --git a/recipes-extended/tdkb/files/0004-Add-start-sequence-after-uci.patch b/recipes-extended/tdkb/files/0004-Add-start-sequence-after-uci.patch
new file mode 100644
index 0000000..a9af40b
--- /dev/null
+++ b/recipes-extended/tdkb/files/0004-Add-start-sequence-after-uci.patch
@@ -0,0 +1,25 @@
+From 794cae8d7f1b5e8174db03ef2cc4383331b5eff7 Mon Sep 17 00:00:00 2001
+From: "Allen.Ye" <allen.ye@mediatek.com>
+Date: Mon, 31 Oct 2022 14:49:16 +0800
+Subject: [PATCH] Add start sequence after uci
+
+---
+ tdk.service | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tdk.service b/tdk.service
+index dc66adb6..e26aaf28 100644
+--- a/tdk.service
++++ b/tdk.service
+@@ -18,7 +18,7 @@
+ ##########################################################################
+ [Unit]
+ Description=TDK Test Agent Start
+-After=dbus.service
++After=dbus.service init-uci-config.service
+ Wants=dbus.service
+
+ [Service]
+--
+2.18.0
+
diff --git a/recipes-extended/tdkb/files/Set_properties.sh b/recipes-extended/tdkb/files/Set_properties.sh
new file mode 100644
index 0000000..ae70bd4
--- /dev/null
+++ b/recipes-extended/tdkb/files/Set_properties.sh
@@ -0,0 +1,39 @@
+devidx=0
+phyidx=0
+
+for _dev in /sys/class/ieee80211/*; do
+ [ -e "$_dev" ] || continue
+ if [ "$(uci get wireless.radio${phyidx}.disabled)" == "1" ]; then
+ phyidx=$((phyidx + 1))
+ continue
+ fi
+
+ echo "dev: $devidx"
+ echo "phy: $phyidx"
+
+ band="$(uci get wireless.radio${phyidx}.band)"
+
+ if [ "$band" == "2g" ]; then
+ echo "APINDEX_2G_PUBLIC_WIFI=$devidx" >> /etc/tdk_platform.properties
+ sed -i "s/\(AP_IF_NAME_2G *= *\).*/\1wifi$devidx/" /etc/tdk_platform.properties
+ sed -i "s/\(RADIO_IF_2G *= *\).*/\1wlan$devidx/" /etc/tdk_platform.properties
+ elif [ "$band" == "5g" ]; then
+ echo "APINDEX_5G_PUBLIC_WIFI=$devidx" >> /etc/tdk_platform.properties
+ sed -i "s/\(AP_IF_NAME_5G *= *\).*/\1wifi$devidx/" /etc/tdk_platform.properties
+ sed -i "s/\(RADIO_IF_5G *= *\).*/\1wlan$devidx/" /etc/tdk_platform.properties
+ elif [ "$band" == "6g" ]; then
+ echo "PRIVATE_6G_AP_INDEX=$devidx" >> /etc/tdk_platform.properties
+ echo "AP_IF_NAME_6G=wifi$devidx" >> /etc/tdk_platform.properties
+ echo "RADIO_IF_6G=wlan$devidx" >> /etc/tdk_platform.properties
+ fi
+
+ devidx=$(($devidx + 1))
+ phyidx=$(($phyidx + 1))
+done
+
+
+echo "DEFAULT_CHANNEL_BANDWIDTH=20MHz,20MHz" >> /etc/tdk_platform.properties
+echo "RADIO_MODES_2G=n:11NGHT40MINUS:4,n:11NGHT40MINUS:8,ax:11AXHE40MINUS:32,ax:11AXHE40MINUS:0" >> /etc/tdk_platform.properties
+echo "RADIO_MODES_5G=ac:11ACVHT80:16,n:11NAHT40MINUS:8,ax:11AXHE80:32,ax:11AXHE80:0" >> /etc/tdk_platform.properties
+echo "getAp0DTIMInterval=1" >> /etc/tdk_platform.properties
+echo "getAp1DTIMInterval=1" >> /etc/tdk_platform.properties
diff --git a/recipes-extended/tdkb/tdk-b.bbappend b/recipes-extended/tdkb/tdk-b.bbappend
index 602c1be..41a7c58 100644
--- a/recipes-extended/tdkb/tdk-b.bbappend
+++ b/recipes-extended/tdkb/tdk-b.bbappend
@@ -6,9 +6,11 @@
do_fetch[vardeps] += "SRCREV_tdkbturris"
SRCREV_FORMAT = "tdk_tdkbturris"
-FILESEXTRAPATHS_prepend := "${THISDIR}:"
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
-SRC_URI += "file://*.patch;apply=no"
+SRC_URI += "file://*.patch;apply=no \
+ file://Set_properties.sh;subdir=git \
+"
do_mtk_patches() {
cd ${S}
@@ -24,19 +26,7 @@
install -d ${D}/etc
install -p -m 755 ${S}/platform/turris/agent/scripts/*.sh ${D}${tdkdir}
install -p -m 755 ${S}/platform/turris/agent/scripts/tdk_platform.properties ${D}/etc/
-
- sed -i "s/\(AP_IF_NAME_2G *= *\).*/\1wifi0/" ${D}/etc/tdk_platform.properties
- sed -i "s/\(AP_IF_NAME_5G *= *\).*/\1wifi1/" ${D}/etc/tdk_platform.properties
- sed -i "s/\(RADIO_IF_2G *= *\).*/\1wlan0/" ${D}/etc/tdk_platform.properties
- sed -i "s/\(RADIO_IF_5G *= *\).*/\1wlan1/" ${D}/etc/tdk_platform.properties
- echo "DEFAULT_CHANNEL_BANDWIDTH=20MHz,20MHz" >> ${D}/etc/tdk_platform.properties
- echo "APINDEX_2G_PUBLIC_WIFI=0" >> ${D}/etc/tdk_platform.properties
- echo "APINDEX_5G_PUBLIC_WIFI=1" >> ${D}/etc/tdk_platform.properties
- echo "RADIO_MODES_2G=n:11NGHT40MINUS:4,n:11NGHT40MINUS:8,ax:11AXHE40MINUS:32,ax:11AXHE40MINUS:0" >> ${D}/etc/tdk_platform.properties
- echo "RADIO_MODES_5G=ac:11ACVHT80:16,n:11NAHT40MINUS:8,ax:11AXHE80:32,ax:11AXHE80:0" >> ${D}/etc/tdk_platform.properties
- echo "getAp0DTIMInterval=1" >> ${D}/etc/tdk_platform.properties
- echo "getAp1DTIMInterval=1" >> ${D}/etc/tdk_platform.properties
-
+ install -p -m 755 ${S}/Set_properties.sh ${D}${tdkdir}
}
FILES_${PN} += "${prefix}/ccsp/"