Skip to content

net: added CoAP RD client for simple node registration#7406

Merged
bergzand merged 4 commits intoRIOT-OS:masterfrom
haukepetersen:add_rdcli_simple
Apr 9, 2018
Merged

net: added CoAP RD client for simple node registration#7406
bergzand merged 4 commits intoRIOT-OS:masterfrom
haukepetersen:add_rdcli_simple

Conversation

@haukepetersen
Copy link
Copy Markdown
Contributor

@haukepetersen haukepetersen commented Jul 25, 2017

based on #7402
also needs

This PR provides a CoAP resource directory (RD) client implementation, that uses the simplified client registration as described in section 5.3.2 in draft-ietf-core-resource-directory-11. The client implementation can be used in two different ways:

  1. standalone (USEMODULE += rdcli_simple_standalone): in this mode the module is running in its own thread, which is started automatically on system startup via auto-init. In this mode, nothing has to be done by the user.
  2. 'manual' (USEMODULE += rdcli_simple): in this mode, the user has to take care of calling rdcli_simple_register() for initial registration and then periodically or on certain events to refresh the registration and to reset the lifetime counter in the resource directory.

The rdcli_simple client is statically configured through the sys/net/include/rdcli_config.h header.

@haukepetersen haukepetersen added Area: network Area: Networking Type: new feature The issue requests / The PR implemements a new feature for RIOT State: waiting for other PR State: The PR requires another PR to be merged first labels Jul 25, 2017
@haukepetersen haukepetersen added this to the Release 2017.10 milestone Jul 25, 2017
@smlng
Copy link
Copy Markdown
Member

smlng commented Jul 27, 2017

just a quick one on first sight: I find the naming (rdcli) a bit vague, i.e. its the CoAP Resource Directory, hence I would expect coap to be part of the name/prefix?

@haukepetersen
Copy link
Copy Markdown
Contributor Author

but then the name gets too long... Also, I just saw, the official name is CoRE Resource Directory, so the natural name would be corerdcli?! But a quick google search for resource directory points very reliable to the CoRE RD, so IMHO it is fine to omit the CoRE from the name of the module and stick to rdcli. I could however change the name of the example project to something more meaningful...

@smlng
Copy link
Copy Markdown
Member

smlng commented Jul 27, 2017

mhm, I thought RD is intrinsically connected to/with CoAP - but as I just read, its not [;] CoAP is just one way to access resources. So never mind, leave naming as is.

@haukepetersen
Copy link
Copy Markdown
Contributor Author

awesome. Would you be inclined to maybe have a look at the underlying PR by any chance?!

(void)arg;

/* wait some seconds to give the address configuration some time to settle */
xtimer_sleep(3);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't more useful to have a define for this delay? Are there situations where 3 seconds is insufficient?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably yes. Will add this.

@haukepetersen
Copy link
Copy Markdown
Contributor Author

startup delay is now configurable. Still waiting for kaspar030/sock#17, though.

@haukepetersen haukepetersen force-pushed the add_rdcli_simple branch 2 times, most recently from 4eb2070 to ea2af21 Compare September 6, 2017 13:59
@haukepetersen
Copy link
Copy Markdown
Contributor Author

kaspar030/sock#17 was merged, so rebased and updated the nanocoap pkg

@haukepetersen haukepetersen removed the State: waiting for other PR State: The PR requires another PR to be merged first label Sep 6, 2017
@haukepetersen
Copy link
Copy Markdown
Contributor Author

Did some additional enhancements and fixes:

  • removed all dependencies for hwrng from example application
  • improved resources in example
  • fixed doxygen in many places
  • fixed gcoap to accept NULL as response handler
  • renamed example to rdcli_simple

@bergzand
Copy link
Copy Markdown
Member

bergzand commented Oct 8, 2017

Is there any advantage to having the separate gcoap RD examples instead of integrating them in the gcoap example? As a test, I think it is useful to have a minimal CoAP RD test, but I think it would be better to have the example integrated in the gcoap example.

@haukepetersen
Copy link
Copy Markdown
Contributor Author

Yes, so far it's separation of concerns... The example of introduced by this PR is to demonstrate the simplified registration as most likely used by very minimal setups, and this is IMHO best demonstrated by a minimal demo application. I would then rather integrate the full RD client as part of the gcoap example...

Copy link
Copy Markdown
Member

@bergzand bergzand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a number of remarks based on a scan through the code. Example looks and works good.


ifneq (,$(filter rdcli_common,$(USEMODULE)))
USEMODULE += luid
USEMODULE += fmt
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't it be better if the rdcli_common module depends on gcoap? It is the first module in this module dependency string that requires coap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

USEMODULE += shell_commands
USEMODULE += ps

FEATURES_REQUIRED += periph_hwrng
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm don't see why a hwrng required for this example.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ups, leftover from a previous example, will drop

