RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Enable/Disable WIFI with rfkill

    Scheduled Pinned Locked Moved Projects and Themes
    wifidisable wificyperghostraspberryxu4
    31 Posts 8 Posters 12.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      common763
      last edited by

      Thanks. One more stupid question. Will running this affect my wi-fi connect to the PC when I transfer files and such?

      mituM 1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator @common763
        last edited by

        @common763 Of course, this will stop the Wifi radio so the network connection will not be possible via Wifi. You can toggle it though from the menu (on/off) whenever you need (or not) the Wifi connection.

        S 1 Reply Last reply Reply Quote 0
        • C
          common763
          last edited by

          ok. thanks for the help. Will give this a shot to see if it fixes my issues.

          1 Reply Last reply Reply Quote 0
          • C
            common763
            last edited by

            I just ran this. The Wifi Switch is at the bottom of the RetroPie Menu. When I select it does the same thing that a rom does without the proper bio...just goes back to the screen. ANy suggestions to what I am doing wrong?

            C 1 Reply Last reply Reply Quote 0
            • C
              common763 @common763
              last edited by

              @common763 All set. I replaced wget http://raw.githubusercontent.com/crcerror/XU4-ORA-scripts/master/wifi_toggle_dialog.sh -O "/home/pi/RetroPie/retropiemenu/Wifi Switch.sh" with wget http://raw.githubusercontent.com/crcerror/RetroPie-Shares/master/rfkill_wifi_dialog.sh -O "/home/pi/RetroPie/retropiemenu/Wifi Switch.sh"

              1 Reply Last reply Reply Quote 0
              • cyperghostC
                cyperghost @mitu
                last edited by cyperghost

                @common763 Glad you found out ;)

                1 Reply Last reply Reply Quote 0
                • cyperghostC
                  cyperghost @mitu
                  last edited by cyperghost

                  @mitu said in Enable/Disable WIFI with rfkill:

                  @common763 Sure - in this case you need to download the script to /home/pi/RetroPie/retropiemenu/Wifi Switch.sh

                  wget http://raw.githubusercontent.com/crcerror/XU4-ORA-scripts/master/wifi_toggle_dialog.sh -O "/home/pi/RetroPie/retropiemenu/Wifi Switch.sh"
                  

                  Excuse me Sir. The XU4-ORA script does NOT work for Raspberry and vice versa.

                  • Raspberry uses rfkill for radio actions
                  • ORA uses nmcli

                  The XU4 is a realy nice device it's a full grown debian/ubuntu platform ;)

                  1 Reply Last reply Reply Quote 0
                  • S
                    Shaddonai @mitu
                    last edited by

                    @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

                    mituM cyperghostC 2 Replies Last reply Reply Quote 0
                    • mituM
                      mitu Global Moderator @Shaddonai
                      last edited by

                      @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.

                      S 1 Reply Last reply Reply Quote 0
                      • cyperghostC
                        cyperghost @Shaddonai
                        last edited by cyperghost

                        @Shaddonai There are more effective methods available to block onboard wifi.
                        Add dtoverlay=pi3-disable-wifi to boot/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 ;)

                        S 1 Reply Last reply Reply Quote 0
                        • S
                          Shaddonai @mitu
                          last edited by

                          @mitu Thanks!

                          1 Reply Last reply Reply Quote 0
                          • S
                            Shaddonai @cyperghost
                            last edited by

                            @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.

                            cyperghostC 1 Reply Last reply Reply Quote 0
                            • cyperghostC
                              cyperghost @Shaddonai
                              last edited by

                              @Shaddonai here you are - disable Bluetooth

                              S 1 Reply Last reply Reply Quote 0
                              • S
                                Shaddonai @cyperghost
                                last edited by

                                @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.

                                cyperghostC 1 Reply Last reply Reply Quote 0
                                • cyperghostC
                                  cyperghost @Shaddonai
                                  last edited by

                                  @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?

                                  S 1 Reply Last reply Reply Quote 0
                                  • S
                                    Shaddonai @cyperghost
                                    last edited by

                                    @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.

                                    cyperghostC 1 Reply Last reply Reply Quote 0
                                    • cyperghostC
                                      cyperghost @Shaddonai
                                      last edited by cyperghost

                                      @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
                                      
                                      S 1 Reply Last reply Reply Quote 0
                                      • S
                                        Shaddonai
                                        last edited by

                                        Thanks man, you are awesome!

                                        1 Reply Last reply Reply Quote 0
                                        • S
                                          Shaddonai @cyperghost
                                          last edited by

                                          @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?

                                          cyperghostC 1 Reply Last reply Reply Quote 0
                                          • cyperghostC
                                            cyperghost @Shaddonai
                                            last edited by cyperghost

                                            @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.

                                            S 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            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.