Android app for two devices
Hi everyone,
my name is Michele and I need to build an app in order to collect accelerometer and gyroscope data from two different sensors with fixed macAddresses. In order to keep things simple I would like to avoid a bluetooth scan and use the macAddressess instead, so I thought of modifying the freefall app of the tutorials in the following way:
private void retrieveBoard(String wrist, String ankle) {
final BluetoothManager btManager =
(BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
final BluetoothDevice remoteDeviceWrist =
btManager.getAdapter().getRemoteDevice(wrist);
final BluetoothDevice remoteDeviceAnkle =
btManager.getAdapter().getRemoteDevice(ankle);
// Create a MetaWear board object for the Bluetooth Device
boardWrist = serviceBinder.getMetaWearBoard(remoteDeviceWrist);
boardAnkle = serviceBinder.getMetaWearBoard(remoteDeviceAnkle);
boardWrist.connectAsync().onSuccessTask(new Continuation<Void, Task<Route>>() {
@Override
public Task<Route> then(Task<Void> task) throws Exception {
Log.i("IntAt","Connected to " + wrist);
loggingWrist = boardWrist.getModule(Logging.class);
accelerometerWrist = boardWrist.getModule(Accelerometer.class);
accelerometerWrist.configure()
.odr(100f) // Set sampling frequency to 100Hz, or closest valid ODR
.commit();
return accelerometerWrist.acceleration().addRouteAsync(new RouteBuilder() {
@Override
public void configure(RouteComponent source) {
source.log(new Subscriber() {
@Override
public void apply(Data data, Object... env) {
Log.i("IntAt", data.value(Acceleration.class).toString());
}
});
}
});
}
}).continueWith(new Continuation<Route, Void>() {
@Override
public Void then(Task<Route> task) throws Exception {
if(task.isFaulted()){
Log.w("IntAt","Failed to configure wrist!", task.getError());
} else{
Log.i("IntAt","Wrist configured");
}
return null;
}
});
boardAnkle.connectAsync().onSuccessTask(new Continuation<Void, Task<Route>>() {
@Override
public Task<Route> then(Task<Void> task) throws Exception {
Log.i("IntAt","Connected to " + ankle);
loggingAnkle = boardAnkle.getModule(Logging.class);
accelerometerAnkle = boardAnkle.getModule(Accelerometer.class);
accelerometerAnkle.configure()
.odr(100f) // Set sampling frequency to 100Hz, or closest valid ODR
.commit();
return accelerometerAnkle.acceleration().addRouteAsync(new RouteBuilder() {
@Override
public void configure(RouteComponent source) {
source.log(new Subscriber() {
@Override
public void apply(Data data, Object... env) {
Log.i("IntAt", data.value(Acceleration.class).toString());
}
});
}
});
}
}).continueWith(new Continuation<Route, Void>() {
@Override
public Void then(Task<Route> task) throws Exception {
if(task.isFaulted()){
Log.w("IntAt","Failed to configure ankle!", task.getError());
} else{
Log.i("IntAt","Ankle configured");
}
return null;
}
});
}
Initially things were working out, but now when I try to use the app I get the error:
Did not receive log id within 1000ms
Can someone help me understand how to solve this issue? Moreover I don't know how to retrieve the data of accelerometere and gyroscope simultaneously (the tutorial shows only the accelerometer).
Any help is highly appreciated.
Regards,
Michele.