Enable/Disable WIFI with rfkill
-
@mitu Just a quetion. This will disable the onboard wifi, but if I block the wifi with this script and then plug a wifi dongle (On a rpi3), I will be using the dongle wifi? Thanks
-
@Shaddonai I'm not sure,
rfkill
can selectively disable/enable Wifi individually, I'm not sure the script can do that (i.e. choose which Wifi connection to stop).
But, as you said, if you use it before you're adding your Wifi dongle, then it should be fine. -
@Shaddonai There are more effective methods available to block onboard wifi.
Adddtoverlay=pi3-disable-wifi
toboot/config.txt
and then it's device drivers are not loaded during boot.rfkill
behaves like a software toggle and I assume if you plug in annother WiFi device then the whole stack will be resetted. Means both connections are active but not if you use the overlay above.@mitu
Yes rfkill can disable/enable devices by it's device number. But I do not know if the device number keeps unique everytime ;) -
@mitu Thanks!
-
@cyperghost Actually I am searching for an sript that let me disable the onboard bluetooth by modifying the config.txt, but I did not find one so I am trying with rfkill. If you know an script like that, please let me know.
-
@Shaddonai here you are - disable Bluetooth
-
@cyperghost I am already using your script for wifi, and I tried to modify it to work with bluetooth, but I could not make it work. You know how to write cripts, so you know wich instruction to sue to write on the config.txt with a script? For example, when I activate it via RetroPie menu, it would go and edit config.txt.
-
@Shaddonai This makes simply no sense. If I write to config.txt then only a reboot does enable/disable the internal WiFi or BT device of the Raspberry. So it makes more sense to disable them permanently and use external devices.
To make the script work for BT devices instead of using
sudo rfkill block wifi
just writesudo rfkill block bluetooth
. It's just a small change in two lines and then it will work for BT but I do not know why you want this? -
@cyperghost I am working on a portable Raspberry Pi, that will work as a Retropie and sort of portable computer with a portable keyboard. The thing is, I thought I could play with my friends , and most of them have PS4 controlers. I know that I can wire them to the RPI with an USB cable, but due to the design I made, It is really uncomfortable, so i thought to make them all use bluetooth. After a little research, I found out that onboard bluetooth is not really good handling many cotrollers, so I went to Amazon and search for a Bluetooth dongle. Then I saw several of them were "Low Energy". That intrigated me, so I searched the consumption of these dongles, and it was pretty heavy , reducing a good amount of battery life. I only planned to use the dongle with friend, in the meantime I would only use one bluetooth controller, so the onboard was OK, and less power consumpting. I woud like to write an script to only disable theonboard bluetooth when I need, and then plug the dongle, so I can maximize the battery life.
-
@Shaddonai AFAIK if you disable the wifi with this script then you can connect several PS-controllers with BT and all is fine.
If you want to do some inline editing then please read about
grep
andsed
commands. This tools can automate write to your/boot/config.txt
but I don't wont to do this for you. For some reasons I can easily break your device.An example how this tools work are here. The
^
is relevant it says search string from the beginning.if grep -q "^enable_uart=1" "/boot/config.txt"; then echo "UART is already enabled. Disabeling now!" sed -i -e "s|^enable_uart=1|#enable_uart=1|" "/boot/config.txt" fi
-
Thanks man, you are awesome!
-
@cyperghost said in Enable/Disable WIFI with rfkill:
sed
Only one more question. In your script you testes the WIFI with" if [ $WLANSTAT -lt 2 ]", how can I test Bluetooth instead?
-
@Shaddonai The variable
WLANSTAT
is setted with values right herre. The script checks just how manyon
are visible. So you should change L6 wifi with bluetooth. But I'm really asking me of the sense. If you disable the Bluetooth stack you do not have further inputs and in the worst case you need a keyboard or a SSH connection. So be aware what you are doing here. -
@cyperghost Thanks for the advice. It is not a really necessary script, but i would love to do it, because this build took me a lot of time and I want to perfect it to the most.
-
Thank you so much for this! I was struggling with two Shanwan ps3 controllers and disabling wifi with your script totally solved it.
-
Hi,
I'm was having trouble with my ps3 controllers and discovered that removing my wifi connection eliminated it. I wanted to install this switch to make this process even easier. However, after installing it it says "Your wifi adapter seems to be blocked or is not available", even though I'm currently connected to wifi and am able to access my retropie over the network. I expected to see the block option, but it shows enable instead. Selecting enable says "sudo: rfkill: command not found" and spits me back to the retropie menu. Wondering if there's something I'm missing...Thanks!
-
Hello all,
sorry to be reviving an old post, but I find myself in the same situation 3 years later and I cant seem to find a solution that keeps up with the changes through time.
I have a Raspberry pi B+ and are running Retropie v.4.7.
I have been able to use a DS3 controller since I setup my raspberry pi with a bluetooth dongle, which I had paired on my laptop initially with the SCPtoolkit. So that was plug and play at the time and didnt even realise this was a complicated matter.
A few weeks ago I decided to get another controller and dongle to do the same for player 2, which obviously did not work.I have :
tried to pair them separately and together,
tried the ps3 controller drivers with both original and clone options
tried the sixaxis option aswell.
My results where mixed, but the botom line is that the best I could get was to have one controller through the bluetooth dongle and one on a USB.*Should also mention that they both work on my laptop with a single bluetooth dongle, setup with SCPtoolkit.
I can see that you have suggested 1 option that I would like to try, but have failed to do so on my own, either because of my inexperience or because the instructions are outdated.I need to check if by disabling the wifi it allows both of them to connect and if it does to setup your script in the menu so that I can toggle it.
When I press f4 and type wget http://raw.githubusercontent.com/crcerror/RetroPie-Shares/master/rfkill_wifi_dialog.sh -O "/home/pi/RetroPie/retropiemenu/Wifi Switch.sh"
It says the directory or file does not exist. Now I can see the actual link of the .sh file on github is different that what is suggested, but I did try to replace it with no success.
I also tried to change the location file to "/home/pi/RetroPie/configs/Wifi Switch.sh" hoping that by placing it there might still work but it doesnt.
Lastly I feel that there must be something that I am missing sicne there are no other solutions out there available but also not many others discussing it, which makes me wonder has this been solved in a simple matter and I am just blind?!Thank you for your time and sorry for the long post, I hope you can help me.
After giving up with every option I decided to try and type that all over again, seems it was a mistype...:S
Anyway I can confirm this works for 2 ps ds3 controllers!!! Now I am off to show off my skills on CTR to my partner!!!Thank you for your support!!!
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.