Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

Enable/Disable WIFI with rfkill



  • @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 write sudo 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 and sed 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 variableWLANSTAT is setted with values right herre. The script checks just how many on 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.



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.