What I understand is that the DeviceConnectionProvider
provides you a DeviceConnection
object with the method getConnection(ConfigurableDevice device)
.
- After, you can connect to the device with this object:
deviceConnection.connect(DeviceConenctionCallback)
. - Once connected, you can access the settings with:
deviceConenction.settings.beacon.transmitPower.get(SettingCallback)
. - If you want to change the settings, use:
deviceConnection.settings.beacon.transmitPower.set(Integer, SettingCallback)
.
Note the possible values for the setting.
A complete code (after recovering the ConfigurableDevice
):
Integer newTransmitPower = -12;
DeviceConnectionProvider provider = new DeviceConnectionProvider(this);
DeviceConnection connection = provider.getConnection(device);
connection.connect(new DeviceConnectionCallback() {
@Override
public void onConnected() {
deviceConnection.settings.beacon.transmitPower().set(newTransmitPower, new SettingCallback<Integer>() {
@Override
public void onSuccess(Integer integer) {
// Handle setting change success
}
@Override
public void onFailure(DeviceConnectionException e) {
// Handle setting change failure
}
});
}
@Override
onDisconnected() {
// Handle disconnection
}
@Override
onConnectionFailed(DeviceConnectionException e) {
// Handle exception
}
}