0

Now I receive a lot of transmitted BLE advertisement packet from BLE devices.

How can I know that is beacon or not?

I think I can check base on below information:

That mean I think I will check the BLE advertisement as below sample code:

do {
      uint8_t entryLen = info->data[n];
        uint8_t entryType = info->data[n + 1];
        if (entryType == 0xff) {
            int m = n + 2;
            if (((uint8_t)info->data[m] == 0x4c) && ((uint8_t)info->data[m + 1] == 0x00) &&
                    ((uint8_t)info->data[m + 2] == 0x02) && ((uint8_t)info->data[m + 3] == 0x15)) {
                printf("---------------iBeacon-------------------------\n");
            } else if (((uint8_t)info->data[m + 2] == 0xbe) && ((uint8_t)info->data[m + 3] == 0xac)) {
                printf("---------------AltBeacon-------------------------\n");
            }
        } else if (entryType == 0x16) {
            int m = n + 2;
            if (((uint8_t)info->data[m] == 0xaa) && ((uint8_t)info->data[m + 1] == 0xfe)) {
                printf("---------------Eddystone-------------------------\n");
                m += 2;
                switch ((uint8_t)info->data[m]) {
                case 0x00:
                    printf("---------------EddystoneBeaconUIDdata-------------------------\n");
                    break;
                case 0x20:
                    printf("---------------EddystoneBeaconTLM-------------------------\n");
                    break;
                default:
                    printf("Eddystone Type %s\n", (uint8_t)info->data[m]);
                    break;
                }
            }
        } else {
              printf("---------------Other BLE Device-------------------------\n");
    }
        n += (entryLen + 1);

} while (n < info->length);

If the device is not iBeacon, AltBeacon or Eddystone that means it is other BLE device (not beacon).

It is ok?

Community
  • 1
  • 1
Nam Vu
  • 5,669
  • 7
  • 58
  • 90
  • 1
    The logic is reasonable but it is unclear what framework you are using to get scan data, and whether the byte offsets from the beginning of the array will be correct. Does the code work for you? – davidgyoung Nov 10 '15 at 11:54
  • It's OK for me. But iBeacon, AltBeacon, Eddystone are all of beacon type in the market? – Nam Vu Nov 10 '15 at 11:59
  • 1
    I think it's a bit unclear what you're asking for. Your code seems to already be capable of distinguishing between iBeacon, AltBeacon, and Eddystone. Basically, they all have a slightly different packet structure, and the code you've shared checks for these differences. Have you written the code yourself, or found it someplace and seek to understand how it works? – heypiotr Nov 11 '15 at 10:35
  • @heypiotr: I understand this code. My question is Are there only iBeacon, AltBeacon, and Eddystone Beacon in the market? Did the market have other type of beacon, like myBeacon? – Nam Vu Nov 12 '15 at 10:45
  • 1
    These three are the most popular, but nothing prevents people from rolling out their own beacon protocols. Gimbal has a proprietary one, Estimote Stickers have their own one too, etc., etc. It's like asking if there are any other programming languages other than those listed on Wikipedia—everyone can create their own language, even if they end up being the only ones that use it. – heypiotr Nov 12 '15 at 15:02

0 Answers0