split() datarouting not working

Hi,

I wrote the following code
public void readBatteryState() {
mwSettings = metawear.getModule(Settings.class);

mwSettings.battery().addRouteAsync(new RouteBuilder() {
@Override
public void configure(RouteComponent source) {
source.split().index(0).stream(new Subscriber() {
@Override
public void apply(Data data, Object... env) {
Log.e("BATTERY CHARGE", String.valueOf(data.value(Byte.class)) + "%");
}
}).index(1).stream(new Subscriber() {
@Override
public void apply(Data data, Object... env) {
Log.e("BATTERY VOLTAGE", String.valueOf(data.value(Float.class)) + "V");
}
});
}
}).continueWith(new Continuation<Route, Void>() {
@Override
public Void then(Task<Route> task) throws Exception {
mwSettings.battery().read();
return null;
}
});
}
but it seems that split() doesn't work because I'm not able to get any log message.

If I don't split() the message containing the entire data is correctly logged, the same if I separate the two datas by data.value(Settings.BatteryState.class).charge() and data.value(Settings.BatteryState.class).voltage().
What I made wrong?

p.s. - firmware 1.3.3, api version 3.0.32

Thanks

Comments

  • If you want to stream battery data, then use the full BatteryState object for now.  Splitting should correctly work within a data processing chain.
  • Hi Eric,

    my idea is to pick only voltage for making double usage: first use react() to flash a led when is below a certain value, second calculate percentage of charging and stream it to android.

    anyway, as you said, after chained with data processing split() worked.
    thanks.

    p.s. - by the way, I noticed your android app has "soft reset". I'd like to know more about it but I wasn't able to find any info in API documents, can you please point out some links? thank you.
    (as to this last question can I leave it here or you prefer - for clarity - if I open a new thread?)
Sign In or Register to comment.