package com.laseroptek.raman.data.model.serial

data class Packet(
    val stx: ByteArray = byteArrayOf(0x21),
    val cmd: ByteArray = byteArrayOf(0x00),
    val data: ByteArray = byteArrayOf(),
    val cs: ByteArray = byteArrayOf(0x0000),
    val etx: ByteArray = byteArrayOf(0x0D)
) {
    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as Packet

        if (!stx.contentEquals(other.stx)) return false
        if (!cmd.contentEquals(other.cmd)) return false
        if (!data.contentEquals(other.data)) return false
        if (!cs.contentEquals(other.cs)) return false
        if (!etx.contentEquals(other.etx)) return false

        return true
    }

    override fun hashCode(): Int {
        var result = stx.contentHashCode()
        result = 31 * result + cmd.contentHashCode()
        result = 31 * result + data.contentHashCode()
        result = 31 * result + cs.contentHashCode()
        result = 31 * result + etx.contentHashCode()
        return result
    }
}
