How to read UDID, Major, Minor of beacon on android devices?

后端 未结 2 1534
一整个雨季
一整个雨季 2021-01-03 08:41

I am trying to develop a BLE application for Android.

Is the any way through which i can detect and read UDID, Major, Minor of beacon on android devices?

I h

2条回答
  •  甜味超标
    2021-01-03 09:22

    1. scanRecord should be parsed as a list of AD structures.
    2. iBeacon is a kind of AD structures.

    With nv-bluetooth, you can extract iBeacon like the following.

    public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord)
    {
        // Parse the payload of the advertising packet.
        List structures =
            ADPayloadParser.getInstance().parse(scanRecord);
    
        // For each AD structure contained in the advertising packet.
        for (ADStructure structure : structures)
        {
            if (structure instanceof IBeacon)
            {
                // iBeacon was found.
                IBeacon iBeacon = (IBeacon)structure;
    
                // Proximity UUID, major number, minor number and power.
                UUID uuid = iBeacon.getUUID();
                int major = iBeacon.getMajor();
                int minor = iBeacon.getMinor();
                int power = iBeacon.getPower();
    
                ........
    

    See "iBeacon as a kind of AD structures" for details.

提交回复
热议问题