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

Refactor request/response to EZSP commands using lambdas #70

Open
lionelains opened this issue Aug 27, 2020 · 0 comments
Open

Refactor request/response to EZSP commands using lambdas #70

lionelains opened this issue Aug 27, 2020 · 0 comments
Labels
refactor Rewriting current code in a more maintenable way

Comments

@lionelains
Copy link
Contributor

lionelains commented Aug 27, 2020

Currently, commands are sent in libezsp-main dedicated methods (mostly using a subcall to dongle.sendCommand())
Responses, however are parsed in a generic reception handler CLibEzspMain::handleEzspRxMessage() and its sub fonctions.

However, this spreads request and responses code apart one from the other, decreasing readability and maintenability, also requiring to store state between request and response.
A better approach would be to point to the response code in the request code, loading a temporary overlay for the duration of the request (possibly with a timeout). This would allow for default response handlers to still exist, but to indicate the expected response handler (the command ID is expected to be provided there).
This would also allow easily passing states as variable captured by value between request and response.
A whole response-dispatching framework supporting at least one level of overlay (defaut handler + overlaid halder) needs to be implemented for this and existing request code should be re-written, though.

@lionelains lionelains added the refactor Rewriting current code in a more maintenable way label Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Rewriting current code in a more maintenable way
Projects
None yet
Development

No branches or pull requests

1 participant