-
Notifications
You must be signed in to change notification settings - Fork 129
add initializer for device props #2392
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
add initializer for device props #2392
Conversation
adu_device_properties.manufacturer = AZ_SPAN_FROM_STR(TEST_ADU_DEVICE_MANUFACTURER); | ||
adu_device_properties.model = AZ_SPAN_FROM_STR(TEST_ADU_DEVICE_MODEL); | ||
adu_device_properties.adu_version = AZ_SPAN_FROM_STR(TEST_AZ_IOT_ADU_CLIENT_AGENT_VERSION); | ||
adu_device_properties.delivery_optimization_agent_version = AZ_SPAN_EMPTY; |
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.
Should this be AZ_SPAN_LITERAL_EMPTY? Looks like that's what it used to be and what we set it to in the device_properties_default
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.
The _LITERAL
variants of span initializers are used for setting values in struct literals. So anything with some
my_struct = { .myvalue = blah };
kind of initialization.
For assigning individual values of a struct, we can set using the non-literal version which adds a cast to that value.
This reverts commit 20504b4.
* | ||
* @return #az_iot_adu_client_device_properties. | ||
*/ | ||
AZ_NODISCARD az_iot_adu_client_device_properties az_iot_adu_client_device_properties_default(); |
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.
Nit - since this is not an "options" it should be named az_iot_adu_client_device_properties_init
similar to az_iot_message_properties_init
.
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 think here it should be _default()
. The _init()
is used to initialize a struct with parameters/values which from then on become private fields of the initialized struct. The interactions on that initialized struct are more or less as though it were an object.
Here, we're giving people a preconfigured default struct which they then directly act on. Thoughts?
No description provided.