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