From ca20a7eabdc16821973945a01a7ef340293a0f74 Mon Sep 17 00:00:00 2001
From: Chen Minqiang <ptpt52@gmail.com>
Date: Fri, 31 Dec 2021 05:37:55 +0800
Subject: [PATCH 1/2] hostapd: Fix ap+sta channel setup issue

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
---
 .../800-fix-ap-sta-channel-setup-failed.patch | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 package/network/services/hostapd/patches/800-fix-ap-sta-channel-setup-failed.patch

diff --git a/package/network/services/hostapd/patches/800-fix-ap-sta-channel-setup-failed.patch b/package/network/services/hostapd/patches/800-fix-ap-sta-channel-setup-failed.patch
new file mode 100644
index 0000000000..de7a611587
--- /dev/null
+++ b/package/network/services/hostapd/patches/800-fix-ap-sta-channel-setup-failed.patch
@@ -0,0 +1,29 @@
+diff --git a/src/common/hw_features_common.c b/src/common/hw_features_common.c
+index ad2aebf..355b4a8 100644
+--- a/src/common/hw_features_common.c
++++ b/src/common/hw_features_common.c
+@@ -615,9 +615,21 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data,
+ 			    center_segment0 == channel - 6)
+ 				data->center_freq1 = 5000 + center_segment0 * 5;
+ 			else {
+-				wpa_printf(MSG_ERROR,
+-					   "Wrong coupling between HT and VHT/HE channel setting");
+-				return -1;
++				if (channel <= 48)
++					center_segment0 = 42;
++				else if (channel <= 64)
++					center_segment0 = 58;
++				else if (channel <= 112)
++					center_segment0 = 106;
++				else if (channel <= 128)
++					center_segment0 = 122;
++				else if (channel <= 144)
++					center_segment0 = 138;
++				else if (channel <= 161)
++					center_segment0 = 155;
++				else if (channel <= 177)
++					center_segment0 = 171;
++				data->center_freq1 = 5000 + center_segment0 * 5;
+ 			}
+ 		}
+ 		break;
-- 
2.25.1

