Guest User

Mbient showcase of streaming data

a guest
Oct 12th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1.  
  2. I am using the following code to connect to the Mbient sensor:
  3. getApplicationContext().bindService(new Intent(this, MetaWearBleService.class), this, BIND_AUTO_CREATE);
  4. mwBoard= serviceBinder.getMetaWearBoard(bdArryDevice.get(which).device);
  5. mwBoard.setConnectionStateHandler(new MetaWearBoard.ConnectionStateHandler() {...});
  6. mwBoard.connect();
  7.  
  8. This is my setup for the sensors:
  9. accModule = mwBoard.getModule(Accelerometer.class);
  10. accModule.setOutputDataRate(50.f);
  11.  
  12. gyrModule = mwBoard.getModule(Gyro.class);
  13. gyrModule.setOutputDataRate(50.f);
  14.  
  15. I am using the following code to stream and log the data:
  16. accModule.routeData().fromAxes().stream("acc_stream").commit()
  17.         .onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
  18.             @Override
  19.             public void success(RouteManager result) {
  20.                 result.subscribe("acc_stream", new RouteManager.MessageHandler() {
  21.                     @Override
  22.                     public void process(Message msg) {...}});
  23.  
  24.                 accModule.enableAxisSampling();
  25.                 accModule.start();
  26.             }});
  27.  
  28. gyrModule.routeData().fromAxes().stream("gyr_stream").commit()
  29.         .onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
  30.             @Override
  31.             public void success(RouteManager result) {
  32.                 result.subscribe("gyr_stream", new RouteManager.MessageHandler() {
  33.                     @Override
  34.                     public void process(Message msg) {...}});
  35.                 gyrModule.start();
  36.             }});
Add Comment
Please, Sign In to add comment