|
|
|
@ -336,22 +336,6 @@ int lwm2m_create_object_inst(const struct lwm2m_obj_path *path)
@@ -336,22 +336,6 @@ int lwm2m_create_object_inst(const struct lwm2m_obj_path *path)
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_create_obj_inst(const char *pathstr) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
LOG_DBG("path:%s", pathstr); |
|
|
|
|
|
|
|
|
|
/* translate path -> path_obj */ |
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_create_object_inst(&path); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_delete_object_inst(const struct lwm2m_obj_path *path) |
|
|
|
|
{ |
|
|
|
|
int ret = 0; |
|
|
|
@ -371,22 +355,6 @@ int lwm2m_delete_object_inst(const struct lwm2m_obj_path *path)
@@ -371,22 +355,6 @@ int lwm2m_delete_object_inst(const struct lwm2m_obj_path *path)
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_delete_obj_inst(const char *pathstr) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
LOG_DBG("path: %s", pathstr); |
|
|
|
|
|
|
|
|
|
/* translate path -> path_obj */ |
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_delete_object_inst(&path); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct lwm2m_engine_obj_inst *lwm2m_engine_get_obj_inst(const struct lwm2m_obj_path *path) |
|
|
|
|
{ |
|
|
|
|
if (path->level < LWM2M_PATH_LEVEL_OBJECT_INST) { |
|
|
|
@ -524,36 +492,6 @@ int lwm2m_set_res_buf(const struct lwm2m_obj_path *path, void *buffer_ptr, uint1
@@ -524,36 +492,6 @@ int lwm2m_set_res_buf(const struct lwm2m_obj_path *path, void *buffer_ptr, uint1
|
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_res_buf(const char *pathstr, void *buffer_ptr, uint16_t buffer_len, |
|
|
|
|
uint16_t data_len, uint8_t data_flags) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
/* translate path -> path_obj */ |
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_set_res_buf(&path, buffer_ptr, buffer_len, data_len, data_flags); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_res_data(const char *pathstr, void *data_ptr, uint16_t data_len, |
|
|
|
|
uint8_t data_flags) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
/* translate path -> path_obj */ |
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_set_res_buf(&path, data_ptr, data_len, data_len, data_flags); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static bool lwm2m_validate_time_resource_lenghts(uint16_t resource_length, uint16_t buf_length) |
|
|
|
|
{ |
|
|
|
|
if (resource_length != sizeof(time_t) && resource_length != sizeof(uint32_t)) { |
|
|
|
@ -789,18 +727,6 @@ int lwm2m_set_opaque(const struct lwm2m_obj_path *path, const char *data_ptr, ui
@@ -789,18 +727,6 @@ int lwm2m_set_opaque(const struct lwm2m_obj_path *path, const char *data_ptr, ui
|
|
|
|
|
return lwm2m_engine_set(path, data_ptr, data_len); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_opaque(const char *pathstr, const char *data_ptr, uint16_t data_len) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_opaque(&path, data_ptr, data_len); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_string(const struct lwm2m_obj_path *path, const char *data_ptr) |
|
|
|
|
{ |
|
|
|
|
uint16_t len = strlen(data_ptr); |
|
|
|
@ -813,155 +739,47 @@ int lwm2m_set_string(const struct lwm2m_obj_path *path, const char *data_ptr)
@@ -813,155 +739,47 @@ int lwm2m_set_string(const struct lwm2m_obj_path *path, const char *data_ptr)
|
|
|
|
|
return lwm2m_engine_set(path, data_ptr, len); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_string(const char *pathstr, const char *data_ptr) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_string(&path, data_ptr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_u8(const struct lwm2m_obj_path *path, uint8_t value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_set(path, &value, 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_u8(const char *pathstr, uint8_t value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_u8(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_u16(const struct lwm2m_obj_path *path, uint16_t value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_set(path, &value, 2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_u16(const char *pathstr, uint16_t value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_u16(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_u32(const struct lwm2m_obj_path *path, uint32_t value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_set(path, &value, 4); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_u32(const char *pathstr, uint32_t value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_u32(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_u64(const struct lwm2m_obj_path *path, uint64_t value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_set(path, &value, 8); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_u64(const char *pathstr, uint64_t value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_s64(&path, (int64_t) value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_s8(const struct lwm2m_obj_path *path, int8_t value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_set(path, &value, 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_s8(const char *pathstr, int8_t value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_s8(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_s16(const struct lwm2m_obj_path *path, int16_t value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_set(path, &value, 2); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_s16(const char *pathstr, int16_t value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_s16(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_s32(const struct lwm2m_obj_path *path, int32_t value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_set(path, &value, 4); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_s32(const char *pathstr, int32_t value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_s32(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_s64(const struct lwm2m_obj_path *path, int64_t value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_set(path, &value, 8); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_s64(const char *pathstr, int64_t value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_s64(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_bool(const struct lwm2m_obj_path *path, bool value) |
|
|
|
|
{ |
|
|
|
|
uint8_t temp = (value != 0 ? 1 : 0); |
|
|
|
@ -969,69 +787,21 @@ int lwm2m_set_bool(const struct lwm2m_obj_path *path, bool value)
@@ -969,69 +787,21 @@ int lwm2m_set_bool(const struct lwm2m_obj_path *path, bool value)
|
|
|
|
|
return lwm2m_engine_set(path, &temp, 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_bool(const char *pathstr, bool value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_bool(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_f64(const struct lwm2m_obj_path *path, const double value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_set(path, &value, sizeof(double)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_float(const char *pathstr, const double *value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_f64(&path, *value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_objlnk(const struct lwm2m_obj_path *path, const struct lwm2m_objlnk *value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_set(path, value, sizeof(struct lwm2m_objlnk)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_objlnk(const char *pathstr, const struct lwm2m_objlnk *value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_objlnk(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_time(const struct lwm2m_obj_path *path, time_t value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_set(path, &value, sizeof(time_t)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_time(const char *pathstr, time_t value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_set_time(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_set_res_data_len(const struct lwm2m_obj_path *path, uint16_t data_len) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
@ -1046,20 +816,6 @@ int lwm2m_set_res_data_len(const struct lwm2m_obj_path *path, uint16_t data_len)
@@ -1046,20 +816,6 @@ int lwm2m_set_res_data_len(const struct lwm2m_obj_path *path, uint16_t data_len)
|
|
|
|
|
} |
|
|
|
|
return lwm2m_set_res_buf(path, buffer_ptr, buffer_len, data_len, data_flags); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_set_res_data_len(const char *pathstr, uint16_t data_len) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
/* translate path -> path_obj */ |
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_set_res_data_len(&path, data_len); |
|
|
|
|
} |
|
|
|
|
/* User data getter functions */ |
|
|
|
|
|
|
|
|
|
int lwm2m_get_res_buf(const struct lwm2m_obj_path *path, void **buffer_ptr, uint16_t *buffer_len, |
|
|
|
@ -1104,36 +860,6 @@ int lwm2m_get_res_buf(const struct lwm2m_obj_path *path, void **buffer_ptr, uint
@@ -1104,36 +860,6 @@ int lwm2m_get_res_buf(const struct lwm2m_obj_path *path, void **buffer_ptr, uint
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_res_buf(const char *pathstr, void **buffer_ptr, uint16_t *buffer_len, |
|
|
|
|
uint16_t *data_len, uint8_t *data_flags) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
/* translate path -> path_obj */ |
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_get_res_buf(&path, buffer_ptr, buffer_len, data_len, data_flags); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_res_data(const char *pathstr, void **data_ptr, uint16_t *data_len, |
|
|
|
|
uint8_t *data_flags) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
/* translate path -> path_obj */ |
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_get_res_buf(&path, data_ptr, NULL, data_len, data_flags); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int lwm2m_engine_get(const struct lwm2m_obj_path *path, void *buf, uint16_t buflen) |
|
|
|
|
{ |
|
|
|
|
int ret = 0; |
|
|
|
@ -1278,18 +1004,6 @@ int lwm2m_get_opaque(const struct lwm2m_obj_path *path, void *buf, uint16_t bufl
@@ -1278,18 +1004,6 @@ int lwm2m_get_opaque(const struct lwm2m_obj_path *path, void *buf, uint16_t bufl
|
|
|
|
|
return lwm2m_engine_get(path, buf, buflen); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_opaque(const char *pathstr, void *buf, uint16_t buflen) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_opaque(&path, buf, buflen); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_string(const struct lwm2m_obj_path *path, void *str, uint16_t buflen) |
|
|
|
|
{ |
|
|
|
|
/* Ensure termination, in case resource is not a string type */ |
|
|
|
@ -1301,154 +1015,46 @@ int lwm2m_get_string(const struct lwm2m_obj_path *path, void *str, uint16_t bufl
@@ -1301,154 +1015,46 @@ int lwm2m_get_string(const struct lwm2m_obj_path *path, void *str, uint16_t bufl
|
|
|
|
|
return lwm2m_engine_get(path, str, buflen); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_string(const char *pathstr, void *str, uint16_t buflen) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_string(&path, str, buflen); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_u8(const struct lwm2m_obj_path *path, uint8_t *value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_get(path, value, 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_u8(const char *pathstr, uint8_t *value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_u8(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_u16(const struct lwm2m_obj_path *path, uint16_t *value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_get(path, value, 2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_u16(const char *pathstr, uint16_t *value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_u16(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_u32(const struct lwm2m_obj_path *path, uint32_t *value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_get(path, value, 4); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_u32(const char *pathstr, uint32_t *value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_u32(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_u64(const struct lwm2m_obj_path *path, uint64_t *value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_get(path, value, 8); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_u64(const char *pathstr, uint64_t *value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_s64(&path, (int64_t *) value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_s8(const struct lwm2m_obj_path *path, int8_t *value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_get(path, value, 1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_s8(const char *pathstr, int8_t *value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_s8(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_s16(const struct lwm2m_obj_path *path, int16_t *value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_get(path, value, 2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_s16(const char *pathstr, int16_t *value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_s16(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_s32(const struct lwm2m_obj_path *path, int32_t *value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_get(path, value, 4); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_s32(const char *pathstr, int32_t *value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_s32(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_s64(const struct lwm2m_obj_path *path, int64_t *value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_get(path, value, 8); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_s64(const char *pathstr, int64_t *value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_s64(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_bool(const struct lwm2m_obj_path *path, bool *value) |
|
|
|
|
{ |
|
|
|
|
int ret = 0; |
|
|
|
@ -1462,69 +1068,21 @@ int lwm2m_get_bool(const struct lwm2m_obj_path *path, bool *value)
@@ -1462,69 +1068,21 @@ int lwm2m_get_bool(const struct lwm2m_obj_path *path, bool *value)
|
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_bool(const char *pathstr, bool *value) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_bool(&path, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_f64(const struct lwm2m_obj_path *path, double *value) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_get(path, value, sizeof(double)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_float(const char *pathstr, double *buf) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_f64(&path, buf); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_objlnk(const struct lwm2m_obj_path *path, struct lwm2m_objlnk *buf) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_get(path, buf, sizeof(struct lwm2m_objlnk)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_objlnk(const char *pathstr, struct lwm2m_objlnk *buf) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_objlnk(&path, buf); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_time(const struct lwm2m_obj_path *path, time_t *buf) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_engine_get(path, buf, sizeof(time_t)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_get_time(const char *pathstr, time_t *buf) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
return lwm2m_get_time(&path, buf); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_get_resource(const struct lwm2m_obj_path *path, struct lwm2m_engine_res **res) |
|
|
|
|
{ |
|
|
|
|
if (path->level < LWM2M_PATH_LEVEL_RESOURCE) { |
|
|
|
@ -1691,19 +1249,6 @@ int lwm2m_create_res_inst(const struct lwm2m_obj_path *path)
@@ -1691,19 +1249,6 @@ int lwm2m_create_res_inst(const struct lwm2m_obj_path *path)
|
|
|
|
|
return lwm2m_engine_allocate_resource_instance(res, &res_inst, path->res_inst_id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_create_res_inst(const char *pathstr) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_create_res_inst(&path); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_delete_res_inst(const struct lwm2m_obj_path *path) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
@ -1733,19 +1278,6 @@ int lwm2m_delete_res_inst(const struct lwm2m_obj_path *path)
@@ -1733,19 +1278,6 @@ int lwm2m_delete_res_inst(const struct lwm2m_obj_path *path)
|
|
|
|
|
k_mutex_unlock(®istry_lock); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_delete_res_inst(const char *pathstr) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_delete_res_inst(&path); |
|
|
|
|
} |
|
|
|
|
/* Register callbacks */ |
|
|
|
|
|
|
|
|
|
int lwm2m_register_read_callback(const struct lwm2m_obj_path *path, lwm2m_engine_get_data_cb_t cb) |
|
|
|
@ -1762,19 +1294,6 @@ int lwm2m_register_read_callback(const struct lwm2m_obj_path *path, lwm2m_engine
@@ -1762,19 +1294,6 @@ int lwm2m_register_read_callback(const struct lwm2m_obj_path *path, lwm2m_engine
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_register_read_callback(const char *pathstr, lwm2m_engine_get_data_cb_t cb) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_register_read_callback(&path, cb); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_register_pre_write_callback(const struct lwm2m_obj_path *path, |
|
|
|
|
lwm2m_engine_get_data_cb_t cb) |
|
|
|
|
{ |
|
|
|
@ -1790,19 +1309,6 @@ int lwm2m_register_pre_write_callback(const struct lwm2m_obj_path *path,
@@ -1790,19 +1309,6 @@ int lwm2m_register_pre_write_callback(const struct lwm2m_obj_path *path,
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_register_pre_write_callback(const char *pathstr, lwm2m_engine_get_data_cb_t cb) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_register_pre_write_callback(&path, cb); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_register_validate_callback(const struct lwm2m_obj_path *path, |
|
|
|
|
lwm2m_engine_set_data_cb_t cb) |
|
|
|
|
{ |
|
|
|
@ -1828,29 +1334,6 @@ int lwm2m_register_validate_callback(const struct lwm2m_obj_path *path,
@@ -1828,29 +1334,6 @@ int lwm2m_register_validate_callback(const struct lwm2m_obj_path *path,
|
|
|
|
|
#endif /* CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE > 0 */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_register_validate_callback(const char *pathstr, lwm2m_engine_set_data_cb_t cb) |
|
|
|
|
{ |
|
|
|
|
#if CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE > 0 |
|
|
|
|
int ret; |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_register_validate_callback(&path, cb); |
|
|
|
|
#else |
|
|
|
|
ARG_UNUSED(pathstr); |
|
|
|
|
ARG_UNUSED(cb); |
|
|
|
|
|
|
|
|
|
LOG_ERR("Validation disabled. Set " |
|
|
|
|
"CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE > 0 to " |
|
|
|
|
"enable validation support."); |
|
|
|
|
return -ENOTSUP; |
|
|
|
|
#endif /* CONFIG_LWM2M_ENGINE_VALIDATION_BUFFER_SIZE > 0 */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_register_post_write_callback(const struct lwm2m_obj_path *path, |
|
|
|
|
lwm2m_engine_set_data_cb_t cb) |
|
|
|
|
{ |
|
|
|
@ -1866,19 +1349,6 @@ int lwm2m_register_post_write_callback(const struct lwm2m_obj_path *path,
@@ -1866,19 +1349,6 @@ int lwm2m_register_post_write_callback(const struct lwm2m_obj_path *path,
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_register_post_write_callback(const char *pathstr, lwm2m_engine_set_data_cb_t cb) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_register_post_write_callback(&path, cb); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_register_exec_callback(const struct lwm2m_obj_path *path, lwm2m_engine_execute_cb_t cb) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
@ -1893,19 +1363,6 @@ int lwm2m_register_exec_callback(const struct lwm2m_obj_path *path, lwm2m_engine
@@ -1893,19 +1363,6 @@ int lwm2m_register_exec_callback(const struct lwm2m_obj_path *path, lwm2m_engine
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_register_exec_callback(const char *pathstr, lwm2m_engine_execute_cb_t cb) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
|
|
|
|
|
ret = lwm2m_string_to_path(pathstr, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_register_exec_callback(&path, cb); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_register_create_callback(uint16_t obj_id, lwm2m_engine_user_cb_t cb) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_engine_obj *obj = NULL; |
|
|
|
@ -1920,11 +1377,6 @@ int lwm2m_register_create_callback(uint16_t obj_id, lwm2m_engine_user_cb_t cb)
@@ -1920,11 +1377,6 @@ int lwm2m_register_create_callback(uint16_t obj_id, lwm2m_engine_user_cb_t cb)
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_register_create_callback(uint16_t obj_id, lwm2m_engine_user_cb_t cb) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_register_create_callback(obj_id, cb); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_register_delete_callback(uint16_t obj_id, lwm2m_engine_user_cb_t cb) |
|
|
|
|
{ |
|
|
|
|
struct lwm2m_engine_obj *obj = NULL; |
|
|
|
@ -1938,11 +1390,6 @@ int lwm2m_register_delete_callback(uint16_t obj_id, lwm2m_engine_user_cb_t cb)
@@ -1938,11 +1390,6 @@ int lwm2m_register_delete_callback(uint16_t obj_id, lwm2m_engine_user_cb_t cb)
|
|
|
|
|
obj->user_delete_cb = cb; |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_register_delete_callback(uint16_t obj_id, lwm2m_engine_user_cb_t cb) |
|
|
|
|
{ |
|
|
|
|
return lwm2m_register_delete_callback(obj_id, cb); |
|
|
|
|
} |
|
|
|
|
/* Generic data handlers */ |
|
|
|
|
|
|
|
|
|
int lwm2m_get_or_create_engine_obj(struct lwm2m_message *msg, |
|
|
|
@ -2212,32 +1659,6 @@ int lwm2m_enable_cache(const struct lwm2m_obj_path *path, struct lwm2m_time_seri
@@ -2212,32 +1659,6 @@ int lwm2m_enable_cache(const struct lwm2m_obj_path *path, struct lwm2m_time_seri
|
|
|
|
|
#endif /* CONFIG_LWM2M_RESOURCE_DATA_CACHE_SUPPORT */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int lwm2m_engine_enable_cache(const char *resource_path, struct lwm2m_time_series_elem *data_cache, |
|
|
|
|
size_t cache_len) |
|
|
|
|
{ |
|
|
|
|
#if defined(CONFIG_LWM2M_RESOURCE_DATA_CACHE_SUPPORT) |
|
|
|
|
struct lwm2m_obj_path path; |
|
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
/* translate path -> path_obj */ |
|
|
|
|
ret = lwm2m_string_to_path(resource_path, &path, '/'); |
|
|
|
|
if (ret < 0) { |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (path.level < LWM2M_PATH_LEVEL_RESOURCE) { |
|
|
|
|
LOG_ERR("path must have at least 3 parts"); |
|
|
|
|
return -EINVAL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return lwm2m_enable_cache(&path, data_cache, cache_len); |
|
|
|
|
#else |
|
|
|
|
LOG_ERR("LwM2M resource cache is only supported for " |
|
|
|
|
"CONFIG_LWM2M_RESOURCE_DATA_CACHE_SUPPORT"); |
|
|
|
|
return -ENOTSUP; |
|
|
|
|
#endif /* CONFIG_LWM2M_RESOURCE_DATA_CACHE_SUPPORT */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if defined(CONFIG_LWM2M_RESOURCE_DATA_CACHE_SUPPORT) |
|
|
|
|
static int lwm2m_engine_data_cache_init(void) |
|
|
|
|
{ |
|
|
|
|