What's the best way to extend the "starter" module to read from multiple boards at once?
Hi there, I'm a pretty inexperienced programmer (physics background but working in a HCI lab currently) and am working on a Unity app that can display the orientation of a human leg based on information streaming from 3 MMC sensors. So far I have modified the "starter" script to stream quaternions to a Unity app on an android phone in real time, and update the orientation of a cube accordingly.
The last step before I'm out of the woods programming-wise (and into the area I'm actually competent in) is extending this so that data is being taken from 3 sensors instead of 1. I spent most of today trying to modify the starter script but attempting to change certain parts to set up 3 sensors seemed to completely break the rest of the code. I'm sorry I don't have a concise/specific question here but if anyone could give me some tips on how to move forward with this it would save me a lot of hours. I know that there is a multimw script in the tutorial pack, but changing that to stream 3 quaternions seems more difficult than updating the starter script to connect to multiple boards (I think, anyways).
Thanks in advance.
Comments
For the record, this is my first time doing any Android programming whatsoever so it's been a challenge. I feel like my goal should be easy to accomplish if I knew what I was looking for so I'm hoping there's a simple solution.
I'm referring to the starter script located here:
https://github.com/mbientlab/MetaWear-Tutorial-Android/tree/master/starter
My attempt so far involves keeping count of how many devices have been connected and if it is not yet the desired amount (3 in my case), then "startActivityForResult(navActivityIntent, REQUEST_START_APP);" is bypassed in the onDeviceSelected part of MainActivity. Once the required number of devices have been connected, the intent containing the 3 devices is passed to startActivityForResult.
To add to this I also made some changes to DeviceSetupActivityFragment, such as replacing "MetawearBoard metawear" with a list of such objects (similarly I have a list of SensorFusionBosch objects, and BluetoothDevice). Does this approach make sense in general? My main problem is that I have so little experience with android that I'm not even certain what many of the other methods are doing so it's hard to adjust them to work for multiple boards.
Looks go to me so far
This ended up being more trouble than its worth so I just wrote my own script. If anyone is trying to do something similar in the future (stream 3 quaternions simultaneously) my code is below. It's very bare bones but gets the job done. Basically it assigns the values to a static variable which is then accessed by an android service and streamed to my unity app. There are certainly much cleaner/more efficient ways to accomplish this but feel free to use my work as a starting point.
`public class MainActivity extends Activity implements ServiceConnection {
private BtleService.LocalBinder serviceBinder;
}`
Nice job!