Poider12
Poider12

Reputation: 223

How to change an estimote beacon's UUID through estimote android sdk?

Good afternoon. I'm developing an android app and I'm trying to integrate an estimote beacon with the app. The thing is I want be able to discover a specific device change the device's UUID, minor, major.

To discover and range the beacons I'm using:

    beaconManager.startRanging(region);

            beaconManager.setRangingListener(new BeaconManager.RangingListener() {
                @Override
                public void onBeaconsDiscovered(Region region, List<Beacon> list) {

                    if (!list.isEmpty()) {

                        for(Beacon b : list){

                            if (b.getMacAddress().equals(macaddress)){

 %%Now that i have the Beacon b I would like to change it's UUID, major and minor.
                            }
                        }
                    }
                }
            });

Can somebody help me? I know that in order to change the UUID I need to be connected to the estimote cloud but I'm not quite getting how (The example on their website uses BeaconConnection which is deprecated).

Upvotes: 1

Views: 308

Answers (1)

Maytham Fahmi
Maytham Fahmi

Reputation: 33387

I use this method, I found on Estimote andriod sdk, it is deprecated by Estimote, but works with out problem by using the proper api setting in android studio.

I was not able to find alternative solution yet, but if I found I will update my answer.

private void editBeacon(final Beacon beacon, UUID newUuid, int newMinor, int newMajor) {
    connection = new BeaconConnection(this, beacon, new BeaconConnection.ConnectionCallback() {
        @Override
        public void onAuthorized(BeaconInfo beaconInfo) {

        }

        @Override
        public void onConnected(BeaconInfo beaconInfo) {
            Log.d(TAG, "Authenticated to beacon. Info: " + beaconInfo);
            Log.d(TAG, "Advertising internal: " + connection.advertisingIntervalMillis().get());
            Log.d(TAG, "Broadcasting transmitPower: " + connection.broadcastingPower().get());
        }

        @Override
        public void onAuthenticationError(EstimoteDeviceException exception) {
            Log.d(TAG, "Authentication Error: " + exception);
        }

        @Override
        public void onDisconnected() {
            Log.d(TAG, "Disconnected");
        }
    });

    connection.authenticate();

    // Interact with beacon.

    // You can update beacon's properties in following way:
    connection.edit()
            .set(connection.proximityUuid(), newUuid)
            .set(connection.major(), newMajor)
            .set(connection.minor(), newMinor)
            .commit(new BeaconConnection.WriteCallback() {
                @Override
                public void onSuccess() {
                }

                @Override
                public void onError(EstimoteDeviceException exception) {
                }
            });

    // Do not forget to close connection.
    connection.close();
}

Upvotes: 1

Related Questions