Compilations error following Android guide
Hello everybody,
I am following the Android guide to change the cellbots data logger (updated android-studio version)to a version that also records the accelerometer data from a metawear. I used the android guide to implement all the callbacks etcetera, but I get stuck at the Discovering a Board section. At
final mwBoard = btManager.getAdapter().getRemoteDevice(MW_MAC_ADDRESS)
where I get the error
Error:(140, 22) error: <identifier> expected
Error:(140, 79) error: ';' expected
Even with the obvious ; fixed I get the unexpected identifier error. Furthermore is declared nowhere which seems strange. I put the fully modified version here on GitHub .
I don't know if I am amiss or if there is an error in the Guide which causes these problems. I tried earlier to implement the methods from the SOSTrigger application to connect to a metawear, this failed miserably however at the point I would select a metawear from the list, that is why I resorted to the mac-address solution following the Android guide.
It would be awesome if someone can tell me where I go wrong or how to go right.
//edit: here is the code of the main activity for easy reference: http://pastebin.com/PGs3EKTR
I am following the Android guide to change the cellbots data logger (updated android-studio version)to a version that also records the accelerometer data from a metawear. I used the android guide to implement all the callbacks etcetera, but I get stuck at the Discovering a Board section. At
final mwBoard = btManager.getAdapter().getRemoteDevice(MW_MAC_ADDRESS)
where I get the error
Error:(140, 22) error: <identifier> expected
Error:(140, 79) error: ';' expected
Even with the obvious ; fixed I get the unexpected identifier error. Furthermore is declared nowhere which seems strange. I put the fully modified version here on GitHub .
I don't know if I am amiss or if there is an error in the Guide which causes these problems. I tried earlier to implement the methods from the SOSTrigger application to connect to a metawear, this failed miserably however at the point I would select a metawear from the list, that is why I resorted to the mac-address solution following the Android guide.
It would be awesome if someone can tell me where I go wrong or how to go right.
//edit: here is the code of the main activity for easy reference: http://pastebin.com/PGs3EKTR
This discussion has been closed.
Comments
final mwBoard = btManager.getAdapter().getRemoteDevice(MW_MAC_ADDRESS)
which should be
final BluetoothDevice mwBoard = btManager.getAdapter().getRemoteDevice(MW_MAC_ADDRESS);
I think also public final string should be String.
And there are several references to the metawear controller object with different names (mwCtrllr and mwController).
My metawear with the current code is still not connecting though (debug log shows only service connect started and connecting... but not "A Bluetooth LE connection has been established!" or "shake detected" which I hoped for.
new code is on github, pastebin here: http://pastebin.com/GxxbrGNr , anyone able to tell me why my metawear is not actually connecting?
ps.Does this forum has code tags btw? I can't find any...
//edit:
android-studio also automatically changes
mwCtrllr.addDeviceCallback(new MetaWearController.DeviceCallbacks() {
I think the android guide could benefit from a good update and even more from the full code connecting a metawear (possibly by MAC and/or useing the mwscanner), maybe even a full android project doing nothing but connecting and adding a switch callback or something like that.
Accelerometer.SamplingConfig config = accelCtrllr.enableXYZSampling().withFullScaleRange(Accelerometer.SamplingConfig.FullScaleRange.FSR_8G).withOutputDataRate(Accelerometer.SamplingConfig.OutputDataRate.ODR_50_HZ);
accelCtrllr.startComponents();
and the following callback:
}).addModuleCallback(new Accelerometer.Callbacks() {
@Override
public void receivedDataValue(short x, short y, short z) {
Log.i("logdebug", "received data value");
Log.i("logdebug", String.format(Locale.US, "(%.3f, %.3f, %.3f)",
x / 1000.0, y / 1000.0, z / 1000.0));
}
});
but I receive no data . Full code again: http://pastebin.com/X8HUR9mk (also pushed to github)
//edit: for some weird reason it worked after I resetted the metawear, can anyone explain that?
The SOStrigger code also uses the scanner fragment which is not used nor explained in the android guide, which together with the errors in the android guide make it very hard for me to get to a working system (note: it took several days for a rather simple application). The SOStrigger application is also only documented (sparsly) in the code itself, but not anywhere else. For someone to understand the entire flow of code it is much easier to have a basic rundown of the system. The android guide tries to do this but failed in my eyes (giving no clear distinction between the fact that there are different methods, no clear explenation of the bluetooth device select method(s) and no full code overview where all the bits are put together in one comprehensible peace of simple code.)
Second remark: very true, I get that (I am not new to learning new platforms, programming languages etcetera)
I am familiar with lots of tech stacks, worked mainly on web platforms and linux platforms. Android is relatively new to me in that aspect that so far I only written basic prototype applications.
Boston sounds nice, but I'm in Singapore until mid July (where I'm doing my internship) then I'm back in NL for holidays and finding a graduation assignment.
As to the documentation, I mentioned the errors in the documentation in this forum post, at the moment I am to busy to help you guys with documentation.