Search code examples
androidbeaconeddystonegoogle-beacon-platform

Register Estimote Beacons (Eddystone) with Google's Proximity Beacon API


Registering beacons with the Proximity Beacon API seemed easy, but I can't receive any messages with the Nearby Messages API (registered beacon, added attachments, subscribed with the messages API).

I think my problem lies with registering the beacon. It says that you're supposed to use the namespaceID and the instanceID, but every app I use to retrieve the ids tell me I either have to put 0x in front of the namespaceID/instanceID, or put : in between them.

I've tried the following formats:

  • namespaceIDinstanceID
  • namespaceID:instanceID
  • 0xnamespaceIDinstanceID

I'm using Estimote beacons at the moment. How would I have to register Estimote beacons with Eddystone to the Proximity Beacon API?

I don't need the code, just the Eddystone UID format before it's converted to base64.


Solution

  • Express the Eddystone UID as a byte array that includes both the namespace and instance, so a total of 16 bytes. Like this:

    JSONObject json = new JSONObject();
    
    // For namespace 0x0102030405060708090a, instance 0x0b0c0d0e0f00
    byte[] myEddystoneUid = new byte[] {
            (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04,
            (byte)0x05, (byte)0x06, (byte)0x07, (byte)0x08,
            (byte)0x09, (byte)0x0a, (byte)0x0b, (byte)0x0c,
            (byte)0x0d, (byte)0x0e, (byte)0x0f, (byte)0x00
    };
    
    JSONObject advertisedId = new JSONObject()
            .put("type", "EDDYSTONE")
            .put("id", Base64.encodeToString(myEddystoneUid, Base64.NO_WRAP));
    json.put("advertisedId", advertisedId);
    json.put("status", "ACTIVE");