Navigation

    UBports Robot Logo

    UBports Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    SOLVED How to stop and restart Bluetooth service?

    Support
    4
    17
    152
    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.
    • Moem
      Moem last edited by Moem

      I have found that the most reliable way to reconnect my smartwatch in the morning is to power down the phone completely, then reboot it. It will then reconnect with no further intervention.
      Just switching bluetooth off and on does not do it; neither does a normal restart.

      So I think I want to completely stop and start bluez (and related services? Maybe?). Is there any way to make that easy? With a launcher of some kind?

      Any pointers would be welcome.

      AntiDroid 1 Reply Last reply Reply Quote 0
      • AntiDroid
        AntiDroid @Moem last edited by

        @moem You could try

        sudo service bluetooth restart
        

        Or maybe even this old trick to get bluetooth speakers to reconnect on Xenial. I do not know if it will work on UT.

        rfkill block bluetooth
        
        rfkill unblock bluetooth
        
        
        Moem 2 Replies Last reply Reply Quote 0
        • Moem
          Moem last edited by

          Sorry, and thank you, but I was hoping for a nice clicky-clicky thing or a way to make one... the UT terminal and me, we're not friends. Without an actual keyboard... well, let's not go there.

          I'm looking for something that is easier than a complete reboot. Otherwise I can just do the reboot.

          K 1 Reply Last reply Reply Quote 0
          • K
            kugiigi @Moem last edited by

            @moem I would assume toggling bluetooth off and on doesn't work. Some issues can be fixed by that.
            Also, using the terminal with OSK is quite decent on UT. Tap for Tab, swipe up and down for history and swipe 2 finger for scrolling. There are also shortcut keys at the bottom bar.

            Moem 1 Reply Last reply Reply Quote 0
            • Moem
              Moem @kugiigi last edited by Moem

              @kugiigi said in How to stop and restart Bluetooth service?:

              I would assume toggling bluetooth off and on doesn't work.

              Right. It doesn't, like I said.

              As for the terminal, I do not understand it and there are no instructions anywhere that I have seen. I'm happy that you consider it easy to use. I do not. I do not even understand what the shortcut keys do. A terminal solution is never going to be easier for me than a reboot. Please take my word for it.

              K 1 Reply Last reply Reply Quote 0
              • K
                kugiigi @Moem last edited by

                @moem Oh sorry, I missed that 😅
                To me, using the terminal would be a lot easier and faster than rebooting. You can create a bash script in your home directory with the commands needed. Then on the terminal you can simply type the first few characters of the bash script in the terminal tap the screen enter. I use this trick on the pinephone whenever wifi stops working.

                Moem 1 Reply Last reply Reply Quote 0
                • Moem
                  Moem @kugiigi last edited by

                  @kugiigi said in How to stop and restart Bluetooth service?:

                  You can create a bash script in your home directory with the commands needed.

                  See, now we are getting somewhere... 🙂
                  Might there be a way to create a launcher to call up that script?

                  K Keneda 2 Replies Last reply Reply Quote 0
                  • K
                    kugiigi @Moem last edited by

                    @moem I believe you can create a desktop file manually in ~/.local/share/applications

                    Moem 1 Reply Last reply Reply Quote 0
                    • Moem
                      Moem @kugiigi last edited by

                      @kugiigi Oooh. Good info, thank you! I will investigate.

                      1 Reply Last reply Reply Quote 0
                      • Keneda
                        Keneda @Moem last edited by Keneda

                        @moem said in How to stop and restart Bluetooth service?:

                        Might there be a way to create a launcher to call up that script?

                        If i remember correctly, Launcher Modular allows ro create shortcuts of that kind (command line).

                        Moem 1 Reply Last reply Reply Quote 0
                        • Moem
                          Moem @Keneda last edited by

                          @keneda That would be a great solution, thank you very much! Going to look into that...

                          AntiDroid 1 Reply Last reply Reply Quote 0
                          • AntiDroid
                            AntiDroid @Moem last edited by AntiDroid

                            @moem if you follow the clickable instructions for setting up an app development enviroment the first thing you do after installing all the required dependencies and programs is you generate an app template. That template is a program with a single button in the middle that when you click it, it prints "hello world" to the command line. I would think it would be easy to change that to one of the commands above (after manually testing via the command line at least once). It would be a great way to get into making yout own programs too.

                            Moem 1 Reply Last reply Reply Quote 0
                            • Moem
                              Moem @AntiDroid last edited by

                              @antidroid That's not something I'm interested in, but thanks!

                              1 Reply Last reply Reply Quote 0
                              • Moem
                                Moem @AntiDroid last edited by

                                This post is deleted!
                                1 Reply Last reply Reply Quote 0
                                • Moem
                                  Moem @AntiDroid last edited by

                                  @antidroid said in How to stop and restart Bluetooth service?:

                                  @moem You could try

                                  sudo service bluetooth restart
                                  

                                  Or maybe even this old trick to get bluetooth speakers to reconnect on Xenial. I do not know if it will work on UT.

                                  rfkill block bluetooth
                                  
                                  rfkill unblock bluetooth
                                  
                                  

                                  I tried both of these options. The first one was not a succes: BT stopped and never started again (which a reboot solved). The second one worked very well!

                                  So in Launcher Modular, which I'm using anyway, I made a custom icon as suggested by @Keneda. This is a winning combination.
                                  The command I used is

                                  rfkill block bluetooth && rfkill unblock bluetooth
                                  

                                  and this morning, when I woke up, the Pebble was unlinked (it has an option to unlink when it does not sense any motion for half an hour, to save battery power) so I tapped the icon.
                                  The notifier for BT flashed very briefly and immediately went active, and the Pebble buzzed to indicate connection.
                                  In other words, this is a complete success and I'm now going to mark it solved and celebrate with a mug of my best tea. 🎉

                                  Thank you, folks, for some great information!

                                  Keneda 1 Reply Last reply Reply Quote 1
                                  • Keneda
                                    Keneda @Moem last edited by

                                    @moem
                                    You're welcome. I hope Launcher Modular to grow as it's a good app, but some bugs on MX4 unfortunatly.

                                    Moem 1 Reply Last reply Reply Quote 0
                                    • Moem
                                      Moem @Keneda last edited by

                                      @keneda said in How to stop and restart Bluetooth service?:

                                      some bugs on MX4 unfortunatly

                                      Sorry to hear that! On OpO, it's pretty much flawless. It really helped me when switching from Android... I felt a lot more at home (sorry, devs). And I like having an analog clock on the home screen.

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