private DroneResponse SendCommandWaitResponse(string DroneCommand) { lock (commandQueue) { if (commandQueue.Count > 0) { return(null); } commandQueue.Enqueue(DroneCommand); commanderSender.Send(DroneCommand); eventHandler.CommandSent(DroneCommand, false); } lock (responseQueue) { Monitor.Wait(responseQueue, RESPONSE_TIMEOUT_MS); } DroneResponse response = null; lock (responseQueue) { if (responseQueue.Count != 0) { response = responseQueue.Dequeue(); if (eventHandler != null) { eventHandler.ReceiveTelloResponse(response.Host, response.Port, DroneCommand, response.Response); } return(response); } } return(null); }
private string GetString(string QueryCommand, string DefaultValue = "") { DroneResponse response = SendCommandWaitResponse(QueryCommand); if (response != null) { return(response.Response); } return(DefaultValue); }
private int GetInt(string QueryCommand, int DefaultValue) { DroneResponse response = SendCommandWaitResponse(QueryCommand); int value = DefaultValue; if (response != null) { int.TryParse(response.Response, out value); } return(value); }
public bool StreamOff() { DroneResponse resp = SendCommandWaitResponse(TelloCommand.StreamOff.GetCommand()); if (resp.Response == DroneResponseValue.OK) { stream_on = false; return(true); } return(false); }
public bool IncreaseSpeed(int By = 5) { int newSpeed = CurrentSpeed + By; try { string command = TelloCommand.SetSpeed.GetCommand(newSpeed); DroneResponse resp = SendCommandWaitResponse(command); if (resp.Response == DroneResponseValue.OK) { speed = newSpeed; return(true); } } catch (CommandIntegerParamException e) {} return(false); }