Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions apps/examples/wifi_manager/wm_test/wm_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,32 @@ void _wt_set_power(void *arg)
WT_LEAVE;
}

void _wt_set_channel_plan(void *arg)
{
WT_ENTER;
struct wt_options *opt = (struct wt_options *)arg;
wifi_manager_result_e res = wifi_manager_set_channel_plan(opt->channel_plan);
if (res != WIFI_MANAGER_SUCCESS) {
WT_LOGE(TAG, "fail to set channel plan\n");
return;
}
WT_LOG(TAG, "set channel plan %d\n", opt->channel_plan);
WT_LEAVE;
}

int _wt_parse_channel_plan(struct wt_options *opt, int argc, char *argv[])
{
if (argc != 3) {
WT_LOGE(TAG, "invalid argument\n");
return -1;
}

opt->channel_plan = atoi(argv[2]);
WT_LOG(TAG, "channel plan %d\n", opt->channel_plan);

return 0;
}

void _wt_stress_test(void *arg)
{
wm_run_stress_test(arg);
Expand Down
1 change: 1 addition & 0 deletions apps/examples/wifi_manager/wm_test/wm_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct wt_options {
char *softap_ssid;
char *softap_password;
int softap_channel;
uint8_t channel_plan;
int scan_specific;
uint32_t stress_tc_idx;
uint8_t power_mode;
Expand Down
1 change: 1 addition & 0 deletions apps/examples/wifi_manager/wm_test/wm_test_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ WT_MEMBER_POOL(WT_TEST_DISPLAY_AP, _wt_interop_display_ap, _wt_parse_interop, "d
WT_MEMBER_POOL(WT_TYPE_EVT_TC, _wt_run_evt_tc, _wt_parse_evt_tc, "tc_evt")
WT_MEMBER_POOL(WT_TYPE_DNS, _wt_dns_test, _wt_parse_dns, "dns")
WT_MEMBER_POOL(WT_TYPE_CONNECTBYRSSI, _wt_connectbyrssi_test, _wt_parse_connectbyrssi, "connect_by_rssi")
WT_MEMBER_POOL(WT_TYPE_CHAN_PLAN, _wt_set_channel_plan, _wt_parse_channel_plan, "chan_plan")
#if defined(CONFIG_ENABLE_HOMELYNK) && (CONFIG_ENABLE_HOMELYNK == 1)
WT_MEMBER_POOL(WT_TYPE_ENABLE_BRIDGE, _wt_enable_bridge, _wt_parse_bridge, "bridge")
#endif
4 changes: 4 additions & 0 deletions apps/examples/wifi_manager/wm_test/wm_test_usage.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
"\n connectbybestrssi test mode options:\n" \
" wm_test connect_by_rssi [SSID_NAME] [SSID_authentication] [SSID_Password] [Repeat Count]\n"\

#define WT_CHANPLAN_USAGE \
"\n set channel plan\n" \
" wm_test chan_plan [channel_plan]\n" \

#define WT_USAGE \
"\n usage: wm_test [options]\n" \
"\n run Wi-Fi Manager:\n" \
Expand Down
31 changes: 29 additions & 2 deletions os/board/bk7239n/src/bsp_adapter/src/net/bk_netmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1593,8 +1593,8 @@ trwifi_result_e bk_wifi_netmgr_ioctl(struct netdev *dev, trwifi_msg_s *msg)

trwifi_result_e bk_wifi_netmgr_set_chplan(struct netdev *dev, uint8_t chplan)
{
trwifi_result_e wuret = TRWIFI_SUCCESS;

trwifi_result_e wuret = TRWIFI_SUCCESS;
#if 0
if (!bk_wifi_check_channel(chplan)) {
ndbg("[BK] invalid chplan argument \r\n");
wuret = TRWIFI_INVALID_ARGS;
Expand All @@ -1612,6 +1612,33 @@ trwifi_result_e bk_wifi_netmgr_set_chplan(struct netdev *dev, uint8_t chplan)
}

bk_wifi_set_ap_channel(chplan);
#endif
char country_code[3] = {0};
int region_idx = chplan;
bk_err_t ret;
ndbg("[BK] chplan %d\r\n", chplan);

if (region_idx < 1 || region_idx > 50) {
ndbg("[BK] invalid chplan argument %d, expected 1~50\r\n", chplan);
wuret = TRWIFI_INVALID_ARGS;
goto exit_set_chp;
}

if (region_idx <= 26) {
country_code[0] = 'A' + (region_idx - 1);
country_code[1] = '\0';
} else {
country_code[0] = 'A';
country_code[1] = 'A' + (region_idx - 27);
country_code[2] = '\0';
}

ret = bk_wifi_set_country_code(country_code);
if (ret != BK_OK) {
ndbg("[BK] failed to set country code %s, ret=%d\r\n", country_code, ret);
wuret = TRWIFI_FAIL;
goto exit_set_chp;
}

exit_set_chp:
return wuret;
Expand Down
Loading