    Ignore every other byte. Go to Payload size state when a start byte is seen;
    don't save the byte regardless. When a start byte is seen, completely reset
    the state."
-  [{:keys [decode-sm ^ByteBuffer input-buffer] :as channel} a-byte]
+  [{:keys [decode-sm decode-message-id ^ByteBuffer input-buffer] :as channel} a-byte]
   (when (or (= a-byte MAVLINK1-START-BYTE)
             (= a-byte MAVLINK2-START-BYTE))
-    (reset! decode-sm {:state payload-size-state
-                   :protocol (if (= a-byte MAVLINK1-START-BYTE)
-                               :mavlink1
-                               :mavlink2)})
+    (reset! decode-sm payload-size-state)
+    (reset! decode-message-id nil)
     (.clear input-buffer)
+    (.put input-buffer ^byte a-byte)
     nil))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

   :last-values (apply merge (map #(let [{:keys [msg-key default-msg]} %]
                                     {msg-key (ref default-msg)})
                                  (vals (:messages-by-keyword mavlink))))
   :decode-sm (atom {:state start-state})
   :statistics (atom {:bytes-received 0
                      :messages-decoded 0
                      :messages-encoded 0

    (while (zero? (.get payload (dec (.position payload))))
      (.position payload (dec (.position payload))))
    (let [trimmed-payload-size (.position payload)]
      (aset-byte packed (byte-to-long (.byteValue (new Long trimmed-payload-size))))

      ; now copy the array from the payload to the packed array.
      (java.lang.System/arraycopy (.array payload) 0 packed 6 (.position payload))
