diff --git a/source/apps/em/wifi_em.c b/source/apps/em/wifi_em.c index fde89977a..becfbcf26 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; @@ -645,6 +647,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; @@ -744,17 +747,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_load_element_present = 0; - neighbor->bss_color = 0; + neighbor->bss_color = EM_BSS_COLOR_DEFAULT; + neighbor->bss_load_element_present = 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_presnt %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)); diff --git a/source/stats/wifi_stats_radio_channel.c b/source/stats/wifi_stats_radio_channel.c index af1c0e497..2b4b1ce6c 100644 --- a/source/stats/wifi_stats_radio_channel.c +++ b/source/stats/wifi_stats_radio_channel.c @@ -1060,6 +1060,8 @@ int execute_radio_channel_api(wifi_mon_collector_element_t *c_elem, wifi_monitor } } + args->dwell_time = dwell_time; + int buffer_size = sizeof(char) * num_channels * 5; channel_buff = (char *)malloc(buffer_size); if (channel_buff != NULL) { diff --git a/source/webconfig/wifi_easymesh_translator.c b/source/webconfig/wifi_easymesh_translator.c index e82c38658..413dbdb8f 100644 --- a/source/webconfig/wifi_easymesh_translator.c +++ b/source/webconfig/wifi_easymesh_translator.c @@ -2515,8 +2515,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]; @@ -2536,9 +2536,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);