Skip to content

Commit a45a921

Browse files
ArsenPodobaArsen Podoba
authored andcommitted
DTMESH-496: Add WPS results callback registration API
Reason for change: To be able start WPS session from OVSDB Test procedure: 1) Verify successful build. 2) Change wps_pbc value in Wifi_VIF_Config 3) Confirm that callback executes correctly and updates runtime/OVSDB state. Risks: Low. Scoped to WPS feature with guarded code paths. Priority: P1 Signed-off-by: Arsen Podoba <[email protected]>
1 parent eca583b commit a45a921

File tree

8 files changed

+117
-5
lines changed

8 files changed

+117
-5
lines changed

include/wifi_events.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ typedef enum {
111111
wifi_event_type_csi_data,
112112
wifi_event_br_report,
113113
wifi_event_hal_csa_beacon_frame,
114+
wifi_event_hal_wps_results,
114115
wifi_event_hal_max,
115116

116117
// Commands

source/core/wifi_ctrl.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,18 @@ void channel_change_callback(wifi_channel_change_event_t radio_channel_param)
12891289
return;
12901290
}
12911291

1292+
int wps_event_callback(int apIndex, wifi_wps_ev_t event)
1293+
{
1294+
wifi_wps_event_t wps_event;
1295+
1296+
wps_event.vap_index = apIndex;
1297+
wps_event.event = event;
1298+
1299+
push_event_to_ctrl_queue((wifi_wps_event_t *)&wps_event, sizeof(wifi_wps_event_t), wifi_event_type_hal_ind, wifi_event_hal_wps_results, NULL);
1300+
1301+
return RETURN_OK;
1302+
}
1303+
12921304
int init_wifi_ctrl(wifi_ctrl_t *ctrl)
12931305
{
12941306
unsigned int i;
@@ -1371,6 +1383,8 @@ int init_wifi_ctrl(wifi_ctrl_t *ctrl)
13711383
/* Register wifi hal channel change events callback */
13721384
wifi_chan_event_register(channel_change_callback);
13731385

1386+
wifi_wpsEvent_callback_register(wps_event_callback);
1387+
13741388
ctrl->bus_events_subscribed = false;
13751389
ctrl->tunnel_events_subscribed = false;
13761390

source/core/wifi_ctrl_queue_handlers.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,6 +1994,50 @@ void process_assoc_device_event(void *data)
19941994
}
19951995
}
19961996

