How to transmit an Eddystone beacon with a specidic UID and namespace using the altbeacon library in android?

74 Views Asked by At

Hey guys I want to transmit an Eddystone Beacon along with a specific UID and namespace data. I am a bit confused as to how I can set the this data while building the Beacon using the Builder, the docs on the site of Altbeacon library demonstrate the scanning part of Eddystone beacons but transmitting an Eddystone beacon is what is missing over there.

If someone can point be to the right direction it would be helpful and I would be very greatly appreciate the help!

1

There are 1 best solutions below

0
davidgyoung On

Try this:

val beacon = Beacon.Builder()
    .setId1("0x00000001") // namespace id
    .setId2("0x00000002") // instance id
    .setTxPower(-59)
    .build()
val beaconParser: BeaconParser = BeaconParser()
    .setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT)
val beaconTransmitter = BeaconTransmitter(applicationContext, beaconParser)
beaconTransmitter.startAdvertising(beacon, object: AdvertiseCallback() {
    override fun onStartFailure(errorCode: Int) {
        super.onStartFailure(errorCode)
        Log.d(TAG, "advertising failed: $errorCode")
    }

    override fun onStartSuccess(settingsInEffect: AdvertiseSettings?) {
        super.onStartSuccess(settingsInEffect)
        Log.d(TAG, "advertising started successfully")
    }
    
})