0

I am using Eddystone-URL with Android Beacon Library. I put the compressed URL in the dataFileds of the Beacon but when I receive the signal, the dataFields are empty Why could this be happenning? attach here the transmiter's code:

try {
        byte[] buf = UrlBeaconUrlCompressor.compress("http://www.google.com");
        beacon = new Beacon.Builder()
                .setId1("0000FEAA-0001-1000-8000-00805F9B34FB")
                .setManufacturer(0xFEAA)
                .setTxPower(-59)
                .setDataFields(bytesToListOfLongs(buf))
                .build();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
    BeaconParser beaconParser = new BeaconParser()
            .setBeaconLayout(BeaconParser.EDDYSTONE_URL_LAYOUT);
    beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser);

I decoded the DataFields before starting to transmit and I see well the URL but I am not receiving anything in this fields in the other smartphone.

1 Answers1

0

You simply cannot use data fields for this case. Data fields are designed to hold only a few bits of information.

Instead, place that data you want to transfer inside the ID1 field itself. In the case of iBeacon and AltBeacon format, that Id is 16 bytes long. You will need to convert your days bytes to always be exactly 16 bytes and format them as a uuid so the Identifier parse method can convert them to an identifier.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Ok, but what's the Eddystone-URL format providing me then? – Alejandro Pérez Jul 16 '17 at 18:17
  • If you are encoding data in a beacon transmission, then you are really going outside the intended use of bluetooth beacons, which are designed to transmit a simple unique identifier. You are welcome to do this, but because you are going outside the intended use, it really doesn't matter which format you use. If you use Eddystone-URL, you encode the data inside the URL. If you use Eddystone-UID, you encode it inside the Namespace and Instance identifiers. If you use iBeacon or AltBeacon, you encode it inside the UUID, major and minor identifiers. – davidgyoung Jul 16 '17 at 23:23