如何通过estimote android sdk更改estimote beacon的UUID?

时间:2017-02-02 19:22:11

标签: android beacon estimote

下午好。我正在开发一个Android应用程序,我试图将estimote信标与应用程序集成。问题是我希望能够发现一个特定的设备更改设备的UUID,轻微,主要。

使用以下方式发现和定位信标:

    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.
                            }
                        }
                    }
                }
            });

有人能帮助我吗?我知道为了更改UUID,我需要连接到estimote云,但我不太了解它(他们网站上的示例使用了不推荐使用的BeaconConnection)。

1 个答案:

答案 0 :(得分:1)

我使用这种方法,我在Estimote andriod sdk上找到它,它被Estimote弃用,但是通过在android studio中使用正确的api设置解决问题。

我还没有找到替代解决方案,但如果我发现我会更新我的答案。

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();
}