[rdkb][eagle] fix TDK issue for logan

[Description]
as title.

[Release-log]

diff --git a/recipes-extended/tdkb/files/0002-Add-tdk-utility-functions.patch b/recipes-extended/tdkb/files/0002-Add-tdk-utility-functions.patch
index 3c107a8..75285ea 100644
--- a/recipes-extended/tdkb/files/0002-Add-tdk-utility-functions.patch
+++ b/recipes-extended/tdkb/files/0002-Add-tdk-utility-functions.patch
@@ -11,38 +11,55 @@
 index fefc1947..ef8fbc84 100755
 --- a/platform/turris/agent/scripts/tdk_platform_utility.sh
 +++ b/platform/turris/agent/scripts/tdk_platform_utility.sh
-@@ -37,17 +37,83 @@ getCMMACAddress()
+@@ -37,17 +37,100 @@ getCMMACAddress()
      echo $macaddress
  }
  
++if [ -e /etc/wireless/l1profile.dat ];
++then
++	AP0_INF=ra0
++	AP1_INF=rai0
++else
++	AP0_INF=wifi0
++	AP1_INF=wifi1
++fi
++
 +getAp0DTIMInterval()
 +{
-+     hostapd_cli -i wifi0 status| grep -i ^dtim | cut -d '=' -f2
++     hostapd_cli -i $AP0_INF status| grep -i ^dtim | cut -d '=' -f2
 +}
 +
 +getAp1DTIMInterval()
 +{
-+     hostapd_cli -i wifi1 status| grep -i ^dtim | cut -d '=' -f2
++     hostapd_cli -i $AP1_INF status| grep -i ^dtim | cut -d '=' -f2
 +}
 +
 +getAp0BeaconInterval()
 +{
-+     hostapd_cli -i wifi0 status | grep ^beacon_int | cut -d '=' -f2
++     hostapd_cli -i $AP0_INF status | grep ^beacon_int | cut -d '=' -f2
 +}
 +
 +getAp1BeaconInterval()
 +{
-+     hostapd_cli -i wifi1 status | grep ^beacon_int | cut -d '=' -f2
++     hostapd_cli -i $AP1_INF status | grep ^beacon_int | cut -d '=' -f2
 +}
 +
 +getRadio0ObssCoexistenceEnable()
 +{
-+    cat /nvram/hostapd0.conf | grep ^ht_coex | cut -d '=' -f2
++ if [ -e /etc/wireless/mediatek/mt7990.b0.dat ]; then
++ 	cat /etc/wireless/mediatek/mt7990.b0.dat | grep ^HT_BSSCoexistence | cut -d '=' -f2
++ else
++	cat /nvram/hostapd0.conf | grep ^ht_coex | cut -d '=' -f2
++ fi
 +}
 +
 +getRadio1ObssCoexistenceEnable()
 +{
-+    cat /nvram/hostapd1.conf | grep ^ht_coex | cut -d '=' -f2
++ if [ -e /etc/wireless/mediatek/mt7990.b1.dat ]; then
++ 	cat /etc/wireless/mediatek/mt7990.b1.dat | grep ^HT_BSSCoexistence | cut -d '=' -f2
++ else
++	cat /nvram/hostapd1.conf | grep ^ht_coex | cut -d '=' -f2
++ fi
 +}
 +
 +getAP0ScanFilter()
diff --git a/recipes-extended/tdkb/files/0003-Add-Set-property-script.patch b/recipes-extended/tdkb/files/0003-Add-Set-property-script.patch
index e088ee5..1eed785 100644
--- a/recipes-extended/tdkb/files/0003-Add-Set-property-script.patch
+++ b/recipes-extended/tdkb/files/0003-Add-Set-property-script.patch
@@ -11,12 +11,17 @@
 index f9f0d58..689898b 100755
 --- a/platform/turris/agent/scripts/StartTDK.sh
 +++ b/platform/turris/agent/scripts/StartTDK.sh
-@@ -40,6 +40,9 @@ then
+@@ -40,6 +40,14 @@ then
          sh tdk_firewall_service.sh &
  fi
  
 +echo "Going to set tdk platform properties"
-+sh Set_properties.sh &
++if [ -e /etc/wireless/l1profile.dat ];
++then
++	sh Set_properties_logan.sh &
++else
++	sh Set_properties.sh &
++fi
 +
  echo "Going to start Agent"
  cd $TDK_BIN_PATH/
diff --git a/recipes-extended/tdkb/files/Set_properties_logan.sh b/recipes-extended/tdkb/files/Set_properties_logan.sh
new file mode 100644
index 0000000..62c646b
--- /dev/null
+++ b/recipes-extended/tdkb/files/Set_properties_logan.sh
@@ -0,0 +1,46 @@
+devidx=0
+
+for _dev in /sys/class/ieee80211/*; do
+
+	if [ "$_dev" == "/sys/class/ieee80211/phy0" ]; then
+		main_inf=ra0
+	elif [ "$_dev" == "/sys/class/ieee80211/phy1" ]; then
+		main_inf=rai0
+	elif [ "$_dev" == "/sys/class/ieee80211/phy2" ]; then
+		main_inf=rax0	
+	fi
+
+	echo "dev: $devidx"
+	echo "main_inf: $main_inf"
+
+	if [ "$main_inf" == "ra0" ]; then
+			echo "APINDEX_2G_PUBLIC_WIFI=$devidx" >> /etc/tdk_platform.properties
+			sed -i "s/\(AP_IF_NAME_2G *= *\).*/\1$main_inf/" /etc/tdk_platform.properties
+			sed -i "s/\(RADIO_IF_2G *= *\).*/\1$main_inf/" /etc/tdk_platform.properties
+	elif [ "$main_inf" == "rai0" ]; then
+			echo "APINDEX_5G_PUBLIC_WIFI=$devidx" >> /etc/tdk_platform.properties
+			sed -i "s/\(AP_IF_NAME_5G *= *\).*/\1$main_inf/" /etc/tdk_platform.properties
+			sed -i "s/\(RADIO_IF_5G *= *\).*/\1$main_inf/" /etc/tdk_platform.properties
+	elif [ "$main_inf" == "rax0" ]; then
+			echo "PRIVATE_6G_AP_INDEX=$devidx" >> /etc/tdk_platform.properties
+			echo "AP_IF_NAME_6G=$main_inf" >> /etc/tdk_platform.properties
+			echo "RADIO_IF_6G=$main_inf" >> /etc/tdk_platform.properties
+	fi
+
+	devidx=$(($devidx + 1))
+done
+
+
+echo "DEFAULT_CHANNEL_BANDWIDTH=40MHz,80MHz" >> /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
+echo "DFS_SUPPORT=Enabled" >> /etc/tdk_platform.properties
+echo "AP_AUTH_MODE_OPEN=1" >> /etc/tdk_platform.properties
+echo "AP_AUTH_MODE_SHARED=2" >> /etc/tdk_platform.properties
+echo "AP_AUTH_MODE_AUTO=4" >> /etc/tdk_platform.properties
+sed -i "s/\(FRAGMENTATION_THRESHOLD_RANGE *= *\).*/\1256-2346/" /etc/tdk_platform.properties
+echo "0" > /tmp/essid0.txt
+echo "0" > /tmp/essid1.txt
+echo "0" > /tmp/essid2.txt
diff --git a/recipes-extended/tdkb/tdk-b.bbappend b/recipes-extended/tdkb/tdk-b.bbappend
index 96ba2ac..7a03e09 100644
--- a/recipes-extended/tdkb/tdk-b.bbappend
+++ b/recipes-extended/tdkb/tdk-b.bbappend
@@ -10,12 +10,19 @@
 
 SRC_URI += "file://*.patch;apply=no \
     file://Set_properties.sh;subdir=git \
+	file://Set_properties_logan.sh;subdir=git \
 "
 
 do_mtk_patches() {
     cd ${S}
     if [ ! -e mtk_wifi_patch_applied ]; then
-        for i in ${WORKDIR}/*.patch; do patch -p1 < $i; done
+		patch -p1 < ${WORKDIR}/0001-Fix-GetApAssociatedDeviceRxStatsResult-and-GetApAsso.patch
+		patch -p1 < ${WORKDIR}/0002-Add-tdk-utility-functions.patch
+		patch -p1 < ${WORKDIR}/0003-Add-Set-property-script.patch
+		if ${@bb.utils.contains( 'DISTRO_FEATURES', 'logan', 'false', 'true', d)}; then
+			patch -p1 < ${WORKDIR}/0004-Add-start-sequence-after-uci.patch
+		fi
+		patch -p1 < ${WORKDIR}/0005-Fix-wifi_getApAssociatedDeviceTidStatsResult-print-a.patch
     fi
     touch mtk_wifi_patch_applied
 }
@@ -27,6 +34,7 @@
     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/
     install -p -m 755 ${S}/Set_properties.sh ${D}${tdkdir}
+    install -p -m 755 ${S}/Set_properties_logan.sh ${D}${tdkdir}
 }
 
 FILES_${PN} += "${prefix}/ccsp/"