androidwear-ossensorsandroid-sensorsandroid-wear-data-api

Android Wear: DataItem API vs Channel API


I need to collect sensor data on an Android Wear device and want to stream it over to an Android smartphone. That is, I have a regular set of values that I want to send over to the phone over an extended period of time. The data rate is not high, say, 100 samples per second, with 20 bytes per measurement sample. It seems that this could either be implemented as a series of dataItems (for the DataItem API) or as a series of small blobs (for the ChannelAPI). Both DataItem and Channel APIs look like they could work. Is there a reason to choose one or the other? Other questions: 1) I've read the Android docs and it looks like the DataItem protocol allows for caching and retransmission in the case of dodgy wireless transport. Does the ChannelAPI also? 2) I will probably push each sample measurement over as a separate item (or blob) and expect these to accumulate over time. It makes sense that once the phone receives the data (and copies it to local storage) that it should remove the dataitem (or blob). Does this affect the data back on the Wear device? Thanks!


Solution

  • Okay, I'm answering my own question. After several months working with the DataLayer API, I can say that it works very well and is surprisingly robust. I have three Wear devices each pushing 100Hz sensor data to a common Android phone app and it works flawlessly with no data bottlenecks. It works even when I am outside and nowhere near a WiFi AP. Regarding the questions: 1) Yes, the caching works and I have not yet encountered an issue with missing packets. I don't know about the Channel API though. 2) I haven't found this to be an issue. One writes the data to an object on the wear device, issue a putrequest and it appears on the Phone side with a call to onDataChanged(). How it is handled in the background is blissfully transparent.