iOS Accelerometer Example
I have downloaded the github StarterProject example. I have it building and running on iOS. It connects to my MetaMotionR and retrieves the temperature log from the device.
I would like to now modify it so that I can get real time accelerometer data from the device. I can't figure out how to do that.
I looked at the documentation and found a page talking about Swift tutorials here:
https://mbientlab.com/tutorials/SDKs.html#swift
The problem is that example code doesn't look anything like the code in the downloaded example. The downloaded example self.device doesn't have a property called accelerometer.
It also doesn't use this:
device.addObserver(self, forKeyPath: "state", options: NSKeyValueObservingOptions.New, context: nil)
device.connectWithHandler
Instead the downloaded sample has this:
self.updateLabel("Restoring")
if let state = DeviceState.loadForDevice(device) {
// Initialize the device
device.deserialize(state.serializedState)
self.updateLabel("Connecting")
device.connectAndSetup().continueWith
So where do I find an example of accelerometer that would work in the StarterProject example?
Comments
The Swift SDK just underwent major breaking changes in v3; the tutorial page currently is for the older v2 releases.
The v3 release wraps around the same C++ library as the JavaScript and Python SDKs so the Swift code will follow the same flow as the JS / Python examples:
https://github.com/mbientlab/MetaWear-SDK-JavaScript/blob/master/examples/multi_device.js
You'll want to refer to the C++ documentation as well as you will be calling it from Swift:
https://mbientlab.com/cppdocs/0/
Thanks Eric for the links but is it possible to get a complete example for IOS as we had before with MetaWearApiTest (https://github.com/mbientlab/MetaWear-SampleApp-iOS) ? for accelerometer, but also gyroscope and sensorfusion (NDOF particularly as new firmware seems to improve it...)
Personally I choose to worked with metamotion-r two years ago as some clear examples for IOS were provided with this example app.
Without a guideline to convert our iOS code, this new firmware appears like a nightmare as we have to rewrite all our code...
Thanks for your attention
I got it all working. Thanks, Eric, for the tips.