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.






Comments

  • You can change the connectAsync's continuation to only transition to next activity once you have the required number of connected devices.
  • Thanks for the response! I think I see what you're saying but the mwBoard.connectAsync() will only connect to the first MetaWearBoard that I've declared correct? Would it only allow me to connect to mwBoard and not mwBoard2 per say?

    I was under the impression that the second MetaWearBoard "mwBoard2" would need its own connectAsync() call such as mwBoard2.connectAsync().
  • The mwBoard variable operates on whatever value you assign it to.
  • Okay, I've used a different method to get both sensors streaming but it seems to be working perfectly. If anyone curious I added a second ScannerActivity2 and made my BtleService and MetaWearBoards Static. Now I can access both in the Sensor Fusion fragment and stream them both at the same time... maybe not the most elegant but it works.
  • 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

    @Alecl17 said:
    Okay, I've used a different method to get both sensors streaming but it seems to be working perfectly. If anyone curious I added a second ScannerActivity2 and made my BtleService and MetaWearBoards Static. Now I can access both in the Sensor Fusion fragment and stream them both at the same time... maybe not the most elegant but it works.

  • Quoting my first post

    @Eric said:
    You can change the connectAsync's continuation to only transition to next activity once you have the required number of connected devices.

    You can also use the example code from the tutorial project:
    https://github.com/mbientlab/MetaWear-Tutorial-Android/tree/master/multimw

  • Thank you, Eric

This discussion has been closed.