WPS button in LUCI web-interface on X86?


we're running OpenWRT as a KVM-guest. I've removed wpad-mini and installed wpad and hostapd-uitls. LUCI shows Enable WPS pushbutton, requires WPA(2)-PSK. Naturally x86/KVM hosts do not have a physical WPS-button.

Is there any way to have a WPS-button in LUCI?

Thanx for any hint! :smiley:


1 Like

Can you explain more about the button you wish to program, and how it's attached to the host?

Also, per the Community Guidelines, please refrain from signing your posts.

There is no physical button on X86/KVM hosts.
That's why I'm asking about a HTML-button in the LUCI web-interface for the WPS Push-Button function.

In theory it could be made possible using a USB to gpio Adapter like a Adafruit Trinket


Then using GPIO pin to read the state of the button and mapping it to the WPS function under OpenWRT


I was referring to something like @markbirss posted.

But, I'll move this thread to the For Developers section for you. There should be straightforward commands; but I don't personally know how to program them into the GUI.


i flashed a mr44 cisco meraki and i have to say that a wps activation button would be usefull in Luci because i dont have WPS physical button neither ...

is there a way to simulate it via a CLI command ?

1 Like

to get you guys started....

  1. install luci-app-commands

  2. go to system > commands [tab] configure

  3. Click add

  4. Enter.... DESC:wpstrig COMMAND:/bin/wpstrig.sh [save-and-apply]

paste this into say... /bin/wpstrig.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_load "$creds"
		json_select wps_credentials || continue
		json_get_vars ifname ssid key encryption
		local ifcname="$ifname"
		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 ..
			json_select ..
			json_select ..

#if [ "$ACTION" = "pressed" -a "$BUTTON" = "wps" ]; then
	ubusobjs="$( ubus -S list hostapd.* )"

	for ubusobj in $ubusobjs; do
		ubus -S call $ubusobj wps_start && wps_done=1
	[ $wps_done = 0 ] || return 0
	ubusobjs="$( ubus -S list wpa_supplicant.* )"
	for ubusobj in $ubusobjs; do
		ifname="$(echo $ubusobj | cut -d'.' -f2 )"
		#if [ -e "/var/run/wpa_supplicant-${ifname}.conf.is_multiap" ]; then
		#	ubus -S call $ubusobj wps_start '{ "multi_ap": true }' && wps_done=1
			ubus -S call $ubusobj wps_start && wps_done=1
	[ $wps_done = 0 ] || wps_catch_credentials &
return 0
  1. Make it executable
chmod +x /bin/wpstrig.sh
  1. Navigate to system > custom commands [ click run ]

See how you go with that.... never use/used wps myself so no idea what you do on a device level.... but you should see something like this in logread;

Sat Jun 22 01:52:55 2019 daemon.notice hostapd: wlan0: WPS-PBC-ACTIVE
Sat Jun 22 01:54:55 2019 daemon.notice hostapd: wlan0: WPS-TIMEOUT

thanks wulfy23

it's working like a charm ,

i dont know why its working only on my wlan2 interface but it's doing the job and i was able to connect my surface tab using wps !!

now i will be able to connect my A/C device thanks to you

1 Like

Excellent solution - works perfectly.

1 Like

This post is now obsolete because there is already a WPS button in LuCI. It can be tested using snapshots.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.