1997+
void process_wps_results_event(wifi_wps_event_t *wps_event)
1998+
{
1999+
#ifdef FEATURE_SUPPORT_WPS
2000+
wifi_ctrl_t *ctrl = (wifi_ctrl_t *)get_wifictrl_obj();
2001+
wifi_vap_info_t *vap_info = NULL;
2002+
rdk_wifi_vap_info_t *rdk_vap_info = NULL;
2003+
unsigned int vap_index = wps_event->vap_index;
2004+
bool wpsPushButton = false;
2005+
2006+
wifi_util_info_print(WIFI_CTRL, "%s:%d wps event[%d] is received\n", __func__, __LINE__, wps_event->event);
2007+
2008+
switch(wps_event->event) {
2009+
case wifi_wps_ev_pbc_active:
2010+
wpsPushButton = true;
2011+
break;
2012+
2013+
case wifi_wps_ev_success:
2014+
case wifi_wps_ev_fail:
2015+
case wifi_wps_ev_pbc_timeout:
2016+
case wifi_wps_ev_pbc_disable:
2017+
wpsPushButton = false;
2018+
break;
2019+
}
2020+
2021+
vap_info = get_wifidb_vap_parameters(vap_index);
2022+
if (vap_info == NULL) {
2023+
wifi_util_error_print(WIFI_CTRL, "%s:%d failed to get vap info for index %d\n",
2024+
__func__, __LINE__, vap_index);
2025+
return;
2026+
}
2027+
2028+
rdk_vap_info = get_wifidb_rdk_vap_info(vap_index);
2029+
if (rdk_vap_info == NULL) {
2030+
wifi_util_error_print(WIFI_CTRL, "%s:%d failed to get rdk vap info for index %d\n",
2031+
__func__, __LINE__, vap_index);
2032+
return;
2033+
}
2034+
2035+
vap_info->u.bss_info.wpsPushButton = wpsPushButton;
2036+
get_wifidb_obj()->desc.update_wifi_vap_info_fn(vap_info->vap_name, vap_info, rdk_vap_info);
2037+
ctrl->webconfig_state |= ctrl_webconfig_state_vap_private_cfg_rsp_pending;
2038+
#endif
2039+
}
2040+
19972041
void process_factory_reset_command(bool type)
19982042
{
19992043
wifi_mgr_t *p_wifi_mgr = get_wifimgr_obj();
@@ -3687,6 +3731,10 @@ void handle_hal_indication(wifi_ctrl_t *ctrl, void *data, unsigned int len,
36873731
process_csa_beacon_frame_event(data, len, ctrl);
36883732
break;
36893733

3734+
case wifi_event_hal_wps_results:
3735+
process_wps_results_event(data);
3736+
break;
3737+
36903738
default:
36913739

36923740
wifi_util_error_print(WIFI_CTRL, "[%s]:WIFI hal handler not supported this event %s\r\n",

source/core/wifi_ctrl_webconfig.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ int webconfig_hal_vap_apply_by_name(wifi_ctrl_t *ctrl, webconfig_subdoc_decoded_
732732
vap_svc_t *svc;
733733
wifi_vap_info_map_t *mgr_vap_map, *p_tgt_vap_map = NULL;
734734
bool found_target = false;
735+
bool wpsPushButtonChanged = false;
735736
wifi_mgr_t *mgr = get_wifimgr_obj();
736737
char update_status[128];
737738
public_vaps_data_t pub;
@@ -825,8 +826,10 @@ int webconfig_hal_vap_apply_by_name(wifi_ctrl_t *ctrl, webconfig_subdoc_decoded_
825826
mgr_rdk_vap_info->exists = rdk_vap_info->exists;
826827
}
827828

829+
wpsPushButtonChanged = isVapPrivate(tgt_vap_index) && is_wpsPushButton_changed(mgr_vap_info, vap_info);
830+
828831
wifi_util_dbg_print(WIFI_CTRL,"%s:%d: Comparing VAP [%s] with [%s]. \n",__func__, __LINE__,mgr_vap_info->vap_name,vap_info->vap_name);
829-
if (is_vap_param_config_changed(mgr_vap_info, vap_info, mgr_rdk_vap_info, rdk_vap_info,
832+
if (is_vap_param_config_changed_except_wpsPushButton(mgr_vap_info, vap_info, mgr_rdk_vap_info, rdk_vap_info,
830833
isVapSTAMesh(tgt_vap_index)) || is_force_apply_true(rdk_vap_info)) {
831834
// radio data changed apply
832835
wifi_util_info_print(WIFI_CTRL, "%s:%d: Change detected in received vap config, applying new configuration for vap: %s\n",
@@ -914,6 +917,13 @@ int webconfig_hal_vap_apply_by_name(wifi_ctrl_t *ctrl, webconfig_subdoc_decoded_
914917
wifi_util_info_print(WIFI_WEBCONFIG, "%s:%d: Received vap config is same for %s, not applying\n",
915918
__func__, __LINE__, vap_names[i]);
916919
}
920+
921+
if (wpsPushButtonChanged)
922+
{
923+
push_event_to_ctrl_queue(&tgt_vap_index, sizeof(tgt_vap_index), wifi_event_type_command,
924+
vap_info->u.bss_info.wpsPushButton ? wifi_event_type_command_wps : wifi_event_type_command_wps_cancel, NULL);
925+
mgr_vap_info->u.bss_info.wpsPushButton = false;
926+
}
917927
}
918928

919929
return RETURN_OK;

source/core/wifi_events.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ const char *wifi_event_subtype_to_string(wifi_event_subtype_t type)
105105
DOC2S(wifi_event_radius_eap_failure)
106106
DOC2S(wifi_event_radius_fallback_and_failover)
107107
DOC2S(wifi_event_type_csi_data)
108+
DOC2S(wifi_event_hal_wps_results)
108109
DOC2S(wifi_event_hal_max)
109110
DOC2S(wifi_event_type_active_gw_check)
110111
DOC2S(wifi_event_type_command_factory_reset)

source/utils/wifi_util.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3876,8 +3876,8 @@ static bool is_vap_preassoc_cac_config_changed(char *vap_name,
38763876
}
38773877
}
38783878

3879-
bool is_vap_param_config_changed(wifi_vap_info_t *vap_info_old, wifi_vap_info_t *vap_info_new,
3880-
rdk_wifi_vap_info_t *rdk_old, rdk_wifi_vap_info_t *rdk_new, bool isSta)
3879+
bool is_vap_param_config_changed_core(wifi_vap_info_t *vap_info_old, wifi_vap_info_t *vap_info_new,
3880+
rdk_wifi_vap_info_t *rdk_old, rdk_wifi_vap_info_t *rdk_new, bool isSta, bool include_wpsPushButton)
38813881
{
38823882

38833883
if ((vap_info_old == NULL) || (vap_info_new == NULL) || (rdk_old == NULL) ||
@@ -3957,8 +3957,7 @@ bool is_vap_param_config_changed(wifi_vap_info_t *vap_info_old, wifi_vap_info_t
39573957
IS_CHANGED(vap_info_old->u.bss_info.wepKeyLength,
39583958
vap_info_new->u.bss_info.wepKeyLength) ||
39593959
IS_CHANGED(vap_info_old->u.bss_info.bssHotspot, vap_info_new->u.bss_info.bssHotspot) ||
3960-
IS_CHANGED(vap_info_old->u.bss_info.wpsPushButton,
3961-
vap_info_new->u.bss_info.wpsPushButton) ||
3960+
(include_wpsPushButton && IS_CHANGED(vap_info_old->u.bss_info.wpsPushButton, vap_info_new->u.bss_info.wpsPushButton)) ||
39623961
IS_CHANGED(vap_info_old->u.bss_info.connected_building_enabled,
39633962
vap_info_new->u.bss_info.connected_building_enabled) ||
39643963
IS_CHANGED(vap_info_old->u.bss_info.mdu_enabled, vap_info_new->u.bss_info.mdu_enabled) ||
@@ -3996,6 +3995,26 @@ bool is_vap_param_config_changed(wifi_vap_info_t *vap_info_old, wifi_vap_info_t
39963995
return false;
39973996
}
39983997

3998+
bool is_vap_param_config_changed(wifi_vap_info_t *vap_info_old, wifi_vap_info_t *vap_info_new,
3999+
rdk_wifi_vap_info_t *rdk_old, rdk_wifi_vap_info_t *rdk_new, bool isSta)
4000+
{
4001+
return is_vap_param_config_changed_core(vap_info_old, vap_info_new, rdk_old, rdk_new, isSta, /*include_wpsPushButton=*/true);
4002+
}
4003+
4004+
bool is_vap_param_config_changed_except_wpsPushButton(wifi_vap_info_t *vap_info_old,
4005+
wifi_vap_info_t *vap_info_new,
4006+
rdk_wifi_vap_info_t *rdk_old,
4007+
rdk_wifi_vap_info_t *rdk_new,
4008+
bool isSta)
4009+
{
4010+
return is_vap_param_config_changed_core(vap_info_old, vap_info_new, rdk_old, rdk_new, isSta, /*include_wpsPushButton=*/false);
4011+
}
4012+
4013+
bool is_wpsPushButton_changed(wifi_vap_info_t *vap_info_old, wifi_vap_info_t *vap_info_new)
4014+
{
4015+
return IS_CHANGED(vap_info_old->u.bss_info.wpsPushButton, vap_info_new->u.bss_info.wpsPushButton);
4016+
}
4017+
39994018
// Countrycode: US, Band 2.4G
40004019
static const wifi_operating_classes_t us_24G[] = {
40014020
{ 81, -30, 2, { 12, 13 } },

source/utils/wifi_util.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,12 @@ bool is_6g_supported_device(wifi_platform_property_t *wifi_prop);
456456
int scan_mode_type_conversion(wifi_neighborScanMode_t *scan_mode_enum, char *scan_mode_str, int scan_mode_len, unsigned int conv_type);
457457
bool is_vap_param_config_changed(wifi_vap_info_t *vap_info_old, wifi_vap_info_t *vap_info_new,
458458
rdk_wifi_vap_info_t *rdk_old, rdk_wifi_vap_info_t *rdk_new, bool isSta);
459+
bool is_vap_param_config_changed_except_wpsPushButton(wifi_vap_info_t *vap_info_old,
460+
wifi_vap_info_t *vap_info_new,
461+
rdk_wifi_vap_info_t *rdk_old,
462+
rdk_wifi_vap_info_t *rdk_new,
463+
bool isSta);
464+
bool is_wpsPushButton_changed(wifi_vap_info_t *vap_info_old, wifi_vap_info_t *vap_info_new);
459465
int update_radio_operating_classes(wifi_radio_operationParam_t *oper);
460466
int get_partner_id(char *partner_id);
461467
int interfacename_from_mac(const mac_address_t *mac, char *ifname);

source/webconfig/wifi_ovsdb_translator.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,6 +2198,7 @@ webconfig_error_t translate_vap_info_to_ovsdb_common(const wifi_vap_info_t *vap,
21982198
vap_row->btm = vap->u.bss_info.bssTransitionActivated;
21992199
vap_row->rrm = vap->u.bss_info.nbrReportActivated;
22002200
vap_row->wps = vap->u.bss_info.wps.enable;
2201+
vap_row->wps_pbc = vap->u.bss_info.wpsPushButton;
22012202
strncpy(vap_row->wps_pbc_key_id, vap->u.bss_info.wps.pin, sizeof(vap_row->wps_pbc_key_id));
22022203
vap_row->vlan_id = iface_map->vlan_id;
22032204
return webconfig_error_none;
@@ -2752,6 +2753,13 @@ webconfig_error_t translate_vap_info_to_vif_state_common(const wifi_vap_info_t *
27522753
vap_row->wps_exists=false;
27532754
}
27542755

2756+
if (vap->u.bss_info.wpsPushButton) {
2757+
vap_row->wps_pbc = vap->u.bss_info.wpsPushButton;
2758+
vap_row->wps_pbc_exists = true;
2759+
} else {
2760+
vap_row->wps_pbc_exists = false;
2761+
}
2762+
27552763
if (strlen(vap->u.bss_info.wps.pin) != 0) {
27562764
strncpy(vap_row->wps_pbc_key_id, vap->u.bss_info.wps.pin, sizeof(vap_row->wps_pbc_key_id));
27572765
vap_row->wps_pbc_key_id_exists = true;
@@ -3914,8 +3922,13 @@ webconfig_error_t translate_ovsdb_to_vap_info_common(const struct schema_Wifi_VI
39143922
vap->u.bss_info.bssTransitionActivated = vap_row->btm;
39153923
vap->u.bss_info.nbrReportActivated = vap_row->rrm;
39163924
vap->u.bss_info.wps.enable = vap_row->wps;
3925+
vap->u.bss_info.wpsPushButton = vap_row->wps_pbc;
39173926
snprintf(vap->u.bss_info.wps.pin, sizeof(vap->u.bss_info.wps.pin), "%s",
39183927
vap_row->wps_pbc_key_id);
3928+
if (vap->u.bss_info.wps.enable)
3929+
vap->u.bss_info.wps.methods |= WIFI_ONBOARDINGMETHODS_PUSHBUTTON;
3930+
if (strlen(vap->u.bss_info.wps.pin))
3931+
vap->u.bss_info.wps.methods |= WIFI_ONBOARDINGMETHODS_PIN;
39193932
wifi_util_dbg_print(WIFI_WEBCONFIG, "%s:%d: vapIndex : %d min_hw_mode %s\n", __func__, __LINE__,
39203933
vap->vap_index, vap_row->min_hw_mode);
39213934
min_hw_mode_conversion(vap->vap_index, (char *)vap_row->min_hw_mode, "", "CONFIG");

0 commit comments

Comments
 (0)