-
Notifications
You must be signed in to change notification settings - Fork 56
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: Create a module with SmartREST message id consts #3282
Conversation
Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
Codecov ReportAttention: Patch coverage is Additional details and impacted files📢 Thoughts on this report? Let us know! |
107963d
to
82f9bae
Compare
Robot Results
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very nice initiative and I would be really happy to see that merged. I would like to have opinions from the team about the code as a suffix being useful or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the changes this PR makes, although I think the pattern matching is currently broken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that you've inherited the existing names from the template titles in the C8y documentation. I've given some renaming suggestions, especially around the operation templates to make them sound like verbs rather than nouns. Feel free to accept/reject the ones that you feel relevant.
@@ -0,0 +1,107 @@ | |||
//! Definitions of Smartrest MQTT message ids. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Module name suggestion: static_templates.rs
(https://cumulocity.com/docs/smartrest/mqtt-static-templates)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was called that previously, but also wanted to incorporate ids like 41
and 71
, which were used in the codebase but aren't really templates.
// Operation templates (5xx) | ||
|
||
pub const RESTART: usize = 510; | ||
pub const COMMAND: usize = 511; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub const COMMAND: usize = 511; | |
pub const RUN_COMMAND: usize = 511; |
|
||
pub const RESTART: usize = 510; | ||
pub const COMMAND: usize = 511; | ||
pub const CONFIGURATION: usize = 513; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub const CONFIGURATION: usize = 513; | |
pub const SET_CONFIGURATION: usize = 513; |
pub const RESTART: usize = 510; | ||
pub const COMMAND: usize = 511; | ||
pub const CONFIGURATION: usize = 513; | ||
pub const FIRMWARE: usize = 515; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub const FIRMWARE: usize = 515; | |
pub const INSTALL_FIRMWARE: usize = 515; |
pub const COMMAND: usize = 511; | ||
pub const CONFIGURATION: usize = 513; | ||
pub const FIRMWARE: usize = 515; | ||
pub const SOFTWARE_LIST: usize = 516; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub const SOFTWARE_LIST: usize = 516; | |
pub const INSTALL_SOFTWARE_LIST: usize = 516; |
pub const SOFTWARE_LIST: usize = 516; | ||
pub const MEASUREMENT_REQUEST_OPERATION: usize = 517; | ||
pub const RELAY: usize = 518; | ||
pub const RELAY_ARRAY: usize = 519; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub const RELAY_ARRAY: usize = 519; | |
pub const SWITCH_RELAY_ARRAY: usize = 519; |
pub const RELAY_ARRAY: usize = 519; | ||
pub const UPLOAD_CONFIGURATION_FILE: usize = 520; | ||
pub const DOWNLOAD_CONFIGURATION_FILE: usize = 521; | ||
pub const LOGFILE_REQUEST: usize = 522; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub const LOGFILE_REQUEST: usize = 522; | |
pub const LOG_FILE_REQUEST: usize = 522; |
pub const UPLOAD_CONFIGURATION_FILE: usize = 520; | ||
pub const DOWNLOAD_CONFIGURATION_FILE: usize = 521; | ||
pub const LOGFILE_REQUEST: usize = 522; | ||
pub const COMMUNICATION_MODE: usize = 523; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub const COMMUNICATION_MODE: usize = 523; | |
pub const CHANGE_COMMUNICATION_MODE: usize = 523; |
pub const LOGFILE_REQUEST: usize = 522; | ||
pub const COMMUNICATION_MODE: usize = 523; | ||
pub const DOWNLOAD_CONFIGURATION_FILE_WITH_TYPE: usize = 524; | ||
pub const FIRMWARE_FROM_PATCH: usize = 525; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub const FIRMWARE_FROM_PATCH: usize = 525; | |
pub const INSTALL_FIRMWARE_FROM_PATCH: usize = 525; |
pub const DOWNLOAD_CONFIGURATION_FILE_WITH_TYPE: usize = 524; | ||
pub const FIRMWARE_FROM_PATCH: usize = 525; | ||
pub const UPLOAD_CONFIGURATION_FILE_WITH_TYPE: usize = 526; | ||
pub const SET_DEVICE_PROFILES: usize = 527; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub const SET_DEVICE_PROFILES: usize = 527; | |
pub const SET_DEVICE_PROFILE: usize = 527; |
Usage of the magic numbers was replaced with using the consts where it could be done trivially, i.e. when these magic numbers were not parts of string literals where replacing them would add a lot of code, which mainly happens to be in the unit tests. Signed-off-by: Marcel Guzik <marcel.guzik@inetum.com>
bd580c2
to
f0ff4f7
Compare
I wanted to keep the names somewhat consistent with c8y documentation, and don't really want to spend more time revising the names, so I will merge them as they are now. We can always adjust them later. |
Agree. Keeping the names consistent with c8y documentation is important even if some might be unclear. |
Proposed changes
Create a single module that contains ids for Smartrest messages and static templates.
The next steps would be for thin-edge not to use these ids directly, but to provide a higher-level layer of abstraction for interacting with Cumulocity, much like go-c8y-cli.
Types of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments