net: lwm2m: define a CREATE operation

Prior to this patch, a CREATE operation was handled as a WRITE operation
after the object instance was created.  This becomes problematic when
handling of optional resources differs between these 2 operations.

Let's introduce an actual CREATE operation and use it later to create
these differences.

Signed-off-by: Michael Scott <michael.scott@linaro.org>
This commit is contained in:
Michael Scott 2017-08-17 12:21:28 -07:00 committed by Anas Nashif
commit 22b11ba8fe
2 changed files with 9 additions and 4 deletions

View file

@ -2043,7 +2043,7 @@ static int handle_request(struct zoap_packet *request,
case ZOAP_METHOD_POST:
if (path.level < 2) {
/* write/create a object instance */
context.operation = LWM2M_OP_WRITE;
context.operation = LWM2M_OP_CREATE;
} else {
context.operation = LWM2M_OP_EXECUTE;
}
@ -2123,6 +2123,7 @@ static int handle_request(struct zoap_packet *request,
break;
case LWM2M_OP_WRITE:
case LWM2M_OP_CREATE:
r = do_write_op(obj, &context, format);
break;

View file

@ -63,18 +63,22 @@
#define LWM2M_OP_WRITE_ATTR 4
#define LWM2M_OP_EXECUTE 5
#define LWM2M_OP_DELETE 6
#define LWM2M_OP_CREATE 7
/* operation permission bits */
#define LWM2M_OP_BIT(op) (1 << (op - 1))
/* resource permissions */
#define LWM2M_PERM_R LWM2M_OP_BIT(LWM2M_OP_READ)
#define LWM2M_PERM_W LWM2M_OP_BIT(LWM2M_OP_WRITE)
#define LWM2M_PERM_W (LWM2M_OP_BIT(LWM2M_OP_WRITE) | \
LWM2M_OP_BIT(LWM2M_OP_CREATE))
#define LWM2M_PERM_X LWM2M_OP_BIT(LWM2M_OP_EXECUTE)
#define LWM2M_PERM_RW (LWM2M_OP_BIT(LWM2M_OP_READ) | \
LWM2M_OP_BIT(LWM2M_OP_WRITE))
LWM2M_OP_BIT(LWM2M_OP_WRITE) | \
LWM2M_OP_BIT(LWM2M_OP_CREATE))
#define LWM2M_PERM_RWX (LWM2M_OP_BIT(LWM2M_OP_READ) | \
LWM2M_OP_BIT(LWM2M_OP_WRITE) | \
LWM2M_OP_BIT(LWM2M_OP_CREATE) | \
LWM2M_OP_BIT(LWM2M_OP_EXECUTE))
/* resource types */