diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index f2cff24..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "RIOT"] - path = RIOT - url = https://github.com/AlexFuhr/RIOT.git \ No newline at end of file diff --git a/Makefile b/Makefile index ab1594b..48422e9 100644 --- a/Makefile +++ b/Makefile @@ -1,63 +1 @@ -# name of your application -APPLICATION = saul_coap - -# If no BOARD is found in the environment, use this default: -BOARD ?= native - -# This has to be the absolute path to the RIOT base directory: -RIOTBASE ?= $(CURDIR)/RIOT - -BOARD_INSUFFICIENT_MEMORY := arduino-duemilanove arduino-leonardo arduino-nano \ - arduino-uno - -# Include packages that pull up and auto-init the link layer. -# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present -USEMODULE += gnrc_netdev_default -USEMODULE += auto_init_gnrc_netif -# Specify the mandatory networking modules -USEMODULE += gnrc_ipv6_default -USEMODULE += gcoap -# Additional networking modules that can be dropped if not needed -USEMODULE += gnrc_icmpv6_echo -USEMODULE += gnrc_icmpv6_error - -# Specify the mandatory networking modules for IPv6 routing -USEMODULE += gnrc_ipv6_router_default - -# Required by gcoap example -USEMODULE += od -USEMODULE += fmt - -# we want to use SAUL: -USEMODULE += saul_default -# include the shell: -USEMODULE += shell -USEMODULE += shell_commands -# additional modules for debugging: -USEMODULE += ps - -# Module for registering to Resource Directory (RD) -USEMODULE += cord_ep - -# needed so that the board can be reached -USEMODULE += netstats_l2 -# -# Include tinycbor for data representation -USEPKG += tinycbor -INCLUDE += $(RIOTPKG)/tinycbor/cbor.h - -CFLAGS += -DGNRC_IPV6_NIB_CONF_SLAAC=1 - -# For debugging and demonstration purposes the lifetime is limited to 30s -CFLAGS += -DCORD_LT=30 - -# Comment this out to disable code in RIOT that does safety checking -# which is not needed in a production environment but helps in the -# development process: -DEVELHELP ?= 1 - -# Change this to 0 show compiler invocation lines by default: -QUIET ?= 1 - -include $(RIOTBASE)/Makefile.include - +include $(RIOTBASE)/Makefile.base diff --git a/Makefile.dep b/Makefile.dep new file mode 100644 index 0000000..3618adb --- /dev/null +++ b/Makefile.dep @@ -0,0 +1,40 @@ +# Include packages that pull up and auto-init the link layer. +# NOTE: 6LoWPAN will be included if IEEE802.15.4 devices are present +USEMODULE += gnrc_netdev_default +USEMODULE += auto_init_gnrc_netif +# Specify the mandatory networking modules +USEMODULE += gnrc_ipv6_default +USEMODULE += gcoap +# Additional networking modules that can be dropped if not needed +USEMODULE += gnrc_icmpv6_echo +USEMODULE += gnrc_icmpv6_error + +# Specify the mandatory networking modules for IPv6 routing +USEMODULE += gnrc_ipv6_router_default + +# Required by gcoap example +USEMODULE += od +USEMODULE += fmt + +# we want to use SAUL: +USEMODULE += saul_default +# include the shell: +USEMODULE += shell +USEMODULE += shell_commands +# additional modules for debugging: +USEMODULE += ps + +# Module for registering to Resource Directory (RD) +USEMODULE += cord_ep + +# needed so that the board can be reached +USEMODULE += netstats_l2 +# +# Include tinycbor for data representation +USEPKG += tinycbor +INCLUDE += $(RIOTPKG)/tinycbor/cbor.h + +CFLAGS += -DGNRC_IPV6_NIB_CONF_SLAAC=1 + +# For debugging and demonstration purposes the lifetime is limited to 30s +CFLAGS += -DCORD_LT=30 diff --git a/Makefile.include b/Makefile.include new file mode 100644 index 0000000..4617d4c --- /dev/null +++ b/Makefile.include @@ -0,0 +1,3 @@ +# Use an immediate variable to evaluate `MAKEFILE_LIST` now +USEMODULE_INCLUDES_saul_coap := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) +USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_saul_coap) \ No newline at end of file diff --git a/RIOT b/RIOT deleted file mode 160000 index b38f48a..0000000 --- a/RIOT +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b38f48a72009141cbce3a0f01c09cc1a7ef0275b diff --git a/main.c b/main.c deleted file mode 100644 index 7fac83e..0000000 --- a/main.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2019 HAW Hamburg - * - * 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. - */ - -/** - * @ingroup pkg - * @{ - * - * @file - * @brief CoAP endpoint for the SAUL registry - * - * @author Micha Rosenbaum - * - * @} - */ - -#include -#include "msg.h" -#include "shell.h" -#include "saul_cord_ep.h" - -#define MAIN_QUEUE_SIZE (4) -#define CORD_EP_ADDRESS "[fdaa:bb:cc:dd::1]:5683" - -static msg_t _main_msg_queue[MAIN_QUEUE_SIZE]; - -extern void saul_coap_init(void); - -/* we will use custom event handler for dumping cord_ep events */ -static void _on_ep_event(saul_cord_ep_event_t event) -{ - switch (event) { - case SAUL_CORD_EP_REGISTERED: - puts("DEBUG: Registered successfully with RD"); - break; - case SAUL_CORD_EP_DEREGISTERED: - puts("DEBUG: Deregistered from RD"); - break; - case SAUL_CORD_EP_UPDATED: - puts("DEBUG: Updated successfully the client registration"); - break; - } -} - -int main(void) -{ - puts("Welcome to RIOT!\n"); - puts("Type `help` for help, type `saul` to see all SAUL devices\n"); - - saul_coap_init(); - - msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE); - - saul_cord_ep_register_cb(_on_ep_event); - saul_cord_ep_create(CORD_EP_ADDRESS); - saul_cord_ep_run(); - - char line_buf[SHELL_DEFAULT_BUFSIZE]; - shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); - - return 0; -} - diff --git a/saul_coap.c b/saul_coap.c index 5f18787..992f188 100644 --- a/saul_coap.c +++ b/saul_coap.c @@ -26,6 +26,8 @@ #include "net/gcoap.h" #include "cbor.h" +#include "saul_coap.h" + static ssize_t _saul_cnt_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, void *ctx); static ssize_t _saul_dev_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, void *ctx); static ssize_t _saul_sensortype_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, void *ctx); diff --git a/saul_coap.h b/saul_coap.h new file mode 100644 index 0000000..5519f10 --- /dev/null +++ b/saul_coap.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2019 HAW Hamburg + * + * 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. + * + * @ingroup pkg + * @{ + * + * @file + * @brief Adapt SAUL registry for CoAP. + * + * @author Micha Rosenbaum + * + * @} + */ +#ifndef SAUL_COAP_H +#define SAUL_COAP_H + +#ifdef __cplusplus + extern "C" { +#endif + +/** + * @brief Initialize and register the saul-coap resources. + * + * @warning This function must only be called once (typically during system + * initialization) + */ +void saul_coap_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* SAUL_COAP_H */