Thursday, July 23, 2015

Forwarding CMSensorRecorder results to iPhone for display

My next step in building out a sensor data stream is to send recorded data to the iPhone. The ttl code on github is up to date. Initially this is just displayed on the phone, a bit of a hello world. However, this illustrates a few features and issues:
  • The phone and watch do not have to be connected during the call to transfer data
  • Data split into batches
  • The WCSession callbacks (data sent, error sending)
  • The serialization bug in NSDate in beta3 (send it as string...)
  • Need to figure out why NSString(format: "%s", dataFormatter.stringFromDate()) doesn't encode properly...
Here's a screen shot of what the results look like.  We see the watch processed 4082 events.



And here's the first page of the events as shown on the iPhone.



Next up, get the reader on a background thread, get the serializer working cleaner, perhaps using temporary file transfer, and then send data to Kinesis.  Next, adjust the UI to have an 'enable' recorder feature which will:
  • Kick off the recorder in small batches with a daemon thread to kick off another batch continuously if the enable switch is set
  • Have a periodic dequeue from the sensor IFF the iPhone is reachable (there is a notify for this), only sending the newly available batches.
  • Similarly, the iPhone will queue up this data (using the local Kinesis buffering) for delivery when its network is reachable
At that point there should be a durable delivery chain from watch through phone to AWS...

No comments:

Post a Comment