下午好。我正在开发一个android应用程序,并尝试将estimote beacon与该应用程序集成。问题是我想要能够发现一个特定的设备,改变设备的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,它已被弃用)。
发布于 2017-05-02 22:52:59
我使用这个方法,我在Estimote上发现的,它是被Estimote弃用的,但是在android studio中使用正确的andriod sdk设置没有问题。
我还没有找到替代的解决方案,但如果我找到了,我会更新我的答案。
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();
}https://stackoverflow.com/questions/42010627
复制相似问题