Closed FelixTing closed 9 months ago
I think use [devsdk_strings_new] directly will cause the order of the label array to be reversed from the original order. This way may not be perfect.
devsdk_strings *edgex_labels_read(const iot_data_t *obj)
{
devsdk_strings *labels = NULL;
const iot_data_t *ldata = iot_data_string_map_get (obj, "labels");
if (ldata)
{
iot_data_vector_iter_t iter;
iot_data_vector_iter (ldata, &iter);
while (iot_data_vector_iter_next (&iter))
{
labels = devsdk_strings_new (iot_data_vector_iter_string (&iter), labels); <--------- here
}
}
return labels;
}
Reference: devman.c → devsdk_add_discovered_devices → devsdk_strings_new
@ych988 I see your point. Code is updated.
You could iterate the vector backward something like
uint32_t i = iot_data_vector_size (ldata);
while (i)
{
labels = devsdk_strings_new (iot_data_string (iot_data_vector_get (ldata, --i)));
}
There is a reverse iteration function: iot_data_vector_iter_prev
fix: #482
If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/device-sdk-c/blob/main/.github/Contributing.md
PR Checklist
Please check if your PR fulfills the following requirements:
BREAKING CHANGE:
describing the break)Testing Instructions
edgex_device_read
in step 1