              30
              (fn []
                (try
-                 (command drone :ref @(:ref drone))
-                 (command drone :pcmd @(:pcmd drone))
+                 (ref drone @(:ref drone))
+                 (pcmd drone :pcmd @(:pcmd drone))
                  (send-commands drone)
                  (catch Throwable e
                    (log/error e "Error sending commands"))))

  drone)


(defn- assoc-exclusive
  "Sets k1 to v and removes k2 from a map."
  [map k1 k2 v]

  (fn [navdata]
    (reset! (:navdata drone) navdata)
    (reset! (:connected? drone) true)
    (let [disable-emergency? (:disable-emergency? drone)
          state (:state navdata)]
      (if (and state (= (:emergency-landing state) :on) @disable-emergency?)
        (swap! (:ref drone) assoc :emergency true)
        (do
          (swap! (:ref drone) assoc :emergency false)
          (reset! disable-emergency? false))))
    (raise-event drone :navdata navdata)))


