Some more questions about logging
Hello
I have a few question that I am unable to answer on myself. I hope, somebody can help me out
1) Is there any way to check if a logger is active?
I have built an App, that starts logging the Switch and is supposed to download the data after a couple of weeks. And as far as I can see, the only feasible way to set a
logMessageHandler
for downloading the data in a new App-session, is to serialize the board state, save it inside the app, and deserialize it later on.That approach seems to work out, but every other time the serialized state and the actual board state seem to be different. Then the downloaded data are only reported via the
receivedUnknownLogEntry
(which works out too I guess, but Id like to download data without having to rely on error-handling^^).2) Also are
startLogging()
and stopLogging()
doing anything for the Switch (or what do they actually do?) ?I am using this kind of code:
AsyncOperation download_state = logModule.downloadLog(0.1f, new Logging.DownloadHandler() {
@Override
public void onProgressUpdate(int n_left, int max) {
if (n_left == 0) {
if(unhandled_logs_i > 0) {
log(String.format(getString(R.string.log_unhandled), unhandled_logs_i));
}
if(unknown_logs_i > 0) {
log(String.format(getString(R.string.log_unknown), unknown_logs_i));
}
}
}
and this seems to initialize offline logging even if I dont use
startLogging()
Same goes for
stopLogging()
. I have to uselogRoute.remove();
or
mwBoard.removeRoutes();
(from which I thought they were only for removing the handler in the app, but I guess it makes sense, that they also remove the reporting-routine on the board) to stop logging.
stopLogging()
doesnt seem to make any difference. Is the Switch different in that regard or did I just understand something wrong here?3) In combination with this, is the problem that if I use
log()
without removing the already set log-routine (which is sometimes only possible by resetting the board, if something went wrong with the deserialized state), the board seems to log every switch event twice (or even more often, when the log-routines accumulate). Then I get a ton of entries from receivedUnknownLogEntry when I download the data.I am not sure how to circumvent this.
So, is there a way to remove the the "lost" logger without resetting the device?
4) And my last question is that the
download_state.onComplete
-handler sometimes doesnt fire in my following code, even when the download seemed to complete perfectly fine.Is that a connection issue, or am I overlooking something?
AsyncOperation download_state = logModule.downloadLog(0.1f, new Logging.DownloadHandler() {
@Override
public void onProgressUpdate(int n_left, int max) {
if (n_left == 0) {
if(unhandled_logs_i > 0) {
log(String.format(getString(R.string.log_unhandled), unhandled_logs_i));
}
if(unknown_logs_i > 0) {
log(String.format(getString(R.string.log_unknown), unknown_logs_i));
}
}
}
@Override
public void receivedUnhandledLogEntry(Message msg) {
++unhandled_logs_i;
}
@Override
public void receivedUnknownLogEntry(byte logId, Calendar c, byte[] data) {
++unknown_logs_i;
}
});
I hope somebody can help me to understand it better
This discussion has been closed.
Comments
<a href="https://mbientlab.com/docs/metawear/android/2/com/mbientlab/metawear/MetaWearBoard.html#tearDown--">tearDown</a>
functionThank you very much for your answers. That helped me a lot!
4.) The problem I am having is, that I cant really replicate this issue. It only happens sometimes. But I havent figured out how and when. My theory is, that it happens when there are connection-issues
I just tried the meta-base-app and downloading the data seems to work. But maybe, there this error occurs only "randomly" too.
The firmware-version is 1.2.5. I am using a Sony-phone with Android 6.0.1