diff --git a/kernel/morse-bundle/files/morse/scripts/dpp_start.sh b/kernel/morse-bundle/files/morse/scripts/dpp_start.sh index e34b0d1..ccc78e4 100644 --- a/kernel/morse-bundle/files/morse/scripts/dpp_start.sh +++ b/kernel/morse-bundle/files/morse/scripts/dpp_start.sh @@ -6,6 +6,9 @@ . /lib/functions.sh . /lib/functions/leds.sh +# This file is removed upon DPP timeout/Success in wpa_s1g_dpp_action.sh script +dpp_start_time=/tmp/dpp_start_time + start_wpa_event_listener() { # Start the wpa_event_listener to listen for DPP events. The # wpa_event_listener will write the config on the STA side and control the @@ -16,7 +19,7 @@ start_wpa_event_listener() { } _maybe_press_dpp_button() { - # For a morse, not disabled, AP or STA, send the button press to hostap. + # For a morse, not disabled, AP or STA, send the button press to hostap local section_name="$1" config_get device "$section_name" device if [ "$(uci -q get "wireless.$device.type")" != "morse" ]; then @@ -32,11 +35,19 @@ _maybe_press_dpp_button() { echo "starting dpp due to button press" start_wpa_event_listener -p /var/run/hostapd_s1g/ hostapd_cli_s1g dpp_push_button + if [ $? -eq 0 ]; then + # Update the dpp start time + echo "$current_uptime" > "$dpp_start_time" + fi ;; "sta") echo "starting dpp due to button press" start_wpa_event_listener wpa_cli_s1g dpp_push_button + if [ $? -eq 0 ]; then + # Update the dpp start time + echo "$current_uptime" > "$dpp_start_time" + fi ;; esac 2>&1 | logger -t button -p daemon.notice } @@ -48,4 +59,18 @@ maybe_press_dpp_button() { config_foreach _maybe_press_dpp_button wifi-iface } +# Create a DPP timestamp file with the current uptime after the initial button press. +# For subsequent button presses, check the timestamp to ensure at least 120 seconds have passed, +# preventing rapid consecutive DPP events. +current_uptime=$(awk '{print int($1)}' /proc/uptime) + +if [ -f $dpp_start_time ]; then + stored_uptime=$(cat "$dpp_start_time") + uptime_diff=$((current_uptime - stored_uptime)) + if [ "$uptime_diff" -lt 120 ]; then + logger -t button -p daemon.notice "DPP button already pressed. Please wait for 2 minutes after the initial press." + return + fi +fi + maybe_press_dpp_button diff --git a/netifd-morse/lib/netifd/morse/wpa_s1g_dpp_action.sh b/netifd-morse/lib/netifd/morse/wpa_s1g_dpp_action.sh index b6597d0..ec21acf 100755 --- a/netifd-morse/lib/netifd/morse/wpa_s1g_dpp_action.sh +++ b/netifd-morse/lib/netifd/morse/wpa_s1g_dpp_action.sh @@ -6,6 +6,8 @@ . /lib/netifd/netifd-wireless.sh . /etc/diag.sh +dpp_start_time=/tmp/dpp_start_time + #returns 0 if config is complete is_config_complete() { @@ -100,6 +102,8 @@ case "$1" in ;; finished) finished + # Remove the DPP start timestamp file upon timeout or successful DPP completion. + rm $dpp_start_time ;; started) started diff --git a/utils/wpa_event_listener/src/wpa_event_listener.c b/utils/wpa_event_listener/src/wpa_event_listener.c index c09337e..7eb9a52 100644 --- a/utils/wpa_event_listener/src/wpa_event_listener.c +++ b/utils/wpa_event_listener/src/wpa_event_listener.c @@ -219,7 +219,8 @@ static void message_process(char *const message) { apply_cached_confs(); clear_cached_confs(); } else if (strstr(value, "failed")) { - led_failed(); + // We don't want to indicate DPP failed scenario and allow DPP to timeout + printf("Avoid doing anything on DPP PB failure\n"); } break; case TYPE_PB_STATUS: