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

    BLE not getting connected

    Scheduled Pinned Locked Moved LoPy
    3 Posts 2 Posters 31 Views 2 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.
    • S Offline
      subham Joshi
      last edited by Gijs

      Hello Folks,
      I have been trying to implement the BLE communication on lopy4 and my laptop. I am referring to the code attached at the bottom for reference and the lopy4 release version is '1.20.2.r3' . The code always gets stuck at bluetooth.connect(adv.mac) for which I have no reason why. Some post suggest that it might be a firmware issue but the latest firmware for lopy4 just stops it from getting connected to comport and then I have to revert back to the older firmware revision. Any guidance or help will be much appreciated.

      Regards
      Subham

      from network import Bluetooth
      import ubinascii
      bluetooth = Bluetooth()
      
      
      bluetooth.start_scan(-1)
      adv = None
      while True:
          adv = bluetooth.get_adv()
          if adv:
              try:
                  bluetooth.connect(adv.mac)
              except:
                  # start scanning again
                  bluetooth.start_scan(-1)
                  continue
              break
      print("Connected to device with addr = {}".format(ubinascii.hexlify(adv.mac)))
      
      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jcaron @subham Joshi
        last edited by

        @subham-Joshi Please edit your post, select your code and click on the </> code formatting button in the toolbar, so spacing is respected (which is vital in Python).

        1 Reply Last reply Reply Quote 0
        • S Offline
          subham Joshi
          last edited by

          Hello @jcaron ,
          Sorry for the inconvenience caused. As a a new user it is not letting me edit it and then submit it again. I have tried multiple times now. I will keep on trying until it lets me do that but in the meantime do you have any idea as in what might stopping me from getting the BLE device connected.
          Regards
          Subham

          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