From b9a3868e2b710d66dae18a6183c264d9a89500c9 Mon Sep 17 00:00:00 2001 From: "pratheeksha.br" Date: Mon, 8 Jun 2026 07:07:30 +0000 Subject: [PATCH] [RDK Agent] Propagate all DFS events received from wifiHal to unified-wifi-mesh --- build/openwrt/makefile | 1 + include/wifi_base.h | 1 + include/wifi_webconfig.h | 28 ++++++ source/apps/analytics/wifi_analytics.c | 1 + source/apps/em/wifi_em.c | 34 +++++++ source/apps/em/wifi_em.h | 1 + source/core/wifi_ctrl_queue_handlers.c | 106 ++++++++++++++++++++ source/core/wifi_ctrl_rbus_handlers.c | 6 ++ source/core/wifi_ctrl_webconfig.c | 8 ++ source/db/wifi_db.c | 6 +- source/db/wifi_db_apis.c | 4 + source/webconfig/Makefile.am | 2 +- source/webconfig/wifi_webconfig.c | 11 ++ source/webconfig/wifi_webconfig_dfs_event.c | 82 +++++++++++++++ 14 files changed, 289 insertions(+), 2 deletions(-) create mode 100644 source/webconfig/wifi_webconfig_dfs_event.c diff --git a/build/openwrt/makefile b/build/openwrt/makefile index 7f0377efe..b8bde81fe 100644 --- a/build/openwrt/makefile +++ b/build/openwrt/makefile @@ -496,6 +496,7 @@ ifdef EM_APP $(ONE_WIFI_HOME)/source/webconfig/wifi_webconfig_em_ap_metrics_report.c endif WEBCONFIG_SOURCES += $(ONE_WIFI_HOME)/source/webconfig/wifi_webconfig_link_report.c + WEBCONFIG_SOURCES += $(ONE_WIFI_HOME)/source/webconfig/wifi_webconfig_dfs_event.c ifdef WIFI_SENSING_APP_SUPPORT CSOURCES += $(wildcard $(ONE_WIFI_HOME)/source/apps/wifi_sensing/src/*.c) diff --git a/include/wifi_base.h b/include/wifi_base.h index def0ede47..d564724fe 100644 --- a/include/wifi_base.h +++ b/include/wifi_base.h @@ -92,6 +92,7 @@ extern "C" { #define WIFI_LINK_QUALITY_DATA "Device.WiFi.LinkQualityData" #define WIFI_LINK_QUALITY_FLAGS "Device.WiFi.LinkQualityFlags" #define WIFI_IGNITE_STATUS "Device.WiFi.EndPoint.1.LinkQualityStatus" +#define WIFI_DFS_EVENT "Device.WiFi.EM.DFSEvent" #ifndef MAX_NUM_MLD_LINKS #define MAX_NUM_MLD_LINKS 15 diff --git a/include/wifi_webconfig.h b/include/wifi_webconfig.h index 3393f2418..9371b900f 100644 --- a/include/wifi_webconfig.h +++ b/include/wifi_webconfig.h @@ -148,6 +148,7 @@ typedef enum { webconfig_subdoc_type_memwraptool, webconfig_subdoc_type_link_report, webconfig_subdoc_type_ignite, + webconfig_subdoc_type_dfs_event, webconfig_subdoc_type_max } webconfig_subdoc_type_t; @@ -176,6 +177,7 @@ typedef enum { webconfig_subdoc_object_type_em_sta_link_metrics, webconfig_subdoc_object_type_em_ap_metrics_report, webconfig_subdoc_object_type_link_report, + webconfig_subdoc_object_type_dfs_event, webconfig_subdoc_object_max } webconfig_subdoc_object_type_t; @@ -210,6 +212,23 @@ typedef struct { void *stats; } collect_subscribed_stats_t; +typedef enum { + em_dfs_evnt_type_started = 0, + em_dfs_evnt_type_finished, + em_dfs_evnt_type_radar_detected, + em_dfs_evnt_type_aborted, + em_dfs_evnt_type_nop_finished +} em_dfs_evnt_type_t; + +typedef struct __attribute__((packed)) { + em_dfs_evnt_type_t event_type; + unsigned char radio_index; + unsigned char op_class; + unsigned char channel; + unsigned short sec_remain_non_occ_dur; + unsigned char status; +} em_bus_event_type_dfs_evnt_params_t; + typedef struct { wifi_global_config_t config; wifi_hal_capability_t hal_cap; @@ -235,6 +254,7 @@ typedef struct { em_ap_metrics_report_t em_ap_metrics_report; #endif report_batch_t *qmgr_report; + em_bus_event_type_dfs_evnt_params_t dfs_event; } webconfig_subdoc_decoded_data_t; typedef char * webconfig_subdoc_encoded_raw_t; @@ -700,6 +720,14 @@ webconfig_error_t encode_link_report_subdoc(webconfig_t *config, webconfig webconfig_error_t translate_to_link_report_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data); webconfig_error_t translate_from_link_report_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data); +// CAC EVENT +webconfig_error_t init_dfs_event_subdoc(webconfig_subdoc_t *doc); +webconfig_error_t access_check_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data); +webconfig_error_t decode_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data); +webconfig_error_t encode_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data); +webconfig_error_t translate_to_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data); +webconfig_error_t translate_from_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data); + #ifdef __cplusplus } #endif diff --git a/source/apps/analytics/wifi_analytics.c b/source/apps/analytics/wifi_analytics.c index 327705940..d806133b9 100644 --- a/source/apps/analytics/wifi_analytics.c +++ b/source/apps/analytics/wifi_analytics.c @@ -75,6 +75,7 @@ const char *subdoc_type_to_string(webconfig_subdoc_type_t type) DOC2S(webconfig_subdoc_type_em_channel_stats) #endif DOC2S(webconfig_subdoc_type_link_report) + DOC2S(webconfig_subdoc_type_dfs_event) default: wifi_util_error_print(WIFI_APPS, "%s:%d: event not handle[%d]\r\n", __func__, __LINE__, type); diff --git a/source/apps/em/wifi_em.c b/source/apps/em/wifi_em.c index ee64f6cca..ad4857f6a 100644 --- a/source/apps/em/wifi_em.c +++ b/source/apps/em/wifi_em.c @@ -24,6 +24,7 @@ #include "wifi_hal.h" #include "wifi_hal_ap.h" #include "wifi_mgr.h" +#include "wifi_hal_rdk_framework.h" #include #include @@ -1622,6 +1623,33 @@ static int em_handle_disassoc_device(wifi_app_t *app, void *arg) return 0; } +static int em_handle_hal_channel_change(wifi_app_t *app, void *data) +{ + wifi_channel_change_event_t *ch_chg = (wifi_channel_change_event_t *)data; + + if (ch_chg == NULL) { + wifi_util_error_print(WIFI_CTRL, "%s:%d: NULL channel change data!\n", __func__, __LINE__); + return RETURN_ERR; + } + + wifi_ctrl_t *wifi_ctrl = get_wifictrl_obj(); + raw_data_t rdata = {0}; + rdata.raw_data.bytes = malloc(sizeof(wifi_channel_change_event_t)); + + if (rdata.raw_data.bytes == NULL) { + wifi_util_error_print(WIFI_CTRL, "%s:%d: Could not allocate for wifi_channel_change_event_t\n", __func__, __LINE__); + return RETURN_ERR; + } + + rdata.data_type = bus_data_type_bytes; + memcpy(rdata.raw_data.bytes, ch_chg, sizeof(wifi_channel_change_event_t)); + rdata.raw_data_len = sizeof(wifi_channel_change_event_t); + get_bus_descriptor()->bus_event_publish_fn(&wifi_ctrl->handle, WIFI_EM_HAL_CHANNEL_CHANGE, &rdata); + free(rdata.raw_data.bytes); + + return RETURN_OK; +} + static int em_handle_sta_conn_status(wifi_app_t *app, void *data) { rdk_sta_data_t *sta_data = (rdk_sta_data_t *)data; @@ -3056,6 +3084,12 @@ int handle_em_hal_event(wifi_app_t *app, wifi_event_subtype_t sub_type, void *da em_handle_wnm_action_frame(app, data); break; + case wifi_event_hal_channel_change: + wifi_util_info_print(WIFI_EM, "%s:%d: case wifi_event_hal_channel_change \n", __func__, + __LINE__); + em_handle_hal_channel_change(app, data); + break; + default: wifi_util_dbg_print(WIFI_EM, "%s:%d app sub_event:%s not handled\r\n", __func__, __LINE__, wifi_event_subtype_to_string(sub_type)); diff --git a/source/apps/em/wifi_em.h b/source/apps/em/wifi_em.h index 43419ec49..db574e2ec 100644 --- a/source/apps/em/wifi_em.h +++ b/source/apps/em/wifi_em.h @@ -38,6 +38,7 @@ extern "C" { #define WIFI_EM_CLIENT_ASSOC_CTRL_REQ "Device.WiFi.EM.ClientAssocCtrlRequest" #define WIFI_EM_UNASSOC_STA_LINK_METRICS_RESP "Device.WiFi.EM.NaStaResponse" #define WIFI_EM_FAILED_CONNECTION "Device.WiFi.EM.FailedConnection" +#define WIFI_EM_HAL_CHANNEL_CHANGE "Device.WiFi.EM.HALChannelChange" #define WNM_CATEGORY 10 #define IEEE80211_HDRLEN 24 diff --git a/source/core/wifi_ctrl_queue_handlers.c b/source/core/wifi_ctrl_queue_handlers.c index ca1756e06..016dd5181 100644 --- a/source/core/wifi_ctrl_queue_handlers.c +++ b/source/core/wifi_ctrl_queue_handlers.c @@ -3620,6 +3620,64 @@ int dfs_nop_finish_timer(void *args) return TIMER_TASK_COMPLETE; } +static void publish_dfs_event(wifi_ctrl_t *ctrl, unsigned char radio_index, + wifi_radio_operationParam_t *radio_params, + wifi_channel_change_event_t *ch_chg, + em_dfs_evnt_type_t event_type, + unsigned short sec_remain_non_occ_dur) +{ + webconfig_subdoc_data_t *data; + raw_data_t rdata; + bus_error_t rc; + + wifi_util_error_print(WIFI_CTRL, "%s:%d: Start*****\n", __func__, __LINE__); + + data = (webconfig_subdoc_data_t *)malloc(sizeof(webconfig_subdoc_data_t)); + if (data == NULL) { + wifi_util_error_print(WIFI_CTRL, "%s:%d: malloc failed\n", __func__, __LINE__); + return; + } + + if (radio_params == NULL) { + wifi_util_error_print(WIFI_CTRL, "%s:%d: radio_params NULL\n", __func__, __LINE__); + return; + } + + // Populate the CAC event structure + data->u.decoded.dfs_event.event_type = event_type; + data->u.decoded.dfs_event.radio_index = radio_index; + data->u.decoded.dfs_event.op_class = radio_params->operatingClass; + data->u.decoded.dfs_event.channel = ch_chg->channel; + data->u.decoded.dfs_event.sec_remain_non_occ_dur = sec_remain_non_occ_dur; + data->u.decoded.dfs_event.status = 0; + + // Encode to JSON using WebConfig + if (webconfig_encode(&ctrl->webconfig, data, webconfig_subdoc_type_dfs_event) != webconfig_error_none) { + wifi_util_error_print(WIFI_CTRL, "%s:%d: Error encoding DFS event\n", __func__, __LINE__); + webconfig_data_free(data); + free(data); + return; + } + + memset(&rdata, 0, sizeof(raw_data_t)); + rdata.data_type = bus_data_type_string; + rdata.raw_data.bytes = (void *)data->u.encoded.raw; + rdata.raw_data_len = strlen(data->u.encoded.raw) + 1; + wifi_util_dbg_print(WIFI_WEBCONFIG,"raw data=%s\n",(char*)rdata.raw_data.bytes); + + rc = get_bus_descriptor()->bus_event_publish_fn(&ctrl->handle, WIFI_DFS_EVENT, &rdata); + if (rc != bus_error_success) { + wifi_util_error_print(WIFI_CTRL, "%s:%d: Failed to publish DFS event, error: %d\n", + __func__, __LINE__, rc); + } + else { + wifi_util_dbg_print(WIFI_CTRL, "%s:%d: Published DFS event, type: %d,",__func__, __LINE__, event_type); + } + + webconfig_data_free(data); + free(data); +} + void process_channel_change_event(wifi_channel_change_event_t *ch_chg, bool is_nop_start_reboot, unsigned int dfs_timer_secs) { wifi_radio_operationParam_t *radio_params = NULL; @@ -3747,6 +3805,28 @@ void process_channel_change_event(wifi_channel_change_event_t *ch_chg, bool is_n goto cleanup; } + // Get radio MAC address + mac_address_t radio_mac; + radio_interface_mapping_t *radio_iface_map = NULL; + wifi_platform_property_t *wifi_prop = &g_wifidb->hal_cap.wifi_prop; + bool radio_mac_valid = false; + + for (unsigned int k = 0; k < (sizeof(wifi_prop->radio_interface_map) / sizeof(radio_interface_mapping_t)); k++) { + if (wifi_prop->radio_interface_map[k].radio_index == ch_chg->radioIndex) { + radio_iface_map = &(wifi_prop->radio_interface_map[k]); + break; + } + } + + if (radio_iface_map != NULL) { + if (mac_address_from_name(radio_iface_map->interface_name, radio_mac) == 0) { + radio_mac_valid = true; + mac_addr_str_t mac_str; + to_mac_str(radio_mac, mac_str); + wifi_util_dbg_print(WIFI_CTRL, "%s:%d: Radio MAC: %s\n", __func__, __LINE__, mac_str); + } + } + switch (ch_chg->sub_event) { case WIFI_EVENT_RADAR_DETECTED : @@ -3755,6 +3835,12 @@ void process_channel_change_event(wifi_channel_change_event_t *ch_chg, bool is_n /* Ignore the duplicate radar events for the same channel triggered within 2 seconds */ break; } + + if (radio_mac_valid) { + unsigned short sec_remain = 1800; + publish_dfs_event(ctrl, ch_chg->radioIndex, radio_params, ch_chg, em_dfs_evnt_type_radar_detected, sec_remain); + } + unsigned int channel_index = 0; l_radio->radarInfo.last_channel = ch_chg->channel; l_radio->radarInfo.num_detected++; @@ -3786,9 +3872,17 @@ void process_channel_change_event(wifi_channel_change_event_t *ch_chg, bool is_n break; case WIFI_EVENT_RADAR_CAC_FINISHED : chan_state = CHAN_STATE_DFS_CAC_COMPLETED; + if (radio_mac_valid) { + publish_dfs_event(ctrl, ch_chg->radioIndex, radio_params, ch_chg, em_dfs_evnt_type_finished, 0); + } + break; case WIFI_EVENT_RADAR_CAC_ABORTED : chan_state = CHAN_STATE_DFS_CAC_COMPLETED; + if (radio_mac_valid) { + publish_dfs_event(ctrl, ch_chg->radioIndex, radio_params, ch_chg, em_dfs_evnt_type_aborted, 0); + } + break; case WIFI_EVENT_RADAR_NOP_FINISHED : if( (unsigned int)l_radio->radarInfo.last_channel == ch_chg->channel && (time_now - l_radio->radarInfo.timestamp >= 1800)) { @@ -3819,12 +3913,24 @@ void process_channel_change_event(wifi_channel_change_event_t *ch_chg, bool is_n } } chan_state = CHAN_STATE_DFS_NOP_FINISHED; + if (radio_mac_valid) { + publish_dfs_event(ctrl, ch_chg->radioIndex, radio_params, ch_chg, em_dfs_evnt_type_nop_finished, 0); + } + break; case WIFI_EVENT_RADAR_PRE_CAC_EXPIRED : chan_state = CHAN_STATE_DFS_NOP_FINISHED; + if (radio_mac_valid) { + publish_dfs_event(ctrl, ch_chg->radioIndex, radio_params, ch_chg, em_dfs_evnt_type_nop_finished, 0); + } + break; case WIFI_EVENT_RADAR_CAC_STARTED : chan_state = CHAN_STATE_DFS_CAC_START; + if (radio_mac_valid) { + publish_dfs_event(ctrl, ch_chg->radioIndex, radio_params, ch_chg, em_dfs_evnt_type_started, 0); + } + break; } diff --git a/source/core/wifi_ctrl_rbus_handlers.c b/source/core/wifi_ctrl_rbus_handlers.c index 2d789e7ba..89d5bcdb5 100644 --- a/source/core/wifi_ctrl_rbus_handlers.c +++ b/source/core/wifi_ctrl_rbus_handlers.c @@ -4438,6 +4438,12 @@ void bus_register_handlers(wifi_ctrl_t *ctrl) { WIFI_CSA_BEACON_FRAME_RECEIVED, bus_element_type_event, { NULL, NULL, NULL, NULL, eventSubHandler, NULL}, high_speed, ZERO_TABLE, { bus_data_type_bytes, false, 0, 0, 0, NULL } }, + { WIFI_DFS_EVENT, bus_element_type_event, + { NULL, NULL, NULL, NULL, eventSubHandler, NULL}, high_speed, ZERO_TABLE, + { bus_data_type_bytes, false, 0, 0, 0, NULL } }, + { WIFI_EM_HAL_CHANNEL_CHANGE, bus_element_type_event, + { NULL, NULL, NULL, NULL, eventSubHandler, NULL}, high_speed, ZERO_TABLE, + { bus_data_type_bytes, false, 0, 0, 0, NULL } }, { WIFI_LINK_QUALITY_DATA, bus_element_type_method, { wifi_get_link_quality_data, NULL, NULL, NULL, NULL, NULL }, slow_speed, ZERO_TABLE, { bus_data_type_string, false, 0, 0, 0, NULL } }, diff --git a/source/core/wifi_ctrl_webconfig.c b/source/core/wifi_ctrl_webconfig.c index 3bf430c85..f81833bf8 100644 --- a/source/core/wifi_ctrl_webconfig.c +++ b/source/core/wifi_ctrl_webconfig.c @@ -3187,6 +3187,14 @@ webconfig_error_t webconfig_ctrl_apply(webconfig_subdoc_t *doc, webconfig_subdoc } break; + case webconfig_subdoc_type_dfs_event: + if (data->descriptor & webconfig_data_descriptor_encoded) { + ret = webconfig_bus_apply(ctrl, &data->u.encoded); + } else { + return webconfig_error_apply; + } + break; + default: break; } diff --git a/source/db/wifi_db.c b/source/db/wifi_db.c index 51b4e64f1..928c987bb 100644 --- a/source/db/wifi_db.c +++ b/source/db/wifi_db.c @@ -112,6 +112,7 @@ static int init_radio_config_default(int radio_index, wifi_radio_operationParam_ cfg.operatingClass = 128; cfg.channel = 36; cfg.channelWidth = WIFI_CHANNELBANDWIDTH_80MHZ; + #if defined (_HUB4_PRODUCT_REQ_) && !defined (_SR213_PRODUCT_REQ_) cfg.variant = WIFI_80211_VARIANT_A | WIFI_80211_VARIANT_N | WIFI_80211_VARIANT_AC; #else @@ -121,16 +122,19 @@ static int init_radio_config_default(int radio_index, wifi_radio_operationParam_ #ifdef CONFIG_IEEE80211BE cfg.variant |= WIFI_80211_VARIANT_BE; #endif /* CONFIG_IEEE80211BE */ + cfg.DfsEnabled = true; + cfg.DfsEnabledBootup = true; break; case WIFI_FREQUENCY_5H_BAND: cfg.operatingClass = 128; cfg.channel = 157; cfg.channelWidth = WIFI_CHANNELBANDWIDTH_80MHZ; cfg.variant = WIFI_80211_VARIANT_A | WIFI_80211_VARIANT_N | WIFI_80211_VARIANT_AC | WIFI_80211_VARIANT_AX; - #ifdef CONFIG_IEEE80211BE cfg.variant |= WIFI_80211_VARIANT_BE; #endif /* CONFIG_IEEE80211BE */ + cfg.DfsEnabled = true; + cfg.DfsEnabledBootup = true; break; case WIFI_FREQUENCY_6_BAND: cfg.operatingClass = 134; diff --git a/source/db/wifi_db_apis.c b/source/db/wifi_db_apis.c index 5b9fb692e..25e96064e 100644 --- a/source/db/wifi_db_apis.c +++ b/source/db/wifi_db_apis.c @@ -7347,6 +7347,8 @@ int wifidb_init_radio_config_default(int radio_index,wifi_radio_operationParam_t #ifdef CONFIG_IEEE80211BE cfg->variant |= WIFI_80211_VARIANT_BE; #endif /* CONFIG_IEEE80211BE */ + cfg->DfsEnabled = true; + cfg->DfsEnabledBootup = true; break; case WIFI_FREQUENCY_5H_BAND: cfg->operatingClass = 128; @@ -7363,6 +7365,8 @@ int wifidb_init_radio_config_default(int radio_index,wifi_radio_operationParam_t #ifdef CONFIG_IEEE80211BE cfg->variant |= WIFI_80211_VARIANT_BE; #endif /* CONFIG_IEEE80211BE */ + cfg->DfsEnabled = true; + cfg->DfsEnabledBootup = true; break; case WIFI_FREQUENCY_6_BAND: cfg->operatingClass = 134; diff --git a/source/webconfig/Makefile.am b/source/webconfig/Makefile.am index 25313f345..444728f63 100644 --- a/source/webconfig/Makefile.am +++ b/source/webconfig/Makefile.am @@ -72,7 +72,7 @@ libwifi_webconfig_la_CPPFLAGS += -I$(top_srcdir)/source/dml/wifi_ssp -I$(top_src libwifi_webconfig_la_CFLAGS = $(SYSTEMD_CFLAGS) -libwifi_webconfig_la_SOURCES = wifi_webconfig.c wifi_encoder.c wifi_decoder.c wifi_webconfig_home.c wifi_webconfig_mesh.c wifi_webconfig_private.c wifi_webconfig_radio.c wifi_webconfig_xfinity.c wifi_webconfig_associated_client.c wifi_webconfig_wifiapi_radio.c wifi_webconfig_wifiapi_vap.c wifi_webconfig_macfilter.c wifi_webconfig_blaster.c wifi_webconfig_harvester.c wifi_webconfig_wifi_config.c wifi_webconfig_csi.c wifi_webconfig_mesh_sta.c wifi_webconfig_mesh_backhaul.c wifi_webconfig_null.c wifi_webconfig_stats_config.c wifi_webconfig_steering_config.c wifi_webconfig_steering_clients.c wifi_webconfig_lnf.c wifi_webconfig_vif_neighbors.c wifi_webconfig_mesh_backhaul_sta.c wifi_webconfig_dml.c wifi_webconfig_levl.c wifi_webconfig_cac.c wifi_webconfig_radio_stats.c wifi_webconfig_neighbor_stats.c wifi_webconfig_assocdevice_stats.c wifi_webconfig_radiodiag_stats.c wifi_webconfig_radio_temperature.c wifi_webconfig_multivap.c wifi_webconfig_easymesh_config.c wifi_webconfig_beacon_report.c wifi_webconfig_memwraptool.c wifi_webconfig_link_report.c wifi_webconfig_ignite.c +libwifi_webconfig_la_SOURCES = wifi_webconfig.c wifi_encoder.c wifi_decoder.c wifi_ovsdb_translator.c wifi_webconfig_home.c wifi_webconfig_mesh.c wifi_webconfig_private.c wifi_webconfig_radio.c wifi_webconfig_xfinity.c wifi_webconfig_associated_client.c wifi_webconfig_wifiapi_radio.c wifi_webconfig_wifiapi_vap.c wifi_webconfig_macfilter.c wifi_webconfig_blaster.c wifi_webconfig_harvester.c wifi_webconfig_wifi_config.c wifi_webconfig_csi.c wifi_webconfig_mesh_sta.c wifi_webconfig_mesh_backhaul.c wifi_webconfig_null.c wifi_webconfig_stats_config.c wifi_webconfig_steering_config.c wifi_webconfig_steering_clients.c wifi_webconfig_lnf.c wifi_webconfig_vif_neighbors.c wifi_webconfig_mesh_backhaul_sta.c wifi_webconfig_dml.c wifi_webconfig_levl.c wifi_webconfig_cac.c wifi_webconfig_radio_stats.c wifi_webconfig_neighbor_stats.c wifi_webconfig_assocdevice_stats.c wifi_webconfig_radiodiag_stats.c wifi_webconfig_radio_temperature.c wifi_webconfig_multivap.c wifi_webconfig_easymesh_config.c wifi_webconfig_beacon_report.c wifi_webconfig_memwraptool.c wifi_webconfig_link_report.c wifi_webconfig_ignite.c wifi_webconfig_dfs_event.c if EM_APP_SUPPORT libwifi_webconfig_la_SOURCES += wifi_webconfig_em_channel_stats.c wifi_webconfig_em_sta_link_metrics.c wifi_webconfig_em_ap_metrics_report.c libwifi_webconfig_la_CFLAGS += $(EM_APP_FLAG) diff --git a/source/webconfig/wifi_webconfig.c b/source/webconfig/wifi_webconfig.c index 71289dfd6..92387a87e 100644 --- a/source/webconfig/wifi_webconfig.c +++ b/source/webconfig/wifi_webconfig.c @@ -794,6 +794,17 @@ webconfig_error_t webconfig_init(webconfig_t *config) config->subdocs[webconfig_subdoc_type_link_report].translate_to_subdoc = translate_to_link_report_subdoc; config->subdocs[webconfig_subdoc_type_link_report].translate_from_subdoc = translate_from_link_report_subdoc; + config->subdocs[webconfig_subdoc_type_dfs_event].type = webconfig_subdoc_type_dfs_event; + strcpy(config->subdocs[webconfig_subdoc_type_dfs_event].name, "DFSEvent"); + config->subdocs[webconfig_subdoc_type_dfs_event].major = 1; + config->subdocs[webconfig_subdoc_type_dfs_event].minor = 1; + config->subdocs[webconfig_subdoc_type_dfs_event].init_subdoc = init_dfs_event_subdoc; + config->subdocs[webconfig_subdoc_type_dfs_event].init_subdoc(&config->subdocs[webconfig_subdoc_type_dfs_event]); + config->subdocs[webconfig_subdoc_type_dfs_event].access_check_subdoc = access_check_dfs_event_subdoc; + config->subdocs[webconfig_subdoc_type_dfs_event].encode_subdoc = encode_dfs_event_subdoc; + config->subdocs[webconfig_subdoc_type_dfs_event].decode_subdoc = decode_dfs_event_subdoc; + config->subdocs[webconfig_subdoc_type_dfs_event].translate_to_subdoc = translate_to_dfs_event_subdoc; + config->subdocs[webconfig_subdoc_type_dfs_event].translate_from_subdoc = translate_from_dfs_event_subdoc; config->proto_desc.translate_to = translate_to_proto; config->proto_desc.translate_from = translate_from_proto; diff --git a/source/webconfig/wifi_webconfig_dfs_event.c b/source/webconfig/wifi_webconfig_dfs_event.c new file mode 100644 index 000000000..94a2a21e0 --- /dev/null +++ b/source/webconfig/wifi_webconfig_dfs_event.c @@ -0,0 +1,82 @@ +#include "wifi_webconfig.h" +#include "wifi_util.h" + +webconfig_subdoc_object_t dfs_event_objects[3] = { + { webconfig_subdoc_object_type_version, "Version" }, + { webconfig_subdoc_object_type_subdoc, "SubDocName" }, + { webconfig_subdoc_object_type_dfs_event, "DFSEvent" } +}; + +webconfig_error_t init_dfs_event_subdoc(webconfig_subdoc_t *doc) +{ + doc->num_objects = sizeof(dfs_event_objects)/sizeof(webconfig_subdoc_object_t); + memcpy((unsigned char *)doc->objects, (unsigned char *)&dfs_event_objects, sizeof(dfs_event_objects)); + + return webconfig_error_none; +} +webconfig_error_t access_check_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data) +{ + wifi_util_info_print(WIFI_WEBCONFIG, "%s:%d: \n", __func__, __LINE__); + return webconfig_error_none; +} +webconfig_error_t encode_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data) +{ + wifi_util_info_print(WIFI_WEBCONFIG, "%s:%d: \n", __func__, __LINE__); + cJSON *json, *obj; + char *str; + em_bus_event_type_dfs_evnt_params_t *params; + + if (data == NULL) { + return webconfig_error_encode; + } + + params = &data->u.decoded.dfs_event; + + json = cJSON_CreateObject(); + if (json == NULL) { + return webconfig_error_encode; + } + + data->u.encoded.json = json; + cJSON_AddStringToObject(json, "Version", "1.0"); + cJSON_AddStringToObject(json, "SubDocName", "DFSEvent"); + + obj = cJSON_CreateObject(); + cJSON_AddItemToObject(json, "DFSEvent", obj); + cJSON_AddNumberToObject(obj, "event_type", params->event_type); + cJSON_AddNumberToObject(obj, "radio_index", params->radio_index); + cJSON_AddNumberToObject(obj, "op_class", params->op_class); + cJSON_AddNumberToObject(obj, "channel", params->channel); + cJSON_AddNumberToObject(obj, "sec_remain_non_occ_dur", params->sec_remain_non_occ_dur); + cJSON_AddNumberToObject(obj, "status", params->status); + str = cJSON_Print(json); + + data->u.encoded.raw = (webconfig_subdoc_encoded_raw_t)calloc(strlen(str) + 1, sizeof(char)); + if (data->u.encoded.raw == NULL) { + cJSON_free(str); + cJSON_Delete(json); + return webconfig_error_encode; + } + + memcpy(data->u.encoded.raw, str, strlen(str) + 1); + data->descriptor = webconfig_data_descriptor_encoded; + cJSON_free(str); + cJSON_Delete(json); + + return webconfig_error_none; +} + +webconfig_error_t decode_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data) +{ + return webconfig_error_none; +} + +webconfig_error_t translate_to_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data) +{ + return webconfig_error_none; +} + +webconfig_error_t translate_from_dfs_event_subdoc(webconfig_t *config, webconfig_subdoc_data_t *data) +{ + return webconfig_error_none; +}