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

    Lopy4 to Lopy4 with BLE get_adv() always none [Solved]

    Scheduled Pinned Locked Moved LoPy
    lopy4ble
    3 Posts 2 Posters 642 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.
    • A Offline
      Amarulp
      last edited by Amarulp

      Hello everyone!
      I was trying to connect two Lopy4 with BLE, but bluetooth.get_adv() is always returning none. Just in a few cases it and using the same code work but then stopped.

      import ubinascii
      from network import Bluetooth
      from time import sleep
      
      bt = Bluetooth()
      bt.init()
      
      bt.set_advertisement(name="lopy", manufacturer_data="lopy_v1")
      if bt.isscanning():
          bt.stop_scan()
      
      bt.start_scan(-1)
      while bt.isscanning():
          adv = bt.get_adv()
          if adv:
              print(adv)
      
      

      Both with the same code, and different names (I also try it with the same name)

      Thank you

      E 1 Reply Last reply Reply Quote 0
      • E Offline
        Eric73 @Amarulp
        last edited by

        @amarulp Hello, I think you cannot, at same time, advertise and scan for device with a lopy but you can test it in case, with some luck it can work.
        I suggest you to have on one lopy to advertise (btw you must add in your code bt.advertise(true) after your bt.set_advertisement according to documentation) and the other lopy do bluetooth scanning.

        A 1 Reply Last reply Reply Quote 1
        • A Offline
          Amarulp @Eric73
          last edited by

          @eric73
          Thank you so much!
          It worked! Also, it can scan and advertise at the same time.

          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