net: lwm2m: LwM2M Object path equal API
Added new API for check is 2 object path equal. Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
This commit is contained in:
parent
16b6892294
commit
3abd9c364a
3 changed files with 29 additions and 13 deletions
|
@ -1468,18 +1468,6 @@ void lwm2m_engine_free_list(sys_slist_t *path_list, sys_slist_t *free_list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool lwm2m_path_object_compare(struct lwm2m_obj_path *path,
|
|
||||||
struct lwm2m_obj_path *compare_path)
|
|
||||||
{
|
|
||||||
if (path->level != compare_path->level || path->obj_id != compare_path->obj_id ||
|
|
||||||
path->obj_inst_id != compare_path->obj_inst_id ||
|
|
||||||
path->res_id != compare_path->res_id ||
|
|
||||||
path->res_inst_id != compare_path->res_inst_id) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void lwm2m_engine_path_list_init(sys_slist_t *lwm2m_path_list, sys_slist_t *lwm2m_free_list,
|
void lwm2m_engine_path_list_init(sys_slist_t *lwm2m_path_list, sys_slist_t *lwm2m_free_list,
|
||||||
struct lwm2m_obj_path_list path_object_buf[],
|
struct lwm2m_obj_path_list path_object_buf[],
|
||||||
uint8_t path_object_size)
|
uint8_t path_object_size)
|
||||||
|
@ -1519,7 +1507,7 @@ int lwm2m_engine_add_path_to_list(sys_slist_t *lwm2m_path_list, sys_slist_t *lwm
|
||||||
/* Keep list Ordered by Object ID/ Object instance/ resource ID */
|
/* Keep list Ordered by Object ID/ Object instance/ resource ID */
|
||||||
SYS_SLIST_FOR_EACH_CONTAINER(lwm2m_path_list, entry, node) {
|
SYS_SLIST_FOR_EACH_CONTAINER(lwm2m_path_list, entry, node) {
|
||||||
if (entry->path.level == LWM2M_PATH_LEVEL_NONE ||
|
if (entry->path.level == LWM2M_PATH_LEVEL_NONE ||
|
||||||
lwm2m_path_object_compare(&entry->path, &new_entry->path)) {
|
lwm2m_obj_path_equal(&entry->path, &new_entry->path)) {
|
||||||
/* Already Root request at list or current path is at list */
|
/* Already Root request at list or current path is at list */
|
||||||
sys_slist_append(lwm2m_free_list, &new_entry->node);
|
sys_slist_append(lwm2m_free_list, &new_entry->node);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -551,3 +551,30 @@ int lwm2m_string_to_path(const char *pathstr, struct lwm2m_obj_path *path,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool lwm2m_obj_path_equal(struct lwm2m_obj_path *a, struct lwm2m_obj_path *b)
|
||||||
|
{
|
||||||
|
uint8_t level = a->level;
|
||||||
|
|
||||||
|
if (a->level != b->level) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level >= LWM2M_PATH_LEVEL_OBJECT && (a->obj_id != b->obj_id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level >= LWM2M_PATH_LEVEL_OBJECT_INST && (a->obj_inst_id != b->obj_inst_id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level >= LWM2M_PATH_LEVEL_RESOURCE && (a->res_id != b->res_id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level >= LWM2M_PATH_LEVEL_RESOURCE_INST && (a->res_inst_id != b->res_inst_id)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -33,4 +33,5 @@ int lwm2m_path_to_string(char *buf, size_t buf_size, struct lwm2m_obj_path *inpu
|
||||||
|
|
||||||
int lwm2m_string_to_path(const char *pathstr, struct lwm2m_obj_path *path, char delim);
|
int lwm2m_string_to_path(const char *pathstr, struct lwm2m_obj_path *path, char delim);
|
||||||
|
|
||||||
|
bool lwm2m_obj_path_equal(struct lwm2m_obj_path *a, struct lwm2m_obj_path *b);
|
||||||
#endif /* LWM2M_UTIL_H_ */
|
#endif /* LWM2M_UTIL_H_ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue