mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Add libcoap as BSD ports-like package
This commit is contained in:
parent
82af516691
commit
55b1c27c38
1
pkg/libcoap/.gitignore
vendored
Normal file
1
pkg/libcoap/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
libcoap
|
34
pkg/libcoap/Makefile
Normal file
34
pkg/libcoap/Makefile
Normal file
@ -0,0 +1,34 @@
|
||||
PKG_NAME=libcoap
|
||||
PKG_URL=http://git.code.sf.net/p/libcoap/code
|
||||
PKG_VERSION=89acaa6775ca3a4aedea510557e6b9c0c01fa5db
|
||||
|
||||
ifneq ($(RIOTBOARD),)
|
||||
include $(RIOTBOARD)/$(BOARD)/Makefile.include
|
||||
endif
|
||||
|
||||
ifneq ($(RIOTBASE),)
|
||||
INCLUDES += -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/sys/net/include \
|
||||
-I$(RIOTBASE)/sys/posix/include -I$(RIOTBASE)/sys/posix/pnet/include
|
||||
endif
|
||||
|
||||
.PHONY: all clean patch reset
|
||||
|
||||
all: patch
|
||||
make -C $(CURDIR)/$(PKG_NAME)
|
||||
|
||||
patch: $(CURDIR)/$(PKG_NAME)/Makefile
|
||||
|
||||
$(CURDIR)/$(PKG_NAME)/Makefile: $(CURDIR)/$(PKG_NAME)
|
||||
cd $< && git apply ../patch.txt
|
||||
|
||||
$(CURDIR)/$(PKG_NAME):
|
||||
git clone $(PKG_URL) $@ && \
|
||||
cd $@ && git checkout $(PKG_VERSION)
|
||||
|
||||
clean::
|
||||
cd $(CURDIR)/$(PKG_NAME) && \
|
||||
git clean -x -f && \
|
||||
git reset --hard $(PKG_VERSION) || true
|
||||
|
||||
distclean::
|
||||
rm -rf $(CURDIR)/$(PKG_NAME)
|
562
pkg/libcoap/patch.txt
Normal file
562
pkg/libcoap/patch.txt
Normal file
@ -0,0 +1,562 @@
|
||||
diff --git a/Makefile b/Makefile
|
||||
new file mode 100644
|
||||
index 0000000..016d716
|
||||
--- /dev/null
|
||||
+++ b/Makefile
|
||||
@@ -0,0 +1,4 @@
|
||||
+MODULE:=$(shell basename $(CURDIR))
|
||||
+INCLUDES += -I$(RIOTBASE) -I$(RIOTBASE)/sys/include -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/drivers/cc110x_ng/include -I$(RIOTBASE)/cpu/arm_common/include -I$(RIOTBASE)/sys/net/destiny/include -I$(RIOTBASE)/sys/net/sixlowpan/include/ -I$(RIOTBASE)/sys/net/ieee802154/include -I$(RIOTBASE)/sys/net/net_help -I$(RIOTBASE)/sys/posix/include -I$(RIOTBASE)/sys/posix/pnet/include
|
||||
+
|
||||
+include $(RIOTBASE)/Makefile.base
|
||||
diff --git a/coap-observer.c b/coap-observer.c
|
||||
deleted file mode 100644
|
||||
index e4b2fe5..0000000
|
||||
--- a/coap-observer.c
|
||||
+++ /dev/null
|
||||
@@ -1,185 +0,0 @@
|
||||
-/* coap-server.c -- Example CoAP server using Contiki and libcoap
|
||||
- *
|
||||
- * Copyright (C) 2011 Olaf Bergmann <bergmann@tzi.org>
|
||||
- *
|
||||
- * Redistribution and use in source and binary forms, with or without
|
||||
- * modification, are permitted provided that the following conditions
|
||||
- * are met:
|
||||
- * 1. Redistributions of source code must retain the above copyright
|
||||
- * notice, this list of conditions and the following disclaimer.
|
||||
- * 2. Redistributions in binary form must reproduce the above copyright
|
||||
- * notice, this list of conditions and the following disclaimer in the
|
||||
- * documentation and/or other materials provided with the distribution.
|
||||
- * 3. Neither the name of the Institute nor the names of its contributors
|
||||
- * may be used to endorse or promote products derived from this software
|
||||
- * without specific prior written permission.
|
||||
- *
|
||||
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
- * SUCH DAMAGE.
|
||||
- *
|
||||
- * This file is part of the Contiki operating system.
|
||||
- *
|
||||
- */
|
||||
-
|
||||
-#include "config.h"
|
||||
-#include "net/uip-debug.h"
|
||||
-
|
||||
-#include <string.h>
|
||||
-
|
||||
-#include "debug.h"
|
||||
-#include "coap.h"
|
||||
-
|
||||
-static coap_context_t *coap_context;
|
||||
-
|
||||
-/* Where the resource to subscribe is hosted */
|
||||
-static coap_address_t dst;
|
||||
-
|
||||
-/* The resource to observe */
|
||||
-static char resource[] = "/s/light";
|
||||
-
|
||||
-/* when did the last notify arrive? (0 == never) */
|
||||
-static coap_tick_t last_seen = 0;
|
||||
-
|
||||
-PROCESS(coap_server_process, "CoAP server process");
|
||||
-AUTOSTART_PROCESSES(&coap_server_process);
|
||||
-/*---------------------------------------------------------------------------*/
|
||||
-void
|
||||
-init_coap() {
|
||||
- coap_address_t listen_addr;
|
||||
-
|
||||
- coap_address_init(&listen_addr);
|
||||
- listen_addr.port = UIP_HTONS(COAP_DEFAULT_PORT);
|
||||
-
|
||||
-#ifdef WITH_CONTIKI
|
||||
- /* initialize uIP address for SLAAC */
|
||||
- uip_ip6addr(&listen_addr.addr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
||||
- uip_ds6_set_addr_iid(&listen_addr.addr, &uip_lladdr);
|
||||
- uip_ds6_addr_add(&listen_addr.addr, 0, ADDR_AUTOCONF);
|
||||
-
|
||||
- uip_debug_lladdr_print(&uip_lladdr);
|
||||
- printf("\r\n");
|
||||
- uip_debug_ipaddr_print(&listen_addr.addr);
|
||||
- printf("\r\n");
|
||||
-#endif /* WITH_CONTIKI */
|
||||
-
|
||||
-#ifdef WITH_CONTIKI
|
||||
- printf("tentative address: [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d\r\n",
|
||||
- listen_addr.addr.u8[0], listen_addr.addr.u8[1],
|
||||
- listen_addr.addr.u8[2], listen_addr.addr.u8[3],
|
||||
- listen_addr.addr.u8[4], listen_addr.addr.u8[5],
|
||||
- listen_addr.addr.u8[6], listen_addr.addr.u8[7],
|
||||
- listen_addr.addr.u8[8], listen_addr.addr.u8[9],
|
||||
- listen_addr.addr.u8[10], listen_addr.addr.u8[11],
|
||||
- listen_addr.addr.u8[12], listen_addr.addr.u8[13],
|
||||
- listen_addr.addr.u8[14], listen_addr.addr.u8[15] ,
|
||||
- uip_ntohs(listen_addr.port));
|
||||
-#endif
|
||||
-
|
||||
- coap_context = coap_new_context(&listen_addr);
|
||||
-
|
||||
- coap_set_log_level(LOG_DEBUG);
|
||||
-
|
||||
- if (!coap_context)
|
||||
- coap_log(LOG_CRIT, "cannot create CoAP context\r\n");
|
||||
-}
|
||||
-
|
||||
-void
|
||||
-message_handler(struct coap_context_t *ctx,
|
||||
- const coap_address_t *remote,
|
||||
- coap_pdu_t *sent,
|
||||
- coap_pdu_t *received,
|
||||
- const coap_tid_t id) {
|
||||
- /* send ACK if received message is confirmable (i.e. a separate response) */
|
||||
- coap_send_ack(ctx, remote, received);
|
||||
-
|
||||
- debug("** process incoming %d.%02d response:\n",
|
||||
- (received->hdr->code >> 5), received->hdr->code & 0x1F);
|
||||
- coap_show_pdu(received);
|
||||
-
|
||||
- coap_ticks(&last_seen);
|
||||
-}
|
||||
-
|
||||
-/*---------------------------------------------------------------------------*/
|
||||
-PROCESS_THREAD(coap_server_process, ev, data)
|
||||
-{
|
||||
- coap_pdu_t *request;
|
||||
- coap_uri_t uri;
|
||||
- PROCESS_BEGIN();
|
||||
-
|
||||
- init_coap();
|
||||
-
|
||||
- if (!coap_context) {
|
||||
- coap_log(LOG_EMERG, "cannot create context\n");
|
||||
- PROCESS_EXIT();
|
||||
- }
|
||||
-
|
||||
- coap_register_response_handler(coap_context, message_handler);
|
||||
-
|
||||
- /* setup subscription request */
|
||||
-
|
||||
- coap_address_init(&dst);
|
||||
- dst.port = uip_htons(COAP_DEFAULT_PORT);
|
||||
- uip_ip6addr(&dst.addr, 0xaaaa, 0, 0, 0, 0x206, 0x98ff, 0xfe00, 0x232);
|
||||
- /* uip_ip6addr(&dst.addr, 0xfe80, 0, 0, 0, 0x206, 0x98ff, 0xfe00, 0x232); */
|
||||
-
|
||||
- request = coap_pdu_init(COAP_MESSAGE_CON, COAP_REQUEST_GET,
|
||||
- coap_new_message_id(coap_context),
|
||||
- COAP_MAX_PDU_SIZE);
|
||||
-
|
||||
- coap_split_uri((unsigned char *)resource, strlen(resource), &uri);
|
||||
-
|
||||
- if (uri.port != COAP_DEFAULT_PORT) {
|
||||
- unsigned char portbuf[2];
|
||||
- coap_add_option(request, COAP_OPTION_URI_PORT,
|
||||
- coap_encode_var_bytes(portbuf, uri.port), portbuf);
|
||||
- }
|
||||
-
|
||||
- if (uri.path.length) {
|
||||
-#define BUFSIZE 20
|
||||
- unsigned char _buf[BUFSIZE];
|
||||
- unsigned char *buf = _buf;
|
||||
- size_t buflen;
|
||||
- int res;
|
||||
-
|
||||
- buflen = BUFSIZE;
|
||||
-#undef BUFSIZE
|
||||
- res = coap_split_path(uri.path.s, uri.path.length, buf, &buflen);
|
||||
-
|
||||
- while (res--) {
|
||||
- coap_add_option(request, COAP_OPTION_URI_PATH,
|
||||
- COAP_OPT_LENGTH(buf), COAP_OPT_VALUE(buf));
|
||||
-
|
||||
- buf += COAP_OPT_SIZE(buf);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- coap_add_option(request, COAP_OPTION_SUBSCRIPTION, 0, NULL);
|
||||
- {
|
||||
- unsigned char buf[2];
|
||||
- prng(buf, 2);
|
||||
- coap_add_option(request, COAP_OPTION_TOKEN, 2, buf);
|
||||
- }
|
||||
-
|
||||
- if (COAP_INVALID_TID == coap_send_confirmed(coap_context, &dst, request))
|
||||
- coap_delete_pdu(request);
|
||||
-
|
||||
- while(1) {
|
||||
- PROCESS_YIELD();
|
||||
- if(ev == tcpip_event) {
|
||||
- coap_read(coap_context); /* read received data */
|
||||
- coap_dispatch(coap_context); /* and dispatch PDUs from receivequeue */
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- PROCESS_END();
|
||||
-}
|
||||
-/*---------------------------------------------------------------------------*/
|
||||
diff --git a/coap-server.c b/coap-server.c
|
||||
deleted file mode 100644
|
||||
index 5dcdfcd..0000000
|
||||
--- a/coap-server.c
|
||||
+++ /dev/null
|
||||
@@ -1,220 +0,0 @@
|
||||
-/* coap-server.c -- Example CoAP server using Contiki and libcoap
|
||||
- *
|
||||
- * Copyright (C) 2011 Olaf Bergmann <bergmann@tzi.org>
|
||||
- *
|
||||
- * Redistribution and use in source and binary forms, with or without
|
||||
- * modification, are permitted provided that the following conditions
|
||||
- * are met:
|
||||
- * 1. Redistributions of source code must retain the above copyright
|
||||
- * notice, this list of conditions and the following disclaimer.
|
||||
- * 2. Redistributions in binary form must reproduce the above copyright
|
||||
- * notice, this list of conditions and the following disclaimer in the
|
||||
- * documentation and/or other materials provided with the distribution.
|
||||
- * 3. Neither the name of the Institute nor the names of its contributors
|
||||
- * may be used to endorse or promote products derived from this software
|
||||
- * without specific prior written permission.
|
||||
- *
|
||||
- * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
- * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
- * SUCH DAMAGE.
|
||||
- *
|
||||
- * This file is part of the Contiki operating system.
|
||||
- *
|
||||
- */
|
||||
-
|
||||
-#include "config.h"
|
||||
-#include "net/uip-debug.h"
|
||||
-
|
||||
-#include <string.h>
|
||||
-
|
||||
-#include "debug.h"
|
||||
-#include "coap.h"
|
||||
-
|
||||
-static coap_context_t *coap_context;
|
||||
-
|
||||
-/* changeable clock base (see handle_put_time()) */
|
||||
-static clock_time_t my_clock_base = 0;
|
||||
-static coap_resource_t *time_resource = NULL; /* just for testing */
|
||||
-
|
||||
-PROCESS(coap_server_process, "CoAP server process");
|
||||
-AUTOSTART_PROCESSES(&coap_server_process);
|
||||
-/*---------------------------------------------------------------------------*/
|
||||
-void
|
||||
-init_coap() {
|
||||
- coap_address_t listen_addr;
|
||||
-
|
||||
- coap_address_init(&listen_addr);
|
||||
- listen_addr.port = UIP_HTONS(COAP_DEFAULT_PORT);
|
||||
-
|
||||
-#ifdef WITH_CONTIKI
|
||||
- /* initialize uIP address for SLAAC */
|
||||
- uip_ip6addr(&listen_addr.addr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
|
||||
- uip_ds6_set_addr_iid(&listen_addr.addr, &uip_lladdr);
|
||||
- uip_ds6_addr_add(&listen_addr.addr, 0, ADDR_AUTOCONF);
|
||||
-
|
||||
- uip_debug_lladdr_print(&uip_lladdr);
|
||||
- printf("\r\n");
|
||||
- uip_debug_ipaddr_print(&listen_addr.addr);
|
||||
- printf("\r\n");
|
||||
-#endif /* WITH_CONTIKI */
|
||||
-
|
||||
-#ifdef WITH_CONTIKI
|
||||
- printf("tentative address: [%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x]:%d\r\n",
|
||||
- listen_addr.addr.u8[0], listen_addr.addr.u8[1],
|
||||
- listen_addr.addr.u8[2], listen_addr.addr.u8[3],
|
||||
- listen_addr.addr.u8[4], listen_addr.addr.u8[5],
|
||||
- listen_addr.addr.u8[6], listen_addr.addr.u8[7],
|
||||
- listen_addr.addr.u8[8], listen_addr.addr.u8[9],
|
||||
- listen_addr.addr.u8[10], listen_addr.addr.u8[11],
|
||||
- listen_addr.addr.u8[12], listen_addr.addr.u8[13],
|
||||
- listen_addr.addr.u8[14], listen_addr.addr.u8[15] ,
|
||||
- uip_ntohs(listen_addr.port));
|
||||
-#endif
|
||||
-
|
||||
- coap_context = coap_new_context(&listen_addr);
|
||||
-
|
||||
- coap_set_log_level(LOG_DEBUG);
|
||||
-
|
||||
- if (!coap_context)
|
||||
- coap_log(LOG_CRIT, "cannot create CoAP context\r\n");
|
||||
-}
|
||||
-
|
||||
-/*---------------------------------------------------------------------------*/
|
||||
-#ifndef min
|
||||
-# define min(a,b) ((a) < (b) ? (a) : (b))
|
||||
-#endif
|
||||
-
|
||||
-void
|
||||
-hnd_get_time(coap_context_t *ctx, struct coap_resource_t *resource,
|
||||
- coap_address_t *peer, coap_pdu_t *request, str *token,
|
||||
- coap_pdu_t *response) {
|
||||
- coap_opt_iterator_t opt_iter;
|
||||
- unsigned char buf[2];
|
||||
- coap_tick_t now;
|
||||
- coap_tick_t t;
|
||||
-
|
||||
- /* if my_clock_base was deleted, we pretend to have no such resource */
|
||||
- response->hdr->code = COAP_RESPONSE_CODE(205),
|
||||
-
|
||||
- coap_add_option(response, COAP_OPTION_CONTENT_TYPE,
|
||||
- coap_encode_var_bytes(buf, COAP_MEDIATYPE_TEXT_PLAIN), buf);
|
||||
-
|
||||
- coap_add_option(response, COAP_OPTION_MAXAGE,
|
||||
- coap_encode_var_bytes(buf, 0x01), buf);
|
||||
-
|
||||
- /* Check if subscription was requested. */
|
||||
- if (request &&
|
||||
- coap_check_option(request, COAP_OPTION_SUBSCRIPTION, &opt_iter) &&
|
||||
- coap_add_observer(resource, peer, token)) {
|
||||
-
|
||||
- /* add a new observe value */
|
||||
- coap_add_option(response, COAP_OPTION_SUBSCRIPTION,
|
||||
- coap_encode_var_bytes(buf, ctx->observe), buf);
|
||||
-
|
||||
- if (token->length)
|
||||
- coap_add_option(response, COAP_OPTION_TOKEN, token->length, token->s);
|
||||
- } else {
|
||||
- coap_add_option(response, COAP_OPTION_SUBSCRIPTION,
|
||||
- coap_encode_var_bytes(buf, ctx->observe), buf);
|
||||
-
|
||||
- if (token->length)
|
||||
- coap_add_option(response, COAP_OPTION_TOKEN, token->length, token->s);
|
||||
- }
|
||||
-
|
||||
- /* calculate current time */
|
||||
- coap_ticks(&t);
|
||||
- now = my_clock_base + (t / COAP_TICKS_PER_SECOND);
|
||||
-
|
||||
- /* output ticks */
|
||||
- response->length += snprintf((char *)response->data,
|
||||
- response->max_size - response->length,
|
||||
- "%u", (unsigned int)now);
|
||||
-}
|
||||
-
|
||||
-void
|
||||
-init_resources(coap_context_t *ctx) {
|
||||
- coap_resource_t *r;
|
||||
-#if 0
|
||||
- r = coap_resource_init(NULL, 0, 0);
|
||||
- coap_register_handler(r, COAP_REQUEST_GET, hnd_get_index);
|
||||
-
|
||||
- coap_add_attr(r, (unsigned char *)"ct", 2, (unsigned char *)"0", 1, 0);
|
||||
- coap_add_attr(r, (unsigned char *)"title", 5, (unsigned char *)"\"General Info\"", 14, 0);
|
||||
- coap_add_resource(ctx, r);
|
||||
-#endif
|
||||
- /* store clock base to use in /time */
|
||||
- my_clock_base = clock_offset;
|
||||
-
|
||||
- r = coap_resource_init((unsigned char *)"time", 4, 0);
|
||||
- if (!r)
|
||||
- goto error;
|
||||
-
|
||||
- r->observable = 1;
|
||||
- time_resource = r;
|
||||
- coap_register_handler(r, COAP_REQUEST_GET, hnd_get_time);
|
||||
-#if 0
|
||||
- coap_register_handler(r, COAP_REQUEST_PUT, hnd_put_time);
|
||||
- coap_register_handler(r, COAP_REQUEST_DELETE, hnd_delete_time);
|
||||
-#endif
|
||||
- coap_add_attr(r, (unsigned char *)"ct", 2, (unsigned char *)"0", 1, 0);
|
||||
- /* coap_add_attr(r, (unsigned char *)"title", 5, (unsigned char *)"\"Internal Clock\"", 16, 0); */
|
||||
- coap_add_attr(r, (unsigned char *)"rt", 2, (unsigned char *)"\"Ticks\"", 7, 0);
|
||||
- coap_add_attr(r, (unsigned char *)"if", 2, (unsigned char *)"\"clock\"", 7, 0);
|
||||
-
|
||||
- coap_add_resource(ctx, r);
|
||||
-#if 0
|
||||
-#ifndef WITHOUT_ASYNC
|
||||
- r = coap_resource_init((unsigned char *)"async", 5, 0);
|
||||
- coap_register_handler(r, COAP_REQUEST_GET, hnd_get_async);
|
||||
-
|
||||
- coap_add_attr(r, (unsigned char *)"ct", 2, (unsigned char *)"0", 1, 0);
|
||||
- coap_add_resource(ctx, r);
|
||||
-#endif /* WITHOUT_ASYNC */
|
||||
-#endif
|
||||
-
|
||||
- return;
|
||||
- error:
|
||||
- coap_log(LOG_CRIT, "cannot create resource\n");
|
||||
-}
|
||||
-
|
||||
-/* struct etimer notify_timer; */
|
||||
-struct etimer dirty_timer;
|
||||
-
|
||||
-/*---------------------------------------------------------------------------*/
|
||||
-PROCESS_THREAD(coap_server_process, ev, data)
|
||||
-{
|
||||
- PROCESS_BEGIN();
|
||||
-
|
||||
- init_coap();
|
||||
- init_resources(coap_context);
|
||||
-
|
||||
- if (!coap_context) {
|
||||
- coap_log(LOG_EMERG, "cannot create context\n");
|
||||
- PROCESS_EXIT();
|
||||
- }
|
||||
-
|
||||
- /* etimer_set(¬ify_timer, 5 * CLOCK_SECOND); */
|
||||
- etimer_set(&dirty_timer, 30 * CLOCK_SECOND);
|
||||
-
|
||||
- while(1) {
|
||||
- PROCESS_YIELD();
|
||||
- if(ev == tcpip_event) {
|
||||
- coap_read(coap_context); /* read received data */
|
||||
- coap_dispatch(coap_context); /* and dispatch PDUs from receivequeue */
|
||||
- } else if (ev == PROCESS_EVENT_TIMER && etimer_expired(&dirty_timer)) {
|
||||
- time_resource->dirty = 1;
|
||||
- etimer_reset(&dirty_timer);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- PROCESS_END();
|
||||
-}
|
||||
-/*---------------------------------------------------------------------------*/
|
||||
diff --git a/config.h b/config.h
|
||||
new file mode 100644
|
||||
index 0000000..5d6ea39
|
||||
--- /dev/null
|
||||
+++ b/config.h
|
||||
@@ -0,0 +1,129 @@
|
||||
+/* config.h. Generated from config.h.in by configure. */
|
||||
+/* config.h.in. Generated from configure.in by autoheader. */
|
||||
+
|
||||
+/* Define if building universal (internal helper macro) */
|
||||
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
|
||||
+
|
||||
+/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
+#define HAVE_ARPA_INET_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the <assert.h> header file. */
|
||||
+#define HAVE_ASSERT_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the `getaddrinfo' function. */
|
||||
+/* #undef HAVE_GETADDRINFO */
|
||||
+
|
||||
+/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
+#define HAVE_INTTYPES_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the `coap' library (-lcoap). */
|
||||
+/* #undef HAVE_LIBCOAP */
|
||||
+
|
||||
+/* Define to 1 if you have the <limits.h> header file. */
|
||||
+/* #undef HAVE_LIMITS_H */
|
||||
+
|
||||
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
||||
+ to 0 otherwise. */
|
||||
+#define HAVE_MALLOC 0
|
||||
+
|
||||
+/* Define to 1 if you have the <memory.h> header file. */
|
||||
+/* #undef HAVE_MEMORY_H */
|
||||
+
|
||||
+/* Define to 1 if you have the `memset' function. */
|
||||
+#define HAVE_MEMSET 1
|
||||
+
|
||||
+/* Define to 1 if you have the <netdb.h> header file. */
|
||||
+/* #undef HAVE_NETDB_H */
|
||||
+
|
||||
+/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
+#define HAVE_NETINET_IN_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the `select' function. */
|
||||
+/* #undef HAVE_SELECT */
|
||||
+
|
||||
+/* Define to 1 if you have the `socket' function. */
|
||||
+#define HAVE_SOCKET 1
|
||||
+
|
||||
+/* Define to 1 if you have the <stdint.h> header file. */
|
||||
+#define HAVE_STDINT_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
+#define HAVE_STDLIB_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the `strcasecmp' function. */
|
||||
+#define HAVE_STRCASECMP 1
|
||||
+
|
||||
+/* Define to 1 if you have the <strings.h> header file. */
|
||||
+#define HAVE_STRINGS_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the <string.h> header file. */
|
||||
+#define HAVE_STRING_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the `strnlen' function. */
|
||||
+#define HAVE_STRNLEN 1
|
||||
+
|
||||
+/* Define to 1 if you have the `strrchr' function. */
|
||||
+#define HAVE_STRRCHR 1
|
||||
+
|
||||
+/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
+#define HAVE_SYS_SOCKET_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
+/* #undef HAVE_SYS_STAT_H */
|
||||
+
|
||||
+/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
+#define HAVE_SYS_TIME_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
+#define HAVE_SYS_TYPES_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the <sys/unistd.h> header file. */
|
||||
+#define HAVE_SYS_UNISTD_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the <time.h> header file. */
|
||||
+#define HAVE_TIME_H 1
|
||||
+
|
||||
+/* Define to 1 if you have the <unistd.h> header file. */
|
||||
+#define HAVE_UNISTD_H 1
|
||||
+
|
||||
+/* Define to the address where bug reports for this package should be sent. */
|
||||
+#define PACKAGE_BUGREPORT ""
|
||||
+
|
||||
+/* Define to the full name of this package. */
|
||||
+#define PACKAGE_NAME "libcoap"
|
||||
+
|
||||
+/* Define to the full name and version of this package. */
|
||||
+#define PACKAGE_STRING "libcoap 4.0.3"
|
||||
+
|
||||
+/* Define to the one symbol short name of this package. */
|
||||
+#define PACKAGE_TARNAME "libcoap"
|
||||
+
|
||||
+/* Define to the home page for this package. */
|
||||
+#define PACKAGE_URL ""
|
||||
+
|
||||
+/* Define to the version of this package. */
|
||||
+#define PACKAGE_VERSION "4.0.3"
|
||||
+
|
||||
+/* Define to 1 if you have the ANSI C header files. */
|
||||
+#define STDC_HEADERS 1
|
||||
+
|
||||
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
+ significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
+#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
+# if defined __BIG_ENDIAN__
|
||||
+# define WORDS_BIGENDIAN 1
|
||||
+# endif
|
||||
+#else
|
||||
+# ifndef WORDS_BIGENDIAN
|
||||
+/* # undef WORDS_BIGENDIAN */
|
||||
+# endif
|
||||
+#endif
|
||||
+
|
||||
+/* Define to rpl_malloc if the replacement function should be used. */
|
||||
+/* #undef malloc */
|
||||
+
|
||||
+/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
+/* #undef size_t */
|
||||
+
|
||||
+/* Define to `int' if <sys/types.h> does not define. */
|
||||
+/* #undef ssize_t */
|
Loading…
Reference in New Issue
Block a user