Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Bluetooth.connect( adv.mac ) hangs

    Scheduled Pinned Locked Moved Issues & Bugs
    lopybluetoothhangs
    9 Posts 4 Posters 2.3k Views 4 Watching
    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.
    • T Offline
      thrag
      last edited by

      What am I doing wrong here? This code hangs when it comes to "bt.connect( adv.mac )"

      Does anyone have working code to read services data values?

      Thanks, in advance?

      from network import Bluetooth
      import time
      
      bt = Bluetooth()
      bt.init()
      
      while( True ):
          if( not bt.isscanning() ):
              bt.start_scan(-1)
      
          print("Scan")
          adv = bt.get_adv()
          if( adv ):
              bt.stop_scan()
              print( adv.mac )
              try:
                  conn = bt.connect( adv.mac )
                  if( conn ):
                      if( conn.isconnected()):
                          print(len(conn.services))
                          conn.disconnect()
                      else:
                          print("Not Connected")
                  else:
                      print("Conn not available")
              except Exception as e:
                  print( e.message )
      
          time.sleep( 1 )
      
      1 Reply Last reply Reply Quote 0
      • J Offline
        jmarcelino
        last edited by

        Are you using the latest firmware?

        os.uname() should tell you

        1 Reply Last reply Reply Quote 0
        • T Offline
          thrag
          last edited by

          Thanks for the reply.

          Yes, the very latest. '1.7.2.b1'

          Garth

          1 Reply Last reply Reply Quote 0
          • T Offline
            thrag
            last edited by

            Actually, I have to correct myself. This is actually working now.. at least better than before. It does not seem to find all advertisements that are available but that could be an issue with the beacon.

            Not sure why it works tonight when it definitely did not yesterday. But anyway, Thanks. It work.

            1 Reply Last reply Reply Quote 0
            • B Offline
              bnjroos
              last edited by

              I have the same issue here, it was working but not anymore and it hangs everytime i try to connect with my LoPy. Then I have to power cycle the board.

              Did you do anything ?

              B T 2 Replies Last reply Reply Quote 0
              • B Offline
                bucknall @bnjroos
                last edited by

                @bnjroos Are you up to date, regarding the firmware?

                Developer Evangelist - Pycom

                B 1 Reply Last reply Reply Quote 0
                • B Offline
                  bnjroos @bucknall
                  last edited by bnjroos

                  @bucknall I think so:

                   os.uname()                                                                                                          
                  (sysname='LoPy', nodename='LoPy', release='1.7.1.b2', version='v1.8.6-642-g84447452 on 2017-06-03', machine='LoPy with E
                  SP32', lorawan='1.0.0')

                  I'm trying to connect to this device for the first time: http://www.transducersdirect.com/product-category/pressure-transducers/wireless-pressure-transducers/

                  However I was connected with the LoPy to my phone using the 'nrf connect' android app with success 2 days ago and it is not working anymore either.

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    thrag @bnjroos
                    last edited by

                    @bnjroos

                    Honestly, I don;t know what fixed. I had already upgrade the firmware and verified the version number and the code I had would not work.

                    The next day. I re-flashed the firmware again to be sure. And tried some other code that essentially did the same thing and it works.

                    I really don;t know what was the magic solution but I am able to get Bt.Connect() to work now. Although actually reading values is not reliable for me. But, that could be the Beacon or the LOPY and I have not figured out which yet.

                    Good Luck with yours.

                    thrag

                    1 Reply Last reply Reply Quote 0
                    • B Offline
                      bucknall
                      last edited by

                      Hmm ok I've flagged this internally and will investigate! Thanks for your patience!

                      Developer Evangelist - Pycom

                      1 Reply Last reply Reply Quote 0

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      • 1 / 1
                      • First post
                        Last post

                      Pycom on Twitter

                      Pycom