mbientlab / metawear-sdk-android Goto Github PK
View Code? Open in Web Editor NEWMetaWear Java SDK - Android - Google - Android Studio
Home Page: https://mbientlab.com
License: Other
MetaWear Java SDK - Android - Google - Android Studio
Home Page: https://mbientlab.com
License: Other
Hi, getting the following exception when trying to set up a passthrough dataprocessor:
Unhandled exception in callback
java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object java.util.Queue.poll()' on a null object reference
at com.mbientlab.metawear.impl.DataProcessorImpl$2.onResponseReceived(DataProcessorImpl.java:138)
at com.mbientlab.metawear.impl.JseMetaWearBoard$4.onMwNotifyCharChanged(JseMetaWearBoard.java:573)
at com.mbientlab.metawear.android.BtleService$1.onCharacteristicChanged(BtleService.java:228)
at android.bluetooth.BluetoothGatt$1.onNotify(BluetoothGatt.java:438)
at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:399)
at android.os.Binder.execTransact(Binder.java:453)
I'm using version 3.0.17 of the SDK with the following code setting up the dataprocessor:
acc.acceleration().addRouteAsync(new RouteBuilder() {
@Override
public void configure(RouteComponent source) {
source.limit(Passthrough.CONDITIONAL, (short) 0)
.name("acceleration_passthrough")
.log(accelerationSubscriber);
}
});
The build was working fine with version 3.2.2 (didn't try any later releases between that and 3.4.0).
After updating to 3.4.0, I get the following build issue:
Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\daksh\.gradle\caches\transforms-1\files-1.1\metawear-3.4.0.aar\96152564b9f60a709adaf03e19eb11a2\jars\classes.jar
Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing com/mbientlab/metawear/impl/DebugImpl.class
Error:com.android.dx.cf.code.SimException: invalid opcode ba (invokedynamic requires --min-sdk-version >= 26)
Error:Execution failed for task ':mobile:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\daksh\.gradle\caches\transforms-1\files-1.1\metawear-3.4.0.aar\96152564b9f60a709adaf03e19eb11a2\jars\classes.jar
I've tried a clean build -- does not work.
Hello !
I'm trying to log the accelerometer after killing my app but from the time I kill the app, the BLE Service is disconnected and when I try to get the logs from the sensor I have the following error :
UNKNOWN_LOG_ENTRY from the errorHandler of the downloadAsync() method.
It's working fine when I start and stop logging inside my app without killing it.
Here the project https://github.com/umanit/metawear_sensor_logging_example/tree/master/app/src/main/java/capteur/umanit/fr/testcapteur I just created as an example. ConfigureActivity start the logging and GetLogActivity stop it, is there something I'm missing ? Again, those activities are achieving their job well if I don't kill the app.
board.onUnexpectedDisconnect
callback not working in android 12 with MetaWare Motion RL
board.onUnexpectedDisconnect(new MetaWearBoard.UnexpectedDisconnectHandler() {
@Override
public void disconnected(int status) {
Log.i("MainActivity", "Unexpectedly lost connection: " + status);
}
});
My Kotlin implementation
val remoteDevice = bluetoothManager.adapter.getRemoteDevice(macAddress)
serviceBinder.removeMetaWearBoard(remoteDevice)
board = serviceBinder.getMetaWearBoard(remoteDevice)
board.onUnexpectedDisconnect {
//Some other code
}
BTW this callback is working fine with Android 11
MetaWare Device: MetaMotionRL
MetaWare SDK Version: 3.8.2
Phone: Google Pixel 6
Android Version: 12
The file MetaWearBLEService.java has an incorrect class name:
public class MetaWearBleService extends Service {
Should be:
public class MetaWearBLEService extends Service {
note the caps on BLE.
Hi,
I'm using the latest SDK version (3.0.32), targeting API > 21, compiling on Android Studio 2.3.3 on Mac OS Sierra and I'm trying to connect to a board via its MAC address. I currently have a MetaWearRG board to test.
My code is very basic :
public void connectToBoard(final String macAddr) {
final BluetoothManager btManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
final BluetoothDevice remoteDevice = btManager.getAdapter().getRemoteDevice(macAddr);
board = serviceBinder.getMetaWearBoard(remoteDevice);
board.connectAsync().continueWithTask(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) throws Exception {
return task.isCancelled() || !task.isFaulted() ? task : reconnect(board);
}
}).continueWith(new Continuation<Void, Task<Void>>() {
@Override
public Task<Void> then(Task<Void> task) throws Exception {
Log.i("COMPANION", "Connected to " + macAddr);
return task
});
}
});
}
It's actually quite the same as the Freefall sample app.
The app never connects to the device. More specifically, here is the BluetoothGatt output :
I/MYAPP: Starting app, connecting ...
D/BluetoothGatt: connect() - device: FF:44:46:AA:21:AF, auto: false
D/BluetoothGatt: registerApp()
D/BluetoothGatt: registerApp() - UUID=54798817-8ffe-4289-bdea-5764162a6a2b
D/BluetoothGatt: onClientRegistered() - status=0 clientIf=5
D/BluetoothGatt: refresh() - device: FF:44:46:AA:21:AF
D/BluetoothGatt: close()
D/BluetoothGatt: unregisterApp() - mClientIf=5
I/MYAPP: Reconnecting ...
( and on and on, it reconnects ad infinitum )
When using the Starter or sample app, the output is similar but onClientConnectionState()
is called and the process unfolds normally afterwards. It seems that when connecting directly with a MAC address, the onClientConnectionState()
never gets called.
connect() - device: FF:44:46:AA:21:4F, auto: false
registerApp()
registerApp() - UUID=83be2c2e-bf0a-414c-a760-cc82149d6e8e
onClientRegistered() - status=0 clientIf=5
onClientConnectionState() - status=0 clientIf=5 device=FF:44:46:AA:21:4F
discoverServices() - device: FF:44:46:AA:21:4F
onSearchComplete() = Device=FF:44:46:AA:21:4F Status=0
setCharacteristicNotification() - uuid: 326a9006-85cb-9195-d9dd-464cfbbae75a enable: true
Any help would be greatly appreciated. I can provide more details if needed.
Thanks !
Can you please include the .jar in the release just like you used to do for 2.x? I'm developing using Xamarin and, just to compile this, I would have to install gigs of tools that I don't really use. Thanks.
fst of all. thx for your effort :)
but gradle is now the standard build system and it would much be easier and faster to integrate into android studio as well.
Exception:
01-08 11:41:40.401 W/BluetoothGatt( 1650): java.lang.RuntimeException: java.lang.NoSuchMethodException: [class com.mbientlab.metawear.impl.DefaultMetaWearBoard, byte, byte]
01-08 11:41:40.401 W/BluetoothGatt( 1650): at com.mbientlab.metawear.impl.DefaultMetaWearBoard.receivedModuleInfo(SourceFile:3225)
01-08 11:41:40.401 W/BluetoothGatt( 1650): at com.mbientlab.metawear.MetaWearBleService$2.onCharacteristicChanged(SourceFile:934)
01-08 11:41:40.401 W/BluetoothGatt( 1650): at android.bluetooth.BluetoothGatt$1.onNotify(BluetoothGatt.java:438)
01-08 11:41:40.401 W/BluetoothGatt( 1650): at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:399)
01-08 11:41:40.401 W/BluetoothGatt( 1650): at android.os.Binder.execTransact(Binder.java:453)
01-08 11:41:40.401 W/BluetoothGatt( 1650): Caused by: java.lang.NoSuchMethodException: [class com.mbientlab.metawear.impl.DefaultMetaWearBoard, byte, byte]
01-08 11:41:40.401 W/BluetoothGatt( 1650): at java.lang.Class.getConstructor(Class.java:528)
01-08 11:41:40.401 W/BluetoothGatt( 1650): at java.lang.Class.getConstructor(Class.java:492)
01-08 11:41:40.401 W/BluetoothGatt( 1650): at com.mbientlab.metawear.impl.DefaultMetaWearBoard.receivedModuleInfo(SourceFile:3222)
01-08 11:41:40.401 W/BluetoothGatt( 1650): ... 4 more
serviceBinder = (MetaWearBleService.LocalBinder) service;
mwBoard = serviceBinder.getMetaWearBoard(btDevice);
mwBoard.setConnectionStateHandler(new MetaWearBoard.ConnectionStateHandler() {
@Override
public void connected() {
}
@Override
public void disconnected() {
mwBoard.connect();
}
@Override
public void failure(int status, Throwable error) {
Logger.logSevere("MetaWear: connect failed " + status + " ", error);
mwBoard.connect();
}
});
mwBoard.connect();
Hello.
It seems that there is an issue when configuring both features on a BMI160. The subscribe
method of the step detection is called multiple times when a step is taken.
However, removing the axis sampling methods (and calling bmi160Accelerometer.disableAxisSampling()
) works as expected and steps are taken one by one.
Is there a workaround for this?
subscribe
method of the StepDetection multiple times (~ 4 times).Bmi160Accelerometer bmi160Accelerometer = mwBoard.getModule(Bmi160Accelerometer.class);
bmi160Accelerometer
.configureStepDetection()
.setSensitivity(Bmi160Accelerometer.StepSensitivity.NORMAL)
.enableStepCounter()
.commit();
bmi160Accelerometer.enableStepDetection();
bmi160Accelerometer
.configureAxisSampling()
.setFullScaleRange(Bmi160Accelerometer.AccRange.AR_8G)
.setOutputDataRate(Bmi160Accelerometer.OutputDataRate.ODR_100_HZ)
.commit();
bmi160Accelerometer.enableAxisSampling();
bmi160Accelerometer.routeData().fromStepDetection().stream("step_detector").commit()
.onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {
result.subscribe("step_detector", new RouteManager.MessageHandler() {
@Override
public void process(Message message) {
Log.d(TAG, "You took a step");
}
});
}
});
bmi160Accelerometer.routeData().fromAxes().stream("accel_stream").commit()
.onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {
result.subscribe("accel_stream", new RouteManager.MessageHandler() {
@Override
public void process(Message message) {
final CartesianFloat cartesian = message.getData(CartesianFloat.class);
}
});
}
});
bmi160Accelerometer.start();
subscribe
method of the StepDetection one time.Bmi160Accelerometer bmi160Accelerometer = mwBoard.getModule(Bmi160Accelerometer.class);
bmi160Accelerometer
.configureStepDetection()
.setSensitivity(Bmi160Accelerometer.StepSensitivity.NORMAL)
.enableStepCounter()
.commit();
bmi160Accelerometer.enableStepDetection();
bmi160Accelerometer.disableAxisSampling();
bmi160Accelerometer.routeData().fromStepDetection().stream("step_detector").commit()
.onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {
result.subscribe("step_detector", new RouteManager.MessageHandler() {
@Override
public void process(Message message) {
Log.d(TAG, "You took a step");
}
});
}
});
bmi160Accelerometer.start();
Just to let you know that importing these projects into eclipse gives the error "Invalid project description."
Hi, When I was programming following the YouTube video, I had a problem I appeared: Cannot Resolve symbol ´seviceBinder´ and I do not know how to continue, in addition to the above I wanted to know if the same can be done but instead of accelerating with euler angles.
Please help me that I am stuck with this. Thank you very much in advance
I added ivy repo in project build.gradle. I added implementation for module build.gradle. I am using SDK 3.6.1. I cannot resolve the com.mbientlab:metawear:3.8.2 implementation. I tried it on work and personal computer so I am sure it is not a firewall issue. Please advise, thanks.
My module build.gradle is as follows:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.liminal"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
releaseImplementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.mbientlab:metawear:3.8.2'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
When my app goes in background, after a few seconds, it crashes and it comes up this log:
Assertion failed: (success), function __26-[MBLMetaWear synchronize]_block_invoke, file /Users/sschiffli/Code/metawear-ios-api/MetaWear/MBLMetaWear.m, line 850. (lldb)
`__26-[MBLMetaWear synchronize]_block_invoke:
0x100216884 <+0>: stp x29, x30, [sp, #-16]!
0x100216888 <+4>: mov x29, sp
0x10021688c <+8>: ldp x8, x2, [x0, #32]
0x100216890 <+12>: adrp x9, 506
0x100216894 <+16>: ldr x1, [x9, #3904]
0x100216898 <+20>: orr w3, wzr, #0x1
0x10021689c <+24>: mov x0, x8
0x1002168a0 <+28>: bl 0x1002f3928 ; symbol stub for: objc_msgSend
0x1002168a4 <+32>: tbz w0, #0, 0x1002168b0 ; <+44> at MBLMetaWear.m:850
0x1002168a8 <+36>: ldp x29, x30, [sp], #16
0x1002168ac <+40>: ret
0x1002168b0 <+44>: adrp x0, 306
0x1002168b4 <+48>: add x0, x0, #3324 ; =3324
0x1002168b8 <+52>: adrp x1, 306
0x1002168bc <+56>: add x1, x1, #2468 ; =2468
0x1002168c0 <+60>: adrp x3, 291
0x1002168c4 <+64>: add x3, x3, #2592 ; =2592
0x1002168c8 <+68>: movz w2, #0x352
0x1002168cc <+72>: bl 0x1002f3b20 ; symbol stub for: __assert_rtn
It is unclear to me how the logging process using this SDK works. The documentation doesn't clarify how to access the data after I call downloadAsync()
. I already looked at your Logging Implementation but I still can't figure out how it works.
It would be really helpful for me if you could clarify how it works and also maybe update it in the documentation.
EDIT: Ok I think I get it now. If I use the .log()
Method the apply
Method of that subscriber gets called when I call asyncDownload()
, is that correct?
EDIT 2: Is there any way to check whether the on board storage is full / how full it is?
Hi, We are evaluating the Mbient Metatracker product.
We want to stream from the sensor only if a certain condition is met. (Accelerometer)
For example, with the accelerometer, we want to stream the data if the RSS value of XYZ is > 1.4 and the z-axis value > 0.39.
I have seen examples of filtering one of these values but I am not very sure how to filter in this situation.
Wanted to check if we can do a custom filter on the RouteComponent or if there is any other way.
Also, is there a way to selectively stream the original xyz values, if this certain condition is met, as the RouteComponent progressively transform these values, and I am not sure how to stream the original ones.
Any direction is appreciated.
Thanks in advance
Hi, I'm getting the above error when trying to serialize the board state with version 3.0.7 of the api. Full stack trace follows.
com.mbientlab.metawear.impl.JseMetaWearBoard$4 java.io.NotSerializableException: com.mbientlab.metawear.impl.JseMetaWearBoard$4 at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1344) at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461) at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959) at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360) at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054) at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384) at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461) at java.util.HashMap.writeObject(HashMap.java:976) at java.lang.reflect.Method.invoke(Native Method) at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1033) at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384) at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461) at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:959) at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:360) at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1054) at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1384) at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1651) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1497) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1461) at com.mbientlab.metawear.impl.JseMetaWearBoard.serialize(JseMetaWearBoard.java:1052) at com.mbientlab.metawear.impl.JseMetaWearBoard.serialize(JseMetaWearBoard.java:1044)
I need to set mbient meta detector trackers for regular logging of telemetry. I see the below error consistently on every connect. The first time that I see it is when I am configuring the sensors for logging. I have made a simpler app with just my configuration code that consistently causes the below error. I would appreciate if you could let me know what might be causing this exception.
On a few occasions I have seen an app crash (could be unrelated) but wanted to see if you help better understand what is the cause of the below error and how one could avoid it.
Link to source code:
https://github.com/gnanda17/configuring-metawear-board/blob/master/app/src/main/java/com/test/configuretrackers/ConfigurationApplication.java
Link to logcat gist:
https://gist.github.com/gnanda17/bbd6873b9d8ca71e32f1344ea4d30660
Configuring trackers:
Meta Detector with Temp + Proximity + Light + Acc
Error
12-30 21:53:31.545 14234-14263/com.test.configuretrackers E/MetaWear: Background task reported an error
java.util.concurrent.ExecutionException: java.lang.NullPointerException: Attempt to read from field 'com.mbientlab.metawear.impl.ResponseHeader com.mbientlab.metawear.impl.Response.header' on a null object reference
at java.util.concurrent.FutureTask.report(FutureTask.java:94)
at java.util.concurrent.FutureTask.get(FutureTask.java:164)
at com.mbientlab.metawear.MetaWearBleService$3.run(MetaWearBleService.java:1364)
at java.util.Timer$TimerImpl.run(Timer.java:284)
Caused by: java.lang.NullPointerException: Attempt to read from field 'com.mbientlab.metawear.impl.ResponseHeader com.mbientlab.metawear.impl.Response.header' on a null object reference
at com.mbientlab.metawear.impl.DefaultMetaWearBoard.receivedResponse(DefaultMetaWearBoard.java:4604)
at com.mbientlab.metawear.MetaWearBleService$2$7.run(MetaWearBleService.java:1141)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
When working with the MetaWearBleService I frequently get the following NPE.
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.bluetooth.BluetoothGatt.close()' on a null object reference
com.mbientlab.metawear.MetaWearBleService$GattConnectionState$1.run(SourceFile:236)
android.os.Handler.handleCallback(Handler.java:739)
android.os.Handler.dispatchMessage(Handler.java:95)
android.os.Looper.loop(Looper.java:148)
android.app.ActivityThread.main(ActivityThread.java:5417)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Hi,
My Swift app uses the bmi270's step counter and activity monitor, but I don't see a way to use it with the android sdk? I see that it is implemented for the bmi160, but my board only has the 270
what can I do?
Please add to README.md that Project compliance level should be set to JDK1.7 or else you will get build errors
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.