I’m using Android SDK and I’m trying to read from or write into beacon storage. I’m able to connect to a beacon using DeviceConnection but when I try to read/write from/to beacon storage, I get error Error INVALID_REGISTER_ID ,register=3040). I’m not sure what does this error mean.
Below is the code snippet I’m using.
`
@Override
public void onConfigurableDevicesFound(List<ConfigurableDevice> configurableDevices) {
Log.d(TAG, "onConfigurableDevicesFound");
for (ConfigurableDevice configurableDevice : configurableDevices) {
String deviceId = configurableDevice.deviceId.toHexString();
if (deviceId.equalsIgnoreCase("<device id of a device I'm trying to connect to>")) {
mBeaconManager.stopConfigurableDevicesDiscovery();
mConnectionProvider = new DeviceConnectionProvider(this);
mConnectionProvider.connectToService(new DeviceConnectionProvider.ConnectionProviderCallback() {
@Override
public void onConnectedToService() {
Log.d(TAG, "onConnectedToService");
final DeviceConnection connection = mConnectionProvider.getConnectionForStorageRead(configurableDevice);
connection.connect(new DeviceConnectionCallback() {
@Override
public void onConnected() {
Log.d(TAG, "onConnected");
Map<String, String> map = new HashMap<>();
map.put("<some key>", "some value");
if (connection.isConnected()) {
connection.settings.storage.writeStorage(map, new StorageManager.WriteCallback() {
@Override
public void onSuccess() {
Log.d(TAG, "onSuccess");
connection.close();
}
@Override
public void onFailure(DeviceConnectionException exception) {
Log.d(TAG, "onFailure:" + exception.getLocalizedMessage());
}
});
}
}
@Override
public void onDisconnected() {
Log.d(TAG, "onDisconnected");
}
@Override
public void onConnectionFailed(DeviceConnectionException exception) {
Log.d(TAG, "onConnectionFailed:" + exception.getLocalizedMessage());
}
});
}
});
}
}
}`