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

    Accessing Minor & Major from iBeacon scan

    Scheduled Pinned Locked Moved Discussion
    5 Posts 2 Posters 64 Views 3 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
      Scott Elliott
      last edited by

      Using ADV_MANUFACTUER_DATA I can cleary see the UUID of the iBeacon I am scanning for. However I cannot view the Major, although I believe I can see the Minor. Obviously to gain the full use of Ibeacon I need to see the minor and major identifiers.

      This is the output of the below code -> 4c0002152f234454cf6d4a0fadf2f4911ba9ffa600610003b4

      The uuid is 2f234454-cf6d-4a0f-adf2-f4911ba9ffa6 and you can clearly see that in the payload. The Minor is 3 and the major is 977. What am I missing here??

      d_in=bluetooth.resolve_adv_data(adv.data, Bluetooth.ADV_MANUFACTURER_DATA)
           if d_in:
                 print(ubinascii.hexlify(d_in))
      
      1 Reply Last reply Reply Quote 0
      • M Offline
        Meriç SARIIŞIK
        last edited by

        Hi Scott,

        When you divide the manufacturer_data into fields, you will see the other data. I prepared some lines as follows.

                d_in = bt.resolve_adv_data(adv.data, Bluetooth.ADV_MANUFACTURER_DATA)
                manuf_data = ubinascii.hexlify(d_in[0:4])
                if manuf_data == b'4c000215':
                    uuid = ubinascii.hexlify(d_in[4:20])
                    major = ubinascii.hexlify(d_in[20:22])
                    minor = ubinascii.hexlify(d_in[22:24])
                    tx_power = ubinascii.hexlify(d_in[24:25])
                    tx_power_real = twoscmp(int(tx_power, 16))
                    major_int = int(major, 16)
                    minor_int = int(minor,16)
                    print(read_adv,manuf,manuf_data, uuid, major, minor, tx_power_real, major_int)
        

        Can you try this code?
        Also, you can use this function for 2's complement.

        def twoscmp(value):
            if value > 128:
                value = value - 256
            return value
        

        Cheers,
        Meric

        S 1 Reply Last reply Reply Quote 2
        • S Offline
          Scott Elliott
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • S Offline
            Scott Elliott @Meriç SARIIŞIK
            last edited by

            @Meriç-SARIIŞIK

            Many thanks, implementing that now, will get back to you

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

              Just an update, this project got parked for a while, but have tried it this morning and your code did work. Appreciate the assistance!

              1 Reply Last reply Reply Quote 2

              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