diff --git a/platforms/dji/tello/driver.go b/platforms/dji/tello/driver.go index 180d02f8e..359f52187 100644 --- a/platforms/dji/tello/driver.go +++ b/platforms/dji/tello/driver.go @@ -334,18 +334,23 @@ func (d *Driver) Start() error { // Halt stops the driver. func (d *Driver) Halt() (err error) { // send a landing command when we disconnect, and give it 500ms to be received before we shutdown - d.Land() - readerCount := atomic.LoadInt32(&d.doneChReaderCount) - for i := 0; i < int(readerCount); i++ { - d.doneCh <- struct{}{} + if d.cmdConn != nil { + d.Land() } - time.Sleep(500 * time.Millisecond) - d.cmdConn.Close() + if d.cmdConn != nil { + d.cmdConn.Close() + } + if d.videoConn != nil { d.videoConn.Close() } + readerCount := atomic.LoadInt32(&d.doneChReaderCount) + for i := 0; i < int(readerCount); i++ { + d.doneCh <- struct{}{} + } + return }