1
votes

I'm fooling around with an Eddystone beacon, and have hit a wall when trying to register it.

The supplier of the beacon that I purchased, provides an app that allows you to read the following data from the beacon:

Eddystone-UID:

  • Namespace: 2F234454F4911BA9FFA6
  • Instance ID: 1
  • Power measured at 0 meters: -20

iBeacon/AltBeacon:

  • UUID: 41f037b6-f49d-4379-8350-e209ea4eadd1
  • Major: 0
  • Minor: 1
  • Power measured at 1 meter: -61

Given this information, what should I use to create my AdvertisedId when registering the beacon using Eddystone?

Thanks!

3

3 Answers

2
votes

Google has a sample Android app that will let you register beacons with their backend. You can see the code that calls registerBeacon here.

The actual registration process posts JSON to Google’s servers, and the JSON generation comes from the com.google.sample.beaconservice.Beacon class in this project here.

If you look at that line, you will see that it converts the identifier from a byte array to base 64 with:

JSONObject advertisedId = new JSONObject()
    .put("type", type)
    .put("id", Utils.base64Encode(id));

So for an Eddystone UID with a 10 byte namespace of 0x010203040506070809 and a 6 byte instance of 0x0a0b0c0d0e0f, you can base 64 encode the identifiers like this:

byte[] eddystoneBeaconId = new byte[] {(byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09, (byte) 0x01a (byte) 0x0b, (byte) 0x0c, (byte) 0x0d, (byte) 0x0e, (byte) 0x0f };
String base64EncodedEddystoneBeaconId = android.util.Base64.encodeToString(id, android.util.Base64.DEFAULT);
0
votes

The namespace and instance id are what you register with Google. But the Namespace identifier you have shown is not valid. It must be a 10 byte (20 character) hex number, and you are showing a 19 character identifier with a "V" in it, which is an illegal character for a hex number. Is this a typo?

0
votes

The syntax is eddystone namespace id+instanceid. This is how to generate the advertised id:

encodeBase64(HexToBinary(eddystone namespace id+instanceid))