AP + Client switch with button

Hi. I need to configure "AP only", "AP+Client", "AP+USB modem internet". I have MR3020 with switch button.

Now I can only switch on/off wifi with BTN_1 and BTN_0.

Please, help to make script, how to turn on/off AP, client and usb modem connection.

As we have established in your other thread, you are using OpenWrt 15.05 (Chaos Calmer) which is totally obsolete. As I said in that thread, a lot has changed since 15.05 and the methods that would be employed in the current versions probably won't work with such an old version. And what worked in that version likely wouldn't work in a current version.

You may find some kind person here who both remembers and is willing to help with this ancient version, but I wouldn't rely on that. You will probably be best served by using the forum search to find similar scripts and then modifying them to suit your needs... a lot of this will require experimentation and trial-and-error tests.

I found a solution to my question from the Internet and changed it for myself:

button:

#!/bin/sh

if [ $BUTTON == "BTN_0" ]; then
if [ $ACTION == "pressed" ]; then

(
for i in `seq 1 2500`; do true; done
if [ -f /tmp/var2 ]; then
#### INSERT YOUR CODE FOR LEFT POSITION HERE
cp /etc/config/wireless_MODEM /etc/config/wireless & wifi
####
else
#### INSERT YOUR CODE FOR RIGHT POSITION HERE
cp /etc/config/wireless_AP /etc/config/wireless & wifi
####
fi
) &
else
#### INSERT YOUR CODE FOR MIDDLE POSITION HERE
cp /etc/config/wireless_AP+CLIENT /etc/config/wireless & wifi
#### CODE END
if [ -f /tmp/var2 ]; then
rm /tmp/var2
fi
fi
else
if [ $ACTION == "released" ]; then
touch /tmp/var2
fi
fi

Save file to "/etc/hotplug.d/button/".

I have set up 4G-MODEM + AP, AP + Client, AP only.

wireless_AP:

config wifi-device 'radio0'
	option type 'mac80211'
	option hwmode '11g'
	option path 'platform/ar933x_wmac'
	option htmode 'HT20'
	option channel '11'
	option txpower '15'
	option country 'US'

config wifi-iface
	option device 'radio0'
	option mode 'ap'
	option ssid 'CLOUD'
	option network 'lan'
	option encryption 'psk2'
	option key 'PASSWORD'

wireless_AP+CLIENT:


config wifi-device 'radio0'
	option type 'mac80211'
	option hwmode '11g'
	option path 'platform/ar933x_wmac'
	option htmode 'HT20'

	option txpower '15'
	option country 'US'

config wifi-iface
	option network 'wwan'
	option ssid 'OnePlus 8T'
	option encryption 'psk2'
	option device 'radio0'
	option mode 'sta'
	option bssid '9E:60:9A:FB:AE:60'
	option key 'PASSWORD'

config wifi-iface
	option device 'radio0'
	option mode 'ap'
	option ssid 'CLOUD'
	option network 'lan'
	option encryption 'psk2'
	option key 'PASSWORD'


wireless_MODEM:

config wifi-device 'radio0'
	option type 'mac80211'
	option hwmode '11g'
	option path 'platform/ar933x_wmac'
	option htmode 'HT20'
	option channel '11'
	option txpower '15'
	option country 'US'

config wifi-iface
	option device 'radio0'
	option mode 'ap'
	option ssid 'CLOUD_4G'
	option network 'lan'
	option encryption 'psk2'
	option key 'PASSWORD'

Then move files to "/etc/config" folder.

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