bluetooth-manager-tinyb
bluetooth-manager-tinyb copied to clipboard
No enum constant extended_properties
I'm trying to make a BLE central using the BluetoothManager API with the TinyB-Transport. The peripheral in question runs on an Android smartphone.
If the central (using your Bluetooth Manager TinyB) has been connected to the peripheral (smartphone), and I try to connect the central to another smartphone (here using the BLE Scanner App), then I get the following Exception from the BluetoothManager:
org.sputnikdev.bluetooth.manager.BluetoothInteractionException: Error occurred while interacting (getResolvedServices) with native object: /88:78:73:E6:4E:42/C8:69:CD:15:D2:30 : No enum constant org.sputnikdev.bluetooth.manager.transport.tinyb.TinyBCharacteristic.AccessTypeMapping.extended_properties
at org.sputnikdev.bluetooth.manager.impl.AbstractBluetoothObjectGovernor.interact(AbstractBluetoothObjectGovernor.java:267)
at org.sputnikdev.bluetooth.manager.impl.AbstractBluetoothObjectGovernor.interact(AbstractBluetoothObjectGovernor.java:248)
at org.sputnikdev.bluetooth.manager.impl.DeviceGovernorImpl.getResolvedServices(DeviceGovernorImpl.java:452)
at org.sputnikdev.bluetooth.manager.impl.DeviceGovernorImpl$ServicesResolvedNotification.notify(DeviceGovernorImpl.java:813)
at org.sputnikdev.bluetooth.manager.impl.DeviceGovernorImpl$ServicesResolvedNotification.notify(DeviceGovernorImpl.java:807)
at org.sputnikdev.bluetooth.manager.transport.tinyb.TinyBDevice.lambda$null$6(TinyBDevice.java:203)
at org.sputnikdev.bluetooth.manager.transport.tinyb.TinyBFactory.lambda$notifySafely$0(TinyBFactory.java:237)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: No enum constant org.sputnikdev.bluetooth.manager.transport.tinyb.TinyBCharacteristic.AccessTypeMapping.extended_properties
at java.lang.Enum.valueOf(Enum.java:238)
at org.sputnikdev.bluetooth.manager.transport.tinyb.TinyBCharacteristic$AccessTypeMapping.valueOf(TinyBCharacteristic.java:46)
at org.sputnikdev.bluetooth.manager.transport.tinyb.TinyBCharacteristic.lambda$getFlags$0(TinyBCharacteristic.java:115)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
at org.sputnikdev.bluetooth.manager.transport.tinyb.TinyBCharacteristic.getFlags(TinyBCharacteristic.java:117)
at org.sputnikdev.bluetooth.manager.impl.DeviceGovernorImpl.convert(DeviceGovernorImpl.java:712)
at org.sputnikdev.bluetooth.manager.impl.DeviceGovernorImpl.lambda$getResolvedServices$2(DeviceGovernorImpl.java:457)
at org.sputnikdev.bluetooth.manager.impl.AbstractBluetoothObjectGovernor.interact(AbstractBluetoothObjectGovernor.java:256)
... 11 more
My code for the central (using Bluetooth Manager TinyB) is the following:
bluetoothManager = new BluetoothManagerBuilder()
.withTinyBTransport(true)
.withRediscover(false)
.withDiscovering(true)
.build();
bluetoothManager.addDeviceDiscoveryListener(new DeviceDiscoveryListener() {
@Override
public void discovered(final DiscoveredDevice discoveredDevice) {
logger.debug("Discovered a device...");
logger.info(discoveredDevice.getDisplayName());
logger.info(discoveredDevice.getName());
logger.info(String.valueOf(discoveredDevice.getURL()));
logger.info(discoveredDevice.getAlias());
bluetoothManager.getDeviceGovernor(discoveredDevice.getURL(), true)
.addBluetoothSmartDeviceListener(new BluetoothSmartDeviceListener() {
@Override
public void servicesResolved(final List<GattService> gattServices) {
logger.debug("Services resolved");
for (GattService gattService : gattServices) {
logger.debug("Discovered service: {}", gattService.getURL().toString());
List<GattCharacteristic> characteristics = gattService.getCharacteristics();
for (GattCharacteristic characteristic : characteristics) {
if (!UUID.fromString(characteristic.getURL().getCharacteristicUUID()).equals(
UUIDProperty.MESSAGE_CHAR_UUID_SEND.getUuidValue())) {
return;
}
logger.debug("Attached valuelistener");
bluetoothManager.getCharacteristicGovernor(characteristic.getURL(), true).addValueListener(
new ValueListener() {
@Override
public void changed(final byte[] value) {
logger.debug("Value is {}", new String(value));
}
});
logger.debug("Discovered characteristic {}", characteristic.getURL().toString());
}
}
}
});
}
});
bluetoothManager.start(true);
The peripheral (on Android) has the following services/characteristics:
BluetoothGattService bluetoothGattService = new BluetoothGattService(
UUIDProperty.SERVICE.getUuidValue(),
BluetoothGattService.SERVICE_TYPE_PRIMARY);
BluetoothGattCharacteristic sendCharacteristic = new BluetoothGattCharacteristic(
UUIDProperty.MESSAGE_CHAR_UUID_RECEIVE.getUuidValue(),
BluetoothGattCharacteristic.PROPERTY_WRITE,
BluetoothGattCharacteristic.PERMISSION_WRITE);
BluetoothGattCharacteristic receiveCharacteristic = new BluetoothGattCharacteristic(
UUIDProperty.MESSAGE_CHAR_UUID_SEND.getUuidValue(),
BluetoothGattCharacteristic.PROPERTY_NOTIFY,
BluetoothGattCharacteristic.PERMISSION_READ);
BluetoothGattDescriptor userConfigurationCharacteristic = new BluetoothGattDescriptor(
UUIDProperty.CLIENT_CHARACTERISTIC_CONFIGURATION_DESCRIPTOR.getUuidValue(),
BluetoothGattDescriptor.PERMISSION_READ | BluetoothGattDescriptor.PERMISSION_WRITE
);
As one can see, there should not be anything that has extended properties (I think? Please correct me if I'm wrong).
My TinyB natives version is 0.5.0 (or at least I cloned and installed from the repo (https://github.com/intel-iot-devkit/tinyb) at most a month ago).
Note that I might be using the library slightly wrong since I find the governers and URLs still a bit hard to grasp.
I have now cloned the repository and made a change in TinyBCharacteristic.java
by simply including an enum value for extended_properties
as follows:
...
extended_properties(CharacteristicAccessType.EXTENDED_PROPERTIES),
...
Now I don't know if it's okay for me to open up a pull-request for you to look at.
If it's okay for me to open one, I will do so as quickly as I can, though on my end at least TinyBFactoryTest.java
still fails even though I haven't changed anything that might make it fail. It would also be great if we could look into that.