diff --git a/source/apps/em/wifi_em.c b/source/apps/em/wifi_em.c index aa1a10070..19dbe082e 100644 --- a/source/apps/em/wifi_em.c +++ b/source/apps/em/wifi_em.c @@ -33,6 +33,8 @@ #define EM_NEIGBOUR_SCAN_PROVIDER_DELAY_SEC 5 // 5 Seconds #define EM_NEIGBOUR_SCAN_INTERVAL_MSEC 60000 // 60 Seconds #define EM_DEF_LINK_METRICS_COLLECT_INTERVAL_MSEC 10000 // 10 Seconds +#define EM_BSS_COLOR_DEFAULT 0x3F +#define EM_SCAN_TYPE_ACTIVE 1 static bool is_monitor_done = false; @@ -671,6 +673,7 @@ static int em_prepare_scan_response_data(wifi_provider_response_t *provider_resp wifi_neighbor_ap2_t *wifi_scan_data = NULL; radio_interface_mapping_t *radio_iface_map = NULL; char time_str[32] = { 0 }; + int dwell_time = provider_response->args.dwell_time; wifi_mgr_t *wifi_mgr = get_wifimgr_obj(); wifi_platform_property_t *wifi_prop = &wifi_mgr->hal_cap.wifi_prop; @@ -770,17 +773,32 @@ static int em_prepare_scan_response_data(wifi_provider_response_t *provider_resp neighbor->signal_strength = src->ap_SignalStrength; strncpy(neighbor->channel_bandwidth, src->ap_OperatingChannelBandwidth, EM_MAX_CHANNEL_BW_LEN); - neighbor->channel_utilization = src->ap_ChannelUtilization; + neighbor->bss_color = EM_BSS_COLOR_DEFAULT; neighbor->bss_load_element_present = 0; - neighbor->bss_color = 0; + + /* Initialize to defaults to avoid stale/uninitialized data */ + neighbor->channel_utilization = 0; neighbor->station_count = 0; + + /* + * Populate channel utilization, Station count + * only if the bss load element is present. + */ + if (src->bss_load_element_present) { + neighbor->bss_load_element_present = src->bss_load_element_present; + neighbor->channel_utilization = src->ap_ChannelUtilization; + neighbor->station_count = src->ap_StaCount; + } res->num_neighbors++; - wifi_util_dbg_print(WIFI_EM, "%s:%d BSSID: %s SSID: %s\n", __func__, __LINE__, - src->ap_BSSID, src->ap_SSID); + wifi_util_dbg_print(WIFI_EM, "bss_color 0x%x ch_util %d bss_element_present %d sta_cnt %d for BSSID: %s SSID: %s\n", + neighbor->bss_color, neighbor->channel_utilization, neighbor->bss_load_element_present, + neighbor->station_count, src->ap_BSSID, src->ap_SSID); } else { wifi_util_error_print(WIFI_EM, "%s:%d : Maximum number of neighbors reached.\n", __func__, __LINE__); } + res->aggregate_scan_duration = dwell_time; + res->scan_type = EM_SCAN_TYPE_ACTIVE; } wifi_util_dbg_print(WIFI_EM, "%s:%d Scan results updated for radio mac : %s\n", __func__, __LINE__, to_mac_str(radio_mac, mac_str)); @@ -2103,6 +2121,7 @@ static int em_process_scan_init_command(unsigned int radio_index, channel_scan_r { wifi_monitor_data_t *data; int valid_chan_count = 0; + wifi_radio_operationParam_t *radioOperation = NULL; wifi_util_dbg_print(WIFI_EM, "%s:%d radio_index: %d \n", __func__, __LINE__, radio_index); @@ -2150,7 +2169,15 @@ static int em_process_scan_init_command(unsigned int radio_index, channel_scan_r data->u.mon_stats_config.args.scan_mode = WIFI_RADIO_SCAN_MODE_FULL; // Perform Full Scan since no channels in request. data->u.mon_stats_config.inst = wifi_app_inst_easymesh; - data->u.mon_stats_config.args.dwell_time = 20; + + radioOperation = getRadioOperationParam(radio_index); + if ( data->u.mon_stats_config.args.scan_mode == WIFI_RADIO_SCAN_MODE_FULL && + radioOperation->band == WIFI_FREQUENCY_6_BAND) { + data->u.mon_stats_config.args.dwell_time = 110; + } else { + data->u.mon_stats_config.args.dwell_time = 20; + } + data->u.mon_stats_config.req_state = mon_stats_request_state_start; data->u.mon_stats_config.start_immediately = true; data->u.mon_stats_config.delay_provider_sec = EM_NEIGBOUR_SCAN_PROVIDER_DELAY_SEC; diff --git a/source/webconfig/wifi_easymesh_translator.c b/source/webconfig/wifi_easymesh_translator.c index 9bcaaf671..2e0c512c8 100644 --- a/source/webconfig/wifi_easymesh_translator.c +++ b/source/webconfig/wifi_easymesh_translator.c @@ -2581,8 +2581,8 @@ webconfig_error_t translate_channel_stats_to_easymesh_channel_info(webconfig_sub em_scan_result.util = src->utilization; em_scan_result.noise = src->noise; em_scan_result.num_neighbors = src->num_neighbors; - em_scan_result.aggr_scan_duration = 0; - em_scan_result.scan_type = 0; + em_scan_result.aggr_scan_duration = src->aggregate_scan_duration; + em_scan_result.scan_type = src->scan_type; for (j = 0; j < src->num_neighbors && j < EM_MAX_NEIGHBORS; j++) { neighbor_bss_t *src_neighbor = &src->neighbors[j]; @@ -2602,9 +2602,19 @@ webconfig_error_t translate_channel_stats_to_easymesh_channel_info(webconfig_sub } else if (strncmp(src_neighbor->channel_bandwidth, "320", strlen("320")) == 0) { dst_neighbor->bandwidth = WIFI_CHANNELBANDWIDTH_320MHZ; } - dst_neighbor->bss_color = 0x8f; - dst_neighbor->channel_util = 00; - dst_neighbor->sta_count = (unsigned short)src_neighbor->station_count; + dst_neighbor->bss_color = src_neighbor->bss_color; + dst_neighbor->bss_load_element_present = src_neighbor->bss_load_element_present; + /* + * Copy BSS Load fields only if present, + * otherwise keep them zero + */ + if (src_neighbor->bss_load_element_present) { + dst_neighbor->channel_util = src_neighbor->channel_utilization; + dst_neighbor->sta_count = (unsigned short)src_neighbor->station_count; + } else { + dst_neighbor->channel_util = 0; + dst_neighbor->sta_count = 0; + } } count++; proto->put_scan_results(proto->data_model, &em_scan_result);