sputnikdev / bluetooth-manager-tinyb Goto Github PK
View Code? Open in Web Editor NEWA transport implementation for the Bluetooth Manager based on TinyB library
License: Apache License 2.0
A transport implementation for the Bluetooth Manager based on TinyB library
License: Apache License 2.0
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.
2018-07-17 22:22:23.393 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'bluetooth:adapter:001A7DDA7111' to inbox.
2018-07-17 22:23:59.700 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler AdapterHandler of thing bluetooth:adapter:001A7DDA7111 tried checking if channel discovering is linked although the handler was already disposed.
2018-07-17 22:23:59.710 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler AdapterHandler of thing bluetooth:adapter:001A7DDA7111 tried checking if channel discovering-control is linked although the handler was already disposed.
2018-07-17 22:24:00.160 [WARN ] [.core.thing.binding.BaseThingHandler] - BaseThingHandler.initialize() will be removed soon, ThingStatus can be set manually via updateStatus(ThingStatus.ONLINE)
2018-07-17 22:24:10.217 [WARN ] [impl.AbstractBluetoothObjectGovernor] - Error occurred while updating governor: /00:1A:7D:DA:71:11 / 1fb3b98 : GDBus.Error:org.bluez.Error.NotSupported: Operation is not supported
2018-07-17 22:24:20.475 [WARN ] [impl.AbstractBluetoothObjectGovernor] - Error occurred while updating governor: /00:1A:7D:DA:71:11 / 35bf4a : GDBus.Error:org.bluez.Error.NotSupported: Operation is not supported
2018-07-17 22:24:30.589 [WARN ] [impl.AbstractBluetoothObjectGovernor] - Error occurred while updating governor: /00:1A:7D:DA:71:11 / 35bf4a : GDBus.Error:org.bluez.Error.NotSupported: Operation is not supported
2018-07-17 22:24:40.607 [WARN ] [impl.AbstractBluetoothObjectGovernor] - Error occurred while updating governor: /00:1A:7D:DA:71:11 / 35bf4a : GDBus.Error:org.bluez.Error.NotSupported: Operation is not supported
Does anyone else have such a problem? how to fix it? I use dongle adapter and bluez 5.47
Hello, I'm looking at this very interesting project because I'm using tinyb on my project too.
Could you tell me the tinyb vesion (or commit) in this repository?
Best regards,
HAKASHUN
x32 or x64 or only x64? thx for feedback.
regards, jan
[ERROR] Failed to execute goal on project bluetooth-manager-tinyb: Could not resolve dependencies for project org.sputnikdev:bluetooth-manager-tinyb:jar:1.3.2-SNAPSHOT: Could not find artifact intel-iot-devkit:tinyb:jar:0.6.0 in sonatype-snapshots (https://oss.sonatype.org/content/repositories/snapshots)
Any idea? It was still ok 4 days ago. Couldn't find any declaration of related changes?
apache-commons is no longer included into OH by default hence the binding is not working out of the box.
Created per discussion in: https://community.openhab.org/t/3rd-party-bluetooth-binding-beta-testers-needed/38492/1085
I had this issue as well and am therefore unable to install the binding.
I use this fantastic library on a Debian System, but when i want to start the jar i get this issue. I dont know where the native library is located to set the library path. Have i missed a step?
What am I missing in my system? This is ARM based ODROID board, running ubuntu trusty. I updated the bluez package to the 5.47 as the latest one was reported to break things. What native stuff would need to be installed?
This is running on Oracle Java 8:
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
02:56:56.098 [ERROR] [ome.binding.bluetooth.transport.tinyb] - [binding.bluetooth.transport.tinyb.activator(243)] The activate method has thrown an exception
java.lang.IllegalStateException: Could not load native libraries for TinyB
at org.sputnikdev.esh.binding.bluetooth.transport.tinyb.activator.TinyBActivator.activate(TinyBActivator.java:19) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:229) ~[?:?]
at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39) ~[?:?]
at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:650) ~[?:?]
at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:506) ~[?:?]
at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:307) ~[?:?]
at org.apache.felix.scr.impl.inject.ActivateMethod.invoke(ActivateMethod.java:299) ~[?:?]
at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:298) ~[?:?]
at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:109) ~[?:?]
at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:906) ~[?:?]
at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:879) ~[?:?]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:749) ~[?:?]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enableInternal(AbstractComponentManager.java:675) ~[?:?]
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:430) ~[?:?]
at org.apache.felix.scr.impl.manager.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:657) ~[?:?]
at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:341) ~[?:?]
at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:390) ~[?:?]
at org.apache.felix.scr.impl.Activator.access$200(Activator.java:54) ~[?:?]
at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:265) ~[?:?]
at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:254) ~[?:?]
at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:227) ~[?:?]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482) ~[?:?]
at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:415) ~[?:?]
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232) ~[?:?]
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444) ~[?:?]
at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:903) ~[?:?]
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) ~[?:?]
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) ~[?:?]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:213) ~[?:?]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:120) ~[?:?]
at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:112) ~[?:?]
at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:156) ~[?:?]
at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) ~[?:?]
at org.eclipse.osgi.container.Module.start(Module.java:467) ~[?:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:383) ~[?:?]
at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:402) ~[?:?]
at org.eclipse.smarthome.extensionservice.marketplace.internal.BindingExtensionHandler.install(BindingExtensionHandler.java:82) ~[?:?]
at org.eclipse.smarthome.extensionservice.marketplace.internal.MarketplaceExtensionService.install(MarketplaceExtensionService.java:222) ~[?:?]
at org.eclipse.smarthome.io.rest.core.internal.extensions.ExtensionResource.lambda$0(ExtensionResource.java:157) ~[?:?]
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) [?:?]
A workaround should be implemented to suppress a false TinyB exception.
intel-iot-devkit/tinyb#140
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.