Trying to register Estimote iBeacon with Proximity Beacon API

417 Views Asked by At

I have got an Estimote Beacon which is in iBeacon mode. Previously, I tried registering Edddystone and I was successful in doing so. Now that , I'm trying to register it with Google Proximity Beacon API. But it's firing an error message as Invalid AdvertisedId id bytes length.

"error": {
    "code": 400,
    "message": "Invalid AdvertisedId id bytes length",
    "status": "INVALID_ARGUMENT"
    }

I wish to know how to parse the scan record so that the length of AdvertisedId would be correct. If there are any other changes that I should do, let me know.

2

There are 2 best solutions below

0
On

Are you passing the AdvertisedId in the form of a Base64-encoded string of raw bytes? Note this part in the Proximity API documentation of the AdvertisedId:

The base64 encoding should be of the binary byte-stream and not any textual (such as hex) representation thereof.

Here's how to get such string using an interactive Ruby interpreter:

irb(main):039:0> uuid = 'B9407F30-F5F8-466E-AFF9-25556B57FE6D'
=> "B9407F30-F5F8-466E-AFF9-25556B57FE6D"
irb(main):040:0> major = 123
=> 123
irb(main):041:0> minor = 456
=> 456
irb(main):047:0> raw_bytes = [uuid.gsub('-', ''), major, minor].pack('H*SS')
=> "\xB9@\x7F0\xF5\xF8Fn\xAF\xF9%UkW\xFEm{\x00\xC8\x01"
irb(main):048:0> require 'base64'
=> true
irb(main):049:0> Base64.encode64(raw_bytes).strip
=> "uUB/MPX4Rm6v+SVVa1f+bXsAyAE="

This last string is what you need to pass.

0
On

Check whether your id is valid.The id of the advertisedId will be the 20 bytes of the iBeacon UUID + major + minor base64 encoded directly from the binary form.