7

The Google's Proximity Beacon API documentation uses Eddystone as an example everywhere:

https://developers.google.com/beacons/proximity/register

However, documentation mentions two more types of beacons, AltBeacon and iBeacon.

If I understand correctly, something like this should be used (adapted from Google's example):

 {
  "advertisedId": {
   "type":"IBEACON",
   "id":"base 64 of what???"},
  "status":"ACTIVE",
  "latLng": {
     "latitude": 51.4935657,
     "longitude": -0.1465538
   }
}

However, what is the acceptable binary format for iBeacon's UUID,Major,Minor (which should be base64'd)?

Roman Susi
  • 4,135
  • 2
  • 32
  • 47
  • Good question. Have you tried concatenating the UUID/major/minor (with spaces, commas or underscores) and Base64 encoding that? – davidgyoung Jul 23 '15 at 12:43
  • According to docs, it should be binary (bytes), so spaces, etc, are out of question. No, I have not tried yet. This question is in hope someone knows. I will post the answer if/when I will find out. – Roman Susi Jul 23 '15 at 16:05

1 Answers1

9

The id of the advertisedId will be the 20 bytes of the iBeacon UUID + major + minor base64 encoded directly from the binary form. (i.e. don't print it out as hex or text first before base64 encoding. Just take the blob and base64 that).

Otherwise your request looks right!

MarcWan
  • 2,943
  • 3
  • 28
  • 41
  • Could you explain a bit more in detail? I'm testing this API in the OAuth playground, so I have to provide the request body in text. How do I get from having a UUID, major and minor to the bytes you mention? – Mathijs Aug 19 '15 at 14:10
  • Boy, that's going to be a bit tough via the playground — you'll have to get an iBeacon UUID, the major + minor, and then concat them all, convert them to binary and then base64 the results. Best to do that with a little PHP or Node script. – MarcWan Aug 19 '15 at 14:46
  • Ok I can try that. Thanks! So concat without spaces or separators? Like 9D07149D23D54B30BA5A5214346460AF111222 for major 111 and minor 222? How does Google know the major isn't 1112 and the minor 22? – Mathijs Aug 20 '15 at 07:33
  • 5
    Again, binary, so 20 bytes: first 16 of which are ibeacon uuid (the binary values) and last 4 of which are major/minor. Major and minor are defined by apple to be 16 bits each. Once you have a binary buffer, you base64 encode that. So, for your example, your UUID is (in hex) 9D07149D23D54B30BA5A5214346460AF and your major/minor are 0x6f and 0xde (111, and 222). concat them on you get: 9D07149D23D54B30BA5A5214346460AF006F00DE. Convert to binary, then base64, you'll get: 'nQcUnSPVSzC6WlIUNGRgrwBvAN4=' – MarcWan Aug 20 '15 at 12:40
  • @Mathijs basically when you register your beacon you specify the type of beacon you are registering. So the proximity api should know to pick up the major minor values out the beacon info! Hope this helps. – Mr.Noob Oct 27 '15 at 12:14