Accessing Minor & Major from iBeacon scan



  • 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))
    


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



  • @Meriç-SARIIŞIK

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



  • This post is deleted!


  • 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


Log in to reply
 

Pycom on Twitter