* @{
*
* @file
* @brief CoRE RD simple registration test application
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a minor remark, but maybe it is possible to add here that this is a CoAP CoRE RD example, as this example is a CoAP specific example of the CoRE RD rfc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return res;
}
/* finish, we don't have any payload */
ssize_t len = gcoap_finish(&pkt, 0, COAP_FORMAT_TEXT);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the rfc draft section 5.3.2, this should be COAP_FORMAT_LINK.

@haukepetersen
Copy link
Copy Markdown
Contributor Author

@bergzand addressed your comments, thanks for the review!

@smlng
Copy link
Copy Markdown
Member

smlng commented Jan 16, 2018

please rebase, also nanocoap is now part of RIOT, i.e. no external package anymore.

@haukepetersen
Copy link
Copy Markdown
Contributor Author

reabsed and added the RD server address configuration to the example's Makefile.

@bergzand can I squash?

@bergzand
Copy link
Copy Markdown
Member

ACK

@bergzand can I squash?

Yes, I'd say this is ready to get merged unless somebody else wants to start nitpicking over it at this point :)

Copy link
Copy Markdown
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minors, feel free to directly squash

#define PRIO (THREAD_PRIORITY_MAIN - 1)
#define TNAME "rdcli_simple"

char stack[STACKSIZE];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

}

luid_get(luid, sizeof(luid));
for (unsigned i = 0; i < sizeof(luid); i++) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a fmt_bytes_hex now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@kb2ma
Copy link
Copy Markdown
Member

kb2ma commented Mar 26, 2018

@haukepetersen, @bergzand: What did you use as an RD server for development/testing?

@kb2ma
Copy link
Copy Markdown
Member

kb2ma commented Mar 27, 2018

@haukepetersen, @bergzand: What did you use as an RD server for development/testing?

Never mind. I see Hauke's comment in #7428 on @pekkanikander's JavaScript-based server.

@kb2ma
Copy link
Copy Markdown
Member

kb2ma commented Mar 27, 2018

I haven't actually tested the implementation but have a couple of comments. Overall, I think this work is a nice addition. A resource directory seems like a worthwhile service to reduce the burden on a constrained network.

I understand the need for flexibility at this point in the implementation. Let the user decide whether to run the registration themselves or in an external thread. However, registration management seems like an infrastructure task rather than something an application developer should care about in detail. gcoap itself seems well suited to this work. It runs in its own thread and is designed as a kind of messaging hub. In the future, it can provide resource registration as an optional service.

gcoap already has the gcoap_register_listener() function to trigger registration. Then it can use its thread message handler loop to react to a timer to re-register based on lifetime. Maybe this work could be the beginning of a plug-in mechanism for optional CoAP features.

Just to be clear, I'm envisioning gcoap-based registration as future work, and not blocking this PR. :-)

@haukepetersen haukepetersen force-pushed the add_rdcli_simple branch 2 times, most recently from 96703af to a0373a5 Compare April 6, 2018 09:33
@haukepetersen
Copy link
Copy Markdown
Contributor Author

rebased and squashed.

@kaspar030 fixed your remarks and merged them right in

@kb2ma Thanks for your thoughts! I think what you sketch makes a lot of sense, and reusing the gcoap's thread for this kind of tasks seems like a very valid approach. Being able to integrate this RD implementation into a 'larger' scope is exactly the reason, why I factored out the thread-stuff into an optional sub-module. Once this PR is merged, I will bring the 'full' RD client PR (#7428) back in a good shape. I would think that that PR is suited well to filter out the exact requirements on gcoap for running additionally 'CoAP based services'. So lets see were we can take that.

@haukepetersen haukepetersen added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed State: waiting for other PR State: The PR requires another PR to be merged first labels Apr 9, 2018
@kaspar030
Copy link
Copy Markdown
Contributor

ACK from my side. @bergzand all yours!

@haukepetersen
Copy link
Copy Markdown
Contributor Author

fixed header guards and sqqashed.

@bergzand
Copy link
Copy Markdown
Member

bergzand commented Apr 9, 2018

@haukepetersen Could you please add the failed boards from Murdock to the examples BOARD_INSUFFICIENT_MEMORY list? Feel free to keep it squashed :)

@haukepetersen
Copy link
Copy Markdown
Contributor Author

done

@haukepetersen
Copy link
Copy Markdown
Contributor Author

Travis seems to have a point here, do not merge yet!

@haukepetersen
Copy link
Copy Markdown
Contributor Author

nope, false alarm, defining a custom value for RDCLI_EP does work as expected, I merely had some trouble escaping the " chars locally.

So until somebody can explain why Travis complains about RDCLI_EP being void, I'd say its save to merge this PR...

@haukepetersen
Copy link
Copy Markdown
Contributor Author

@bergzand what do you say, should we merge?

@bergzand
Copy link
Copy Markdown
Member

bergzand commented Apr 9, 2018

Murdock is not complaining about it, so I blame the older cppcheck from travis.

@bergzand bergzand merged commit 4b210bb into RIOT-OS:master Apr 9, 2018
@haukepetersen haukepetersen deleted the add_rdcli_simple branch April 9, 2018 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants