diff -r aa7dc7faf1bb -r 358a601bfe81 Message.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Message.h Sun May 11 00:30:03 2025 +0200
@@ -0,0 +1,88 @@
+/**
+ * djm-fix
+ * Copyright © 2025 František Kučera (Frantovo.cz, GlobalCode.info)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+
+#include
+#include
+#include
+#include
+
+enum class MessageType : uint8_t {
+ /** device sends: greeting message */
+ D11_GREETING = 0x11,
+
+ /** host sends: seed1 */
+ H12_SEED1 = 0x12,
+
+ /** device sends: hash1 and seed2 */
+ D13_HASH1_SEED2 = 0x13,
+
+ /** host sends: hash2 */
+ H14_HASH2 = 0x14,
+
+ /** device sends: confirmation of successful handshake */
+ D15_CONFIRMATION = 0x15,
+};
+
+enum class FieldType : uint8_t {
+ /** manufacturer name */
+ F01 = 0x01,
+ /** product name */
+ F02 = 0x02,
+ /** seed1 from host | seed2 from device */
+ F03 = 0x03,
+ /** hash2 from host | hash1 from device */
+ F04 = 0x04,
+ /** seed3 from device */
+ F05 = 0x05,
+};
+
+class Field {
+public:
+ FieldType type;
+ std::vector data;
+
+ Field(FieldType type, std::vector data) : type(type), data(data) {
+ }
+
+ virtual ~Field() = default;
+};
+
+/**
+ * Object representation of a raw MIDI message.
+ * Is either a result of parsing a raw message by MessageCodec, or constructed
+ * in the application to be serialized in MessageCodec to a raw message.
+ */
+class Message {
+public:
+ MessageType type;
+ /** 0x17 for DJM-250MK2 and 0x34 for V10 (maybe not a version) */
+ uint8_t version;
+ std::vector fields;
+
+ Message(MessageType type, uint8_t version, std::vector fields) :
+ type(type), version(version), fields(fields) {
+ }
+
+ virtual ~Message() = default;
+
+ std::string toString() const;
+
+ std::vector findFields(FieldType type);
+
+};