chrysn/aiocoap

Observer doesn't update resources

Closed this issue · 2 comments

Step-1:
aiocoap-client --method POST --content-format 40 --payload '</sensors/temp>;rt="temperature-c";secure=1' coap://localhost/resourcedirectory/?ep=node1

Step-2:
aiocoap-client --method GET --observe coap://localhost/resource-lookup/?anchor=coap://*
Output:
<coap://127.0.0.1:57202/sensors/temp>; rt=temperature-c; secure=1

Step-3:
aiocoap-client --method POST coap://localhost/reg/1/?secure=0
The registered Client gets:
<coap://127.0.0.1:57202/sensors/temp>; rt=temperature-c; secure=1

When I tried to run a lookup
iocoap-client --method GET coap://localhost/endpoint-lookup/?ep="node*"
Output:
</reg/1/>; ep=node1; secure=0; base="coap://127.0.0.1:43951"; rt=core.rd-ep

Why the observer didn't gets the latest representation of the resource ?

This is based on a misunderstanding of registration updates:

The secure=1 you set in step 1 is a property of the /sensors/temp resource. The change performed in step 3 sets an independent property of secure=0 on the registration itself, which is independent of the resource registration. (This is more easily seen if you register several resources -- each of them has an own rt property, but the registration has an ep property).

For illustration, look at the output of aiocoap-client coap://localhost/resource-lookup/ throughout the steps you perform, and see #244 (or actually #243, which you originally did the right thing and just were stopped by the bug fixed there).

So to update the secure property of the resource /sensors/temp and get an Observe notification, you should run:
aiocoap-client --method POST --content-format 40 --payload '</sensors/temp>;secure=2' coap://localhost/resourcedirectory/?ep=node1

After your clear explanation, the misunderstanding is gone. So, we close the issue.