/// <summary> /// Vibrates motor /// </summary> /// <param name="id">Id of motor to vibrate</param> private async void Vibrate(int id) { // If wsVibration was instantiated correctly if (wsVibration != null) { // Create new Vibration object Vibration vib = new Vibration(); vib.Duration = 500; vib.Id = (VibratorId)id; // Vibrate using wsVibration wsVibration.VibrateAsync(vib); } // If wsVibration wasn't instantiated correclty else { // Create message to send string msg = $"vibrate {id} 500"; //send message directly to the server espServer.SendData(msg); } }
/// <summary> /// Sends vibration message to esp server to vibrate a single motor /// </summary> /// <param name="vibration">Vibration object <see cref="Vibration"/></param> /// <returns>Bool if data is send</returns> public async Task <bool> VibrateAsync(Vibration vibration) { string data = $"vibrate {(int) vibration.Id} {vibration.Duration}"; return(await mServer.SendData(data)); }