net/rdcli_simple: rename to cord_epsim

This commit is contained in:
Hauke Petersen 2018-10-15 10:44:32 +02:00
parent 152623577e
commit 226b9fa383
10 changed files with 103 additions and 96 deletions

View File

@ -749,14 +749,14 @@ ifneq (,$(filter skald,$(USEMODULE)))
USEMODULE += random USEMODULE += random
endif endif
ifneq (,$(filter rdcli_simple_standalone,$(USEMODULE))) ifneq (,$(filter cord_epsim_standalone,$(USEMODULE)))
USEMODULE += rdcli_simple USEMODULE += cord_epsim
USEMODULE += xtimer USEMODULE += xtimer
endif endif
ifneq (,$(filter rdcli_simple,$(USEMODULE))) ifneq (,$(filter cord_epsim,$(USEMODULE)))
USEMODULE += cord_common USEMODULE += cord_common
USEMODULE += fmt USEMODULE += gcoap
endif endif
ifneq (,$(filter rdcli_standalone,$(USEMODULE))) ifneq (,$(filter rdcli_standalone,$(USEMODULE)))
@ -776,7 +776,6 @@ endif
ifneq (,$(filter cord_common,$(USEMODULE))) ifneq (,$(filter cord_common,$(USEMODULE)))
USEMODULE += fmt USEMODULE += fmt
USEMODULE += gcoap
USEMODULE += luid USEMODULE += luid
endif endif

View File

@ -20,7 +20,7 @@ USEMODULE += auto_init_gnrc_netif
USEMODULE += gnrc_ipv6_default USEMODULE += gnrc_ipv6_default
# Run the simple CoRE resource directory # Run the simple CoRE resource directory
USEMODULE += rdcli_simple_standalone USEMODULE += cord_epsim_standalone
# Include the shell for testing purposes # Include the shell for testing purposes
USEMODULE += shell USEMODULE += shell

View File

@ -5,6 +5,7 @@ PSEUDOMODULES += can_pm
PSEUDOMODULES += can_raw PSEUDOMODULES += can_raw
PSEUDOMODULES += ccn-lite-utils PSEUDOMODULES += ccn-lite-utils
PSEUDOMODULES += conn_can_isotp_multi PSEUDOMODULES += conn_can_isotp_multi
PSEUDOMODULES += cord_epsim_standalone
PSEUDOMODULES += core_% PSEUDOMODULES += core_%
PSEUDOMODULES += ecc_% PSEUDOMODULES += ecc_%
PSEUDOMODULES += emb6_router PSEUDOMODULES += emb6_router
@ -53,7 +54,6 @@ PSEUDOMODULES += printf_float
PSEUDOMODULES += prng PSEUDOMODULES += prng
PSEUDOMODULES += prng_% PSEUDOMODULES += prng_%
PSEUDOMODULES += rdcli_standalone PSEUDOMODULES += rdcli_standalone
PSEUDOMODULES += rdcli_simple_standalone
PSEUDOMODULES += saul_adc PSEUDOMODULES += saul_adc
PSEUDOMODULES += saul_default PSEUDOMODULES += saul_default
PSEUDOMODULES += saul_gpio PSEUDOMODULES += saul_gpio

View File

@ -130,7 +130,7 @@ endif
ifneq (,$(filter cord_common,$(USEMODULE))) ifneq (,$(filter cord_common,$(USEMODULE)))
DIRS += net/application_layer/cord/common DIRS += net/application_layer/cord/common
endif endif
ifneq (,$(filter rdcli_simple,$(USEMODULE))) ifneq (,$(filter cord_epsim,$(USEMODULE)))
DIRS += net/application_layer/cord/epsim DIRS += net/application_layer/cord/epsim
endif endif
ifneq (,$(filter rdcli,$(USEMODULE))) ifneq (,$(filter rdcli,$(USEMODULE)))

View File

@ -168,10 +168,10 @@ void auto_init(void)
extern void rdcli_standalone_run(void); extern void rdcli_standalone_run(void);
rdcli_standalone_run(); rdcli_standalone_run();
#endif #endif
#ifdef MODULE_RDCLI_SIMPLE_STANDALONE #ifdef MODULE_CORD_EPSIM_STANDALONE
DEBUG("Auto init rdcli_simple module\n"); DEBUG("Auto init cord_epsim module\n");
extern void rdcli_simple_run(void); extern void cord_epsim_run(void);
rdcli_simple_run(); cord_epsim_run();
#endif #endif
#ifdef MODULE_ASYMCUTE #ifdef MODULE_ASYMCUTE
DEBUG("Auto init Asymcute\n"); DEBUG("Auto init Asymcute\n");

View File

@ -0,0 +1,68 @@
/*
* Copyright (C) 2017-2018 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup net_cord_epsim CoRE RD Simple Registration Endpoint
* @ingroup net_cord
* @brief CoRE Resource Directory endpoint using the simple registration
* procedure
* @{
*
* @file
* @brief Interface for the CoRE RD simple registration endpoint
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
#ifndef NET_CORD_EPSIM_H
#define NET_CORD_EPSIM_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Error codes used by the cord_epsim implementation
*/
enum {
CORD_EPSIM_OK = 0, /**< all good */
CORD_EPSIM_NOADDR = -1, /**< on address conversion errors */
CORD_EPSIM_ERROR = -2, /**< on other errors */
};
/**
* @brief Initiate the node registration by sending an empty CoAP POST message
* to the RD server's /.well-known/core resource
*
* @return CORD_EPSIM_OK on success
* @return CORD_EPSIM_NOADDR if conversion of RD address fails
* @return CORD_EPSIM_ERROR if something goes wrong preparing or sending the
* initial request
*/
int cord_epsim_register(void);
#if defined(MODULE_CORD_EPSIM_STANDALONE) || defined(DOXYGEN)
/**
* @brief Spawn a new thread that registers the node and updates the
* registration with all responding RDs using the simple registration
* process
*
* @note Only available with the `cord_epsim_standalone` module compiled in
*
* @warning This function must only be called once (typically during system
* initialization)
*/
void cord_epsim_run(void);
#endif
#ifdef __cplusplus
}
#endif
#endif /* NET_CORD_EPSIM_H */
/** @} */

View File

@ -1,61 +0,0 @@
/*
* Copyright (C) 2017-2018 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup net_rdcli_simple CoRE RD Simple Client
* @ingroup net
* @brief CoAP-based CoRE Resource Directory client supporting the simple
* registration only
* @{
*
* @file
* @brief Interface for a simple CoRE RD registration
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
#ifndef NET_RDCLI_SIMPLE_H
#define NET_RDCLI_SIMPLE_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Error codes used by the rdcli_simple implementation
*/
enum {
RDCLI_SIMPLE_OK = 0, /**< all good */
RDCLI_SIMPLE_NOADDR = -1, /**< on address conversion errors */
RDCLI_SIMPLE_ERROR = -2, /**< on other errors */
};
/**
* @brief Initiate the node registration by sending an empty CoAP POST message
* to the RD server's /.well-known/core resource
*
* @return RDCLI_SIMPLE_OK on success
* @return RDCLI_SIMPLE_NOADDR if conversion of RD address fails
* @return RDCLI_SIMPLE_ERROR if something goes wrong preparing or sending the
* initial request
*/
int rdcli_simple_register(void);
/**
* @brief Spawn a new thread that registers the node and updates the
* registration with all responding RDs using the simple registration
* process
*/
void rdcli_simple_run(void);
#ifdef __cplusplus
}
#endif
#endif /* NET_RDCLI_SIMPLE_H */
/** @} */

View File

@ -1,9 +1,9 @@
MODULE = rdcli_simple MODULE = cord_epsim
SRC = rdcli_simple.c SRC = cord_epsim.c
ifneq (,$(filter rdcli_simple_standalone,$(USEMODULE))) ifneq (,$(filter cord_epsim_standalone,$(USEMODULE)))
SRC += rdcli_simple_standalone.c SRC += cord_epsim_standalone.c
endif endif
include $(RIOTBASE)/Makefile.base include $(RIOTBASE)/Makefile.base

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2017 Freie Universität Berlin * Copyright (C) 2017-2018 Freie Universität Berlin
* *
* This file is subject to the terms and conditions of the GNU Lesser * This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level * General Public License v2.1. See the file LICENSE in the top level
@ -7,11 +7,11 @@
*/ */
/** /**
* @ingroup net_rdcli_simple * @ingroup net_cord_epsim
* @{ * @{
* *
* @file * @file
* @brief Simplified CoAP resource directory client implementation * @brief CoRE RD simple registration endpoint implementation
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* *
@ -20,11 +20,10 @@
#include <string.h> #include <string.h>
#include "fmt.h"
#include "net/gcoap.h" #include "net/gcoap.h"
#include "net/cord/epsim.h"
#include "net/cord/config.h" #include "net/cord/config.h"
#include "net/cord/common.h" #include "net/cord/common.h"
#include "net/rdcli_simple.h"
#include "net/ipv6/addr.h" #include "net/ipv6/addr.h"
#define BUFSIZE (128U) #define BUFSIZE (128U)
@ -34,7 +33,7 @@
static coap_pkt_t pkt; static coap_pkt_t pkt;
static uint8_t buf[BUFSIZE]; static uint8_t buf[BUFSIZE];
int rdcli_simple_register(void) int cord_epsim_register(void)
{ {
sock_udp_ep_t remote = { sock_udp_ep_t remote = {
.family = AF_INET6, .family = AF_INET6,
@ -44,26 +43,26 @@ int rdcli_simple_register(void)
/* parse RD server address */ /* parse RD server address */
if (ipv6_addr_from_str((ipv6_addr_t *)&remote.addr.ipv6, if (ipv6_addr_from_str((ipv6_addr_t *)&remote.addr.ipv6,
RDCLI_SERVER_ADDR) == NULL) { CORD_SERVER_ADDR) == NULL) {
return RDCLI_SIMPLE_NOADDR; return CORD_EPSIM_NOADDR;
} }
/* build the initial CON packet */ /* build the initial CON packet */
if (gcoap_req_init(&pkt, buf, sizeof(buf), COAP_METHOD_POST, if (gcoap_req_init(&pkt, buf, sizeof(buf), COAP_METHOD_POST,
"/.well-known/core") < 0) { "/.well-known/core") < 0) {
return RDCLI_SIMPLE_ERROR; return CORD_EPSIM_ERROR;
} }
/* make packet confirmable */ /* make packet confirmable */
coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON); coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON);
/* add Uri-Query options */ /* add Uri-Query options */
if (cord_common_add_qstring(&pkt) < 0) { if (cord_common_add_qstring(&pkt) < 0) {
return RDCLI_SIMPLE_ERROR; return CORD_EPSIM_ERROR;
} }
/* finish, we don't have any payload */ /* finish, we don't have any payload */
ssize_t len = gcoap_finish(&pkt, 0, COAP_FORMAT_NONE); ssize_t len = gcoap_finish(&pkt, 0, COAP_FORMAT_NONE);
if (gcoap_req_send2(buf, len, &remote, NULL) == 0) { if (gcoap_req_send2(buf, len, &remote, NULL) == 0) {
return RDCLI_SIMPLE_ERROR; return CORD_EPSIM_ERROR;
} }
return RDCLI_SIMPLE_OK; return CORD_EPSIM_OK;
} }

View File

@ -7,11 +7,11 @@
*/ */
/** /**
* @ingroup net_rdcli_simple * @ingroup net_cord_epsim
* @{ * @{
* *
* @file * @file
* @brief Standalone extension for the simple RD registration client * @brief Standalone extension for the simple RD registration endpoint
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* *
@ -21,12 +21,12 @@
#include "log.h" #include "log.h"
#include "thread.h" #include "thread.h"
#include "xtimer.h" #include "xtimer.h"
#include "net/cord/epsim.h"
#include "net/cord/config.h" #include "net/cord/config.h"
#include "net/rdcli_simple.h"
#define STACKSIZE (THREAD_STACKSIZE_DEFAULT) #define STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#define PRIO (THREAD_PRIORITY_MAIN - 1) #define PRIO (THREAD_PRIORITY_MAIN - 1)
#define TNAME "rdcli_simple" #define TNAME "cord_epsim"
static char _stack[STACKSIZE]; static char _stack[STACKSIZE];
@ -38,10 +38,10 @@ static void *reg_runner(void *arg)
xtimer_sleep(CORD_STARTUP_DELAY); xtimer_sleep(CORD_STARTUP_DELAY);
while (1) { while (1) {
if (rdcli_simple_register() != RDCLI_SIMPLE_OK) { if (cord_epsim_register() != CORD_EPSIM_OK) {
/* if this fails once, it will always fail, so we might as well /* if this fails once, it will always fail, so we might as well
* quit now */ * quit now */
LOG_ERROR("[rdcli_simple] error: unable to send registration\n"); LOG_ERROR("[cord_epsim] error: unable to send registration\n");
break; break;
} }
xtimer_sleep(CORD_UPDATE_INTERVAL); xtimer_sleep(CORD_UPDATE_INTERVAL);
@ -50,7 +50,9 @@ static void *reg_runner(void *arg)
return NULL; return NULL;
} }
void rdcli_simple_run(void) #ifdef MODULE_CORD_EPSIM_STANDALONE
void cord_epsim_run(void)
{ {
thread_create(_stack, sizeof(_stack), PRIO, 0, reg_runner, NULL, TNAME); thread_create(_stack, sizeof(_stack), PRIO, 0, reg_runner, NULL, TNAME);
} }
#endif