mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
net/rdcli_simple: rename to cord_epsim
This commit is contained in:
parent
152623577e
commit
226b9fa383
@ -749,14 +749,14 @@ ifneq (,$(filter skald,$(USEMODULE)))
|
||||
USEMODULE += random
|
||||
endif
|
||||
|
||||
ifneq (,$(filter rdcli_simple_standalone,$(USEMODULE)))
|
||||
USEMODULE += rdcli_simple
|
||||
ifneq (,$(filter cord_epsim_standalone,$(USEMODULE)))
|
||||
USEMODULE += cord_epsim
|
||||
USEMODULE += xtimer
|
||||
endif
|
||||
|
||||
ifneq (,$(filter rdcli_simple,$(USEMODULE)))
|
||||
ifneq (,$(filter cord_epsim,$(USEMODULE)))
|
||||
USEMODULE += cord_common
|
||||
USEMODULE += fmt
|
||||
USEMODULE += gcoap
|
||||
endif
|
||||
|
||||
ifneq (,$(filter rdcli_standalone,$(USEMODULE)))
|
||||
@ -776,7 +776,6 @@ endif
|
||||
|
||||
ifneq (,$(filter cord_common,$(USEMODULE)))
|
||||
USEMODULE += fmt
|
||||
USEMODULE += gcoap
|
||||
USEMODULE += luid
|
||||
endif
|
||||
|
||||
|
@ -20,7 +20,7 @@ USEMODULE += auto_init_gnrc_netif
|
||||
USEMODULE += gnrc_ipv6_default
|
||||
|
||||
# Run the simple CoRE resource directory
|
||||
USEMODULE += rdcli_simple_standalone
|
||||
USEMODULE += cord_epsim_standalone
|
||||
|
||||
# Include the shell for testing purposes
|
||||
USEMODULE += shell
|
||||
|
@ -5,6 +5,7 @@ PSEUDOMODULES += can_pm
|
||||
PSEUDOMODULES += can_raw
|
||||
PSEUDOMODULES += ccn-lite-utils
|
||||
PSEUDOMODULES += conn_can_isotp_multi
|
||||
PSEUDOMODULES += cord_epsim_standalone
|
||||
PSEUDOMODULES += core_%
|
||||
PSEUDOMODULES += ecc_%
|
||||
PSEUDOMODULES += emb6_router
|
||||
@ -53,7 +54,6 @@ PSEUDOMODULES += printf_float
|
||||
PSEUDOMODULES += prng
|
||||
PSEUDOMODULES += prng_%
|
||||
PSEUDOMODULES += rdcli_standalone
|
||||
PSEUDOMODULES += rdcli_simple_standalone
|
||||
PSEUDOMODULES += saul_adc
|
||||
PSEUDOMODULES += saul_default
|
||||
PSEUDOMODULES += saul_gpio
|
||||
|
@ -130,7 +130,7 @@ endif
|
||||
ifneq (,$(filter cord_common,$(USEMODULE)))
|
||||
DIRS += net/application_layer/cord/common
|
||||
endif
|
||||
ifneq (,$(filter rdcli_simple,$(USEMODULE)))
|
||||
ifneq (,$(filter cord_epsim,$(USEMODULE)))
|
||||
DIRS += net/application_layer/cord/epsim
|
||||
endif
|
||||
ifneq (,$(filter rdcli,$(USEMODULE)))
|
||||
|
@ -168,10 +168,10 @@ void auto_init(void)
|
||||
extern void rdcli_standalone_run(void);
|
||||
rdcli_standalone_run();
|
||||
#endif
|
||||
#ifdef MODULE_RDCLI_SIMPLE_STANDALONE
|
||||
DEBUG("Auto init rdcli_simple module\n");
|
||||
extern void rdcli_simple_run(void);
|
||||
rdcli_simple_run();
|
||||
#ifdef MODULE_CORD_EPSIM_STANDALONE
|
||||
DEBUG("Auto init cord_epsim module\n");
|
||||
extern void cord_epsim_run(void);
|
||||
cord_epsim_run();
|
||||
#endif
|
||||
#ifdef MODULE_ASYMCUTE
|
||||
DEBUG("Auto init Asymcute\n");
|
||||
|
68
sys/include/net/cord/epsim.h
Normal file
68
sys/include/net/cord/epsim.h
Normal 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 */
|
||||
/** @} */
|
@ -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 */
|
||||
/** @} */
|
@ -1,9 +1,9 @@
|
||||
MODULE = rdcli_simple
|
||||
MODULE = cord_epsim
|
||||
|
||||
SRC = rdcli_simple.c
|
||||
SRC = cord_epsim.c
|
||||
|
||||
ifneq (,$(filter rdcli_simple_standalone,$(USEMODULE)))
|
||||
SRC += rdcli_simple_standalone.c
|
||||
ifneq (,$(filter cord_epsim_standalone,$(USEMODULE)))
|
||||
SRC += cord_epsim_standalone.c
|
||||
endif
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
@ -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
|
||||
* 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
|
||||
* @brief Simplified CoAP resource directory client implementation
|
||||
* @brief CoRE RD simple registration endpoint implementation
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
*
|
||||
@ -20,11 +20,10 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "fmt.h"
|
||||
#include "net/gcoap.h"
|
||||
#include "net/cord/epsim.h"
|
||||
#include "net/cord/config.h"
|
||||
#include "net/cord/common.h"
|
||||
#include "net/rdcli_simple.h"
|
||||
#include "net/ipv6/addr.h"
|
||||
|
||||
#define BUFSIZE (128U)
|
||||
@ -34,7 +33,7 @@
|
||||
static coap_pkt_t pkt;
|
||||
static uint8_t buf[BUFSIZE];
|
||||
|
||||
int rdcli_simple_register(void)
|
||||
int cord_epsim_register(void)
|
||||
{
|
||||
sock_udp_ep_t remote = {
|
||||
.family = AF_INET6,
|
||||
@ -44,26 +43,26 @@ int rdcli_simple_register(void)
|
||||
|
||||
/* parse RD server address */
|
||||
if (ipv6_addr_from_str((ipv6_addr_t *)&remote.addr.ipv6,
|
||||
RDCLI_SERVER_ADDR) == NULL) {
|
||||
return RDCLI_SIMPLE_NOADDR;
|
||||
CORD_SERVER_ADDR) == NULL) {
|
||||
return CORD_EPSIM_NOADDR;
|
||||
}
|
||||
|
||||
/* build the initial CON packet */
|
||||
if (gcoap_req_init(&pkt, buf, sizeof(buf), COAP_METHOD_POST,
|
||||
"/.well-known/core") < 0) {
|
||||
return RDCLI_SIMPLE_ERROR;
|
||||
return CORD_EPSIM_ERROR;
|
||||
}
|
||||
/* make packet confirmable */
|
||||
coap_hdr_set_type(pkt.hdr, COAP_TYPE_CON);
|
||||
/* add Uri-Query options */
|
||||
if (cord_common_add_qstring(&pkt) < 0) {
|
||||
return RDCLI_SIMPLE_ERROR;
|
||||
return CORD_EPSIM_ERROR;
|
||||
}
|
||||
/* finish, we don't have any payload */
|
||||
ssize_t len = gcoap_finish(&pkt, 0, COAP_FORMAT_NONE);
|
||||
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;
|
||||
}
|
@ -7,11 +7,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup net_rdcli_simple
|
||||
* @ingroup net_cord_epsim
|
||||
* @{
|
||||
*
|
||||
* @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>
|
||||
*
|
||||
@ -21,12 +21,12 @@
|
||||
#include "log.h"
|
||||
#include "thread.h"
|
||||
#include "xtimer.h"
|
||||
#include "net/cord/epsim.h"
|
||||
#include "net/cord/config.h"
|
||||
#include "net/rdcli_simple.h"
|
||||
|
||||
#define STACKSIZE (THREAD_STACKSIZE_DEFAULT)
|
||||
#define PRIO (THREAD_PRIORITY_MAIN - 1)
|
||||
#define TNAME "rdcli_simple"
|
||||
#define TNAME "cord_epsim"
|
||||
|
||||
static char _stack[STACKSIZE];
|
||||
|
||||
@ -38,10 +38,10 @@ static void *reg_runner(void *arg)
|
||||
xtimer_sleep(CORD_STARTUP_DELAY);
|
||||
|
||||
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
|
||||
* quit now */
|
||||
LOG_ERROR("[rdcli_simple] error: unable to send registration\n");
|
||||
LOG_ERROR("[cord_epsim] error: unable to send registration\n");
|
||||
break;
|
||||
}
|
||||
xtimer_sleep(CORD_UPDATE_INTERVAL);
|
||||
@ -50,7 +50,9 @@ static void *reg_runner(void *arg)
|
||||
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);
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user