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 device name?

    Scheduled Pinned Locked Moved MicroPython
    7 Posts 5 Posters 2.6k Views 5 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.
    • D Offline
      DongYin
      last edited by

      adv = bt.get_adv() get a ble device
      but bt.resolve_adv_data(adv.data, bt.ADV_NAME_CMPL) always returns a 'None'

      1 Reply Last reply Reply Quote 0
      • D Offline
        duffo64
        last edited by

        Hi @DongYin,

        What happens if you try to use ADV_NAME_SHORT instead of ADV_NAME_CMPL ?

        /Claudio

        1 Reply Last reply Reply Quote 1
        • D Offline
          DongYin
          last edited by

          @duffo64 said in BLE device name?:

          Hi @DongYin,

          What happens if you try to use ADV_NAME_SHORT instead of ADV_NAME_CMPL ?

          ADV_NAME_SHORT returns 'None' too.
          if i use ADV_MANUFACTURER_DATA returns " b'L\x00\x10\x02\n\x00' "
          others Address type all return 'None'

          1 Reply Last reply Reply Quote 0
          • R Offline
            Ralph
            last edited by

            @DongYin I'm not the bluetooth expert, but I think not all devices return their name. I also get None for most devices I find in our office building, but when I test it with this BLE Peripheral simulator app, I do get the name. Maybe @daniel can confirm.

            D 1 Reply Last reply Reply Quote 1
            • D Offline
              daniel @Ralph
              last edited by

              @DongYin BLE advertisements can only carry a certain amount of data (up to 31 bytes) and the device advertising chooses what to send. Many devices do not advertise the name.

              D 1 Reply Last reply Reply Quote 2
              • D Offline
                DongYin @daniel
                last edited by

                @daniel @Ralph Thank you for your explain,another questin ,when i set my LoPy ble device to scanning state,my iPhone can't search it too.

                from network import Bluetooth
                bluetooth = Bluetooth()
                bluetooth.start_scan(-1)

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

                  This is what I add into my lopy so they get a name:

                  bluetooth.set_advertisement(name="lopy", manufacturer_data="lopy_v1")

                  and when I look for the lopy I do this:

                  from network import Bluetooth
                  #import time - Dont need this part for this
                  bt = Bluetooth()
                  bt.start_scan(-1)

                  while True:
                  adv = bt.get_adv()
                  if adv and bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL) == 'lopy':
                  try:
                  conn = bt.connect(adv.mac)

                  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