下午好。我正在开发一个 android 应用程序,我正在尝试将一个 estimote 信标与该应用程序集成。问题是我希望能够发现特定设备更改设备的 UUID、minor、major。
要发现和测距我正在使用的信标:
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)。
最佳答案
我用这个方法,我在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();
}
关于android - 如何通过estimote android sdk更改estimote beacon的UUID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42010627/