How do I add WPS LED event for Archer A7 v5

Hey guys! I just started using OpenWrt (19.07.3 r11063-85e04e9f46) on my A7 router, and I'm wondering how I can get the WPS LED to turn on when I press the WPS button. I used this guide in order to get WPS working on it but I can't figure out how to get the LED to turn on.

Here's the information for the buttons and LEDs
WPS button script
WPS LED name: tp-link:green:wps
WPS LED config

Hi,
I'm in the same boat as you. I added the trigger right at the beginning, when the button is pressed but I cannot figure out how to make it stop.

#!/bin/sh

wps_catch_credentials() {
        local iface ifaces ifc ifname ssid encryption key radio radios
        local found=0

        . /usr/share/libubox/jshn.sh
        ubus -S -t 30 listen wps_credentials | while read creds; do
                json_init
                json_load "$creds"
                json_select wps_credentials || continue
                json_get_vars ifname ssid key encryption
                local ifcname="$ifname"
                json_init
                json_load "$(ubus -S call network.wireless status)"
                json_get_keys radios
                for radio in $radios; do
                        json_select $radio
                        json_select interfaces
                        json_get_keys ifaces
                        for ifc in $ifaces; do
                                json_select $ifc
                                json_get_vars ifname
                                [ "$ifname" = "$ifcname" ] && {
                                        ubus -S call uci set "{\"config\":\"wireless\", \"type\":\"wifi-iface\",                \
                                                                \"match\": { \"device\": \"$radio\", \"encryption\": \"wps\" }, \
                                                                \"values\": { \"encryption\": \"$encryption\",                  \
                                                                                \"ssid\": \"$ssid\",                            \
                                                                                \"key\": \"$key\" } }"
                                        ubus -S call uci commit '{"config": "wireless"}'
                                        ubus -S call uci apply
                                }
                                json_select ..
                        done
                        json_select ..
                        json_select ..
                done
        done
}

if [ "$ACTION" = "pressed" -a "$BUTTON" = "wps" ]; then
        wps_done=0
        ubusobjs="$( ubus -S list hostapd.* )"
        echo timer > /sys/devices/platform/leds/leds/d-link:blue:wps/trigger
        for ubusobj in $ubusobjs; do
                ubus -S call $ubusobj wps_start && wps_done=1
        done
        [ $wps_done = 0 ] || return 0
        wps_done=0
        ubusobjs="$( ubus -S list wpa_supplicant.* )"
        for ubusobj in $ubusobjs; do
                ifname="$(echo $ubusobj | cut -d'.' -f2 )"
                multi_ap=""
                if [ -e "/var/run/wpa_supplicant-${ifname}.conf.is_multiap" ]; then
                        ubus -S call $ubusobj wps_start '{ "multi_ap": true }' && wps_done=1
                else
                        ubus -S call $ubusobj wps_start && wps_done=1
                fi
        done
        echo none > /sys/devices/platform/leds/leds/d-link:blue:wps/trigger
        [ $wps_done = 0 ] || wps_catch_credentials &
fi

Thank you.

The problem is to detect when the WPS process finishes, in registrar and enrollee side. There are the best ways I have found to detect this:

Enrollee (STA)

Use ubus and listen, as wpa_supplicant inform this event, for example with the following commands:

ubus call wpa_supplicant.sta0 wps_start  # trigger the WPS in interface sta0
ubus -S -t 120 listen wps_credentials # listen for 120 seconds the result of the operation (the credentials)

If all is OK, you will receive something like this in JSON:

{ "wps_credentials": {"ifname":"sta0","encryption":"psk2","ssid":"TestSSID","key":"TestPassword"} }

You can also use for example wpa_cli but is not the best option and also demands to install that package.

Registrar (AP)

Unfortunatelly hostapd seems to not inform an event which can be "listened" in ubus. So, you need to call periodically for its state, for example with the command:

ubus -v call hostapd.wlan0 wps_status

You will receive something like that, in JSON:

{
        "pbc_status": "Disabled",
        "last_wps_result": "Success",
        "peer_address": "6a:ff:7b:3b:53:8e"
}

Again, you can use hostapd_cli also, but for sure is better with ubus.