/// <summary> /// Attempt to connect to both footwear devices. /// </summary> /// <returns></returns> private async Task <ConnectionManager> ConnectAsync() { this.state = State.Connecting; Console.WriteLine("Attempting to connect to both devices."); await this.ConnectToDeviceAsync(this.left); await this.ConnectToDeviceAsync(this.right); Console.WriteLine("Succesfully connected to both devices."); Console.WriteLine("Attempting to retrieve services from both devices."); await this.RetrieveServicesAsync(this.left); await this.RetrieveServicesAsync(this.right); Console.WriteLine("Succesfully retrieved services from both devices."); Console.WriteLine("Attempting to retrieve characterstics from both devices."); await this.RetrieveCharacteristicsAsync(this.left); await this.RetrieveCharacteristicsAsync(this.right); Console.WriteLine("Succesfully retrieved characteristics from both devices."); Console.WriteLine("Successfully Established Connection to Both Devices. Testing Haptic Motor Vibration..."); this.state = State.Connected; HapticUpdate update = new HapticUpdate(); update.leftDeviceForwardHaptic = ENABLED; update.leftDeviceReverseHaptic = ENABLED; update.rightDeviceForwardHaptic = ENABLED; update.rightDeviceReverseHaptic = ENABLED; await this.PerformAction("vibrate", update); Console.WriteLine("Sucessfully Tested Haptic Motors, Devices are Ready!"); return(this); }
/// <summary> /// Perform a haptic action. /// </summary> /// <param name="action"></param> /// <param name="update"></param> /// <returns></returns> public async Task <HapticUpdate> PerformAction(string action, HapticUpdate update) { HapticUpdate result = new HapticUpdate(); switch (action.ToLower()) { case "vibrate": await this.UpdateLeftDeviceHaptics(update.leftDeviceForwardHaptic, update.leftDeviceReverseHaptic); await this.UpdateRightDeviceHaptics(update.rightDeviceForwardHaptic, update.rightDeviceReverseHaptic); await Task.Delay(250); await this.TurnOffHaptics(); await Task.Delay(100); await this.UpdateLeftDeviceHaptics(update.leftDeviceForwardHaptic, update.leftDeviceReverseHaptic); await this.UpdateRightDeviceHaptics(update.rightDeviceForwardHaptic, update.rightDeviceReverseHaptic); await Task.Delay(250); await this.TurnOffHaptics(); return(result); case "update": default: await this.UpdateLeftDeviceHaptics(update.leftDeviceForwardHaptic, update.leftDeviceReverseHaptic); await this.UpdateRightDeviceHaptics(update.rightDeviceForwardHaptic, update.rightDeviceReverseHaptic); return(update); } }