Multiple (2 BLE) Sensors based off meta-wear sample App
Hi everyone, I'm pretty new to android development as a whole, but I've been playing around with the sensors and have found the meta-wear sample app extremely useful for providing documentation on how to use many features. I was wondering how I could go about connecting the second sensor in a method similar to the ScannerActivity here. I've looked at the MultiMw to try and figure it out but it seems to be implemented quite differently. Connecting this second sensor is pretty much the final piece of the puzzle for my app.
Could I implement an OnClickListener to the Listview rather than using the OnDeviceSelected to connect to the board? I would just setup the data route that way instead, have a dialogue box asking if I want to add another sensor and implement a loop with conditions on a yes or no result. If I press yes, the sensor connects and runs:
Intent navActivityIntent = new Intent(ScannerActivity.this, NavigationActivity.class);
navActivityIntent.putExtra(NavigationActivity.EXTRA_BT_DEVICE, btDevice);
Then i can pair a second sensor, those two lines are repeated... but this time i run the following line after the first two in order to start the activity:
startActivityForResult(navActivityIntent, REQUEST_START_APP);
Would an implementation lke this work? I'm fairly certain with traditional GATT as long as I allow one connection to finish before starting the second this would work...
Anyways let me know what you think or if i'm clearly missing something. Thanks.
This discussion has been closed.
Comments
connectAsync
's continuation to only transition to next activity once you have the required number of connected devices.mwBoard
variable operates on whatever value you assign it to.Hi Eric and Alecl17,
I am working on the same problem right now. I can obtain the single sensor info without problem. However, I want to work with two sensors at the same time. Could you send me a copy of the code or give me some suggestions on how you make the two sensors connection work?
Thanks
Quoting my first post
You can also use the example code from the tutorial project:
https://github.com/mbientlab/MetaWear-Tutorial-Android/tree/master/multimw
Thank you, Eric