public LinearAccelerationPageViewModel() { // Command to start the subscription ToggleSubscribeSwitchCommand = new Xamarin.Forms.Command( async() => { if (IsSubscribeSwitchOn) { ConnectionStatusText = "Connecting..."; await MovesenseDevice.Connect(); ConnectionStatusText = "Subscribing..."; subscription = await CrossMovesense.Current.SubscribeAccelerometerAsync( MovesenseDevice.Name, (d) => { PlotData(d.Data.Timestamp, d.Data.AccData[0].X, d.Data.AccData[0].Y, d.Data.AccData[0].Z); }, 26); ConnectionStatusText = "Subscribed"; } else { // Unsubscribe subscription.Unsubscribe(); ConnectionStatusText = "Unsubscribed"; await MovesenseDevice.Disconnect(); ConnectionStatusText = "Disconnected"; } } , () => (MovesenseDevice != null) // Enable command only if we've got a device ); InitPlotModel(); }