Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type depending on more fields. #38

Open
Nutelac opened this issue May 29, 2015 · 0 comments
Open

Type depending on more fields. #38

Nutelac opened this issue May 29, 2015 · 0 comments

Comments

@Nutelac
Copy link

Nutelac commented May 29, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant