Skip to content

Commit e49e184

Browse files
committed
Fix 40 MHz bandwidth mode
1 parent d2578cd commit e49e184

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

src/RadioManagementModule.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,24 @@
55
#include <chrono>
66
#include <map>
77
#include <thread>
8+
#include <unordered_map>
89
#include <vector>
910

11+
namespace{
12+
int get_40mhz_center_channel(int channel) {
13+
static const std::unordered_map<int, int> channel_map = {
14+
{36, 38}, {40, 38}, {44, 46}, {48, 46},
15+
{52, 54}, {56, 54}, {60, 62}, {64, 62},
16+
{100, 102}, {104, 102}, {108, 110}, {112, 110},
17+
{116, 118}, {120, 118}, {124, 126}, {128, 126},
18+
{132, 134}, {136, 134}, {140, 142}, {144, 142},
19+
{149, 151}, {153, 151}, {157, 159}, {161, 159}
20+
};
21+
22+
auto it = channel_map.find(channel);
23+
return (it != channel_map.end()) ? it->second : channel;
24+
}
25+
}
1026
RadioManagementModule::RadioManagementModule(
1127
RtlUsbAdapter device, std::shared_ptr<EepromManager> eepromManager,
1228
Logger_t logger)
@@ -89,11 +105,7 @@ static uint8_t rtw_get_center_ch(uint8_t channel, ChannelWidth_t chnl_bw,
89105
else if (channel <= 14)
90106
center_ch = 7;
91107
} else if (chnl_bw == ChannelWidth_t::CHANNEL_WIDTH_40) {
92-
if (chnl_offset == HAL_PRIME_CHNL_OFFSET_LOWER) {
93-
center_ch = (uint8_t)(channel + 2);
94-
} else {
95-
center_ch = (uint8_t)(channel - 2);
96-
}
108+
center_ch = get_40mhz_center_channel(center_ch);
97109
} else if (chnl_bw == ChannelWidth_t::CHANNEL_WIDTH_20) {
98110
center_ch = channel;
99111
} else {

0 commit comments

Comments
 (0)