Skip to content

Type depending on more fields. #38

@Nutelac

Description

@Nutelac

I implementing protocol, which has multiple byte codes for one type. For example digital message may have codes in range of 0x90 - 0x9F. Naive function for generating that type can looks like this:

(defn digital-message
  [port]
  (bit-or 0x90 port))

I would like to create encoders and decoders which looks like that:
decoder:

(decode-all decoder (to-byte-buffer [0x91 0x05 0x98 0x06])) ; [{:type :digital-message :port 1 :some-data 5}
                                                            ;  {:type :digital-message :port 8 :some-data 6}]

encoder:

(encode encoder {:type :digital-message :port 2 :some-data 5}) ; [0x92 0x05]

Unfortunaly, I don't know how to implement it and combine with gloss/header.

Thanks for any response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions