From 542a921e3f1134071820dba12ef626a49febe8c6 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Thu, 11 Aug 2016 14:04:29 +0200 Subject: [PATCH 01/19] initial uplaod --- examples/osd/maclayertest/Makefile | 78 ++++++++ examples/osd/maclayertest/README.md | 14 ++ examples/osd/maclayertest/flash.sh | 2 + examples/osd/maclayertest/maclayertest.c | 230 +++++++++++++++++++++++ examples/osd/maclayertest/project-conf.h | 106 +++++++++++ examples/osd/maclayertest/run.sh | 5 + 6 files changed, 435 insertions(+) create mode 100644 examples/osd/maclayertest/Makefile create mode 100644 examples/osd/maclayertest/README.md create mode 100755 examples/osd/maclayertest/flash.sh create mode 100644 examples/osd/maclayertest/maclayertest.c create mode 100644 examples/osd/maclayertest/project-conf.h create mode 100755 examples/osd/maclayertest/run.sh diff --git a/examples/osd/maclayertest/Makefile b/examples/osd/maclayertest/Makefile new file mode 100644 index 000000000..ffb8d687e --- /dev/null +++ b/examples/osd/maclayertest/Makefile @@ -0,0 +1,78 @@ +EXE=maclayertest + +all: $(EXE) + +CONTIKI=../../.. + +# Contiki IPv6 configuration +WITH_UIP6=1 +UIP_CONF_IPV6=1 +CFLAGS += -DUIP_CONF_IPV6=1 +CFLAGS += -DUIP_CONF_IPV6_RPL=1 + +CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" + +# automatically build RESTful resources +REST_RESOURCES_DIR = ./resources +REST_RESOURCES_DIR_COMMON = ../resources-common +REST_RESOURCES_FILES= $(notdir \ + $(shell find $(REST_RESOURCES_DIR_COMMON) -name '*.c') \ + ) + +PROJECTDIRS += $(REST_RESOURCES_DIR_COMMON) +PROJECT_SOURCEFILES += $(REST_RESOURCES_FILES) + +# linker optimizations +SMALL=1 + +# REST Engine shall use Erbium CoAP implementation +APPS += er-coap +APPS += rest-engine +APPS += json json-resource + +# optional rules to get assembly +#CUSTOM_RULE_C_TO_OBJECTDIR_O = 1 +#CUSTOM_RULE_S_TO_OBJECTDIR_O = 1 + +include $(CONTIKI)/Makefile.include + +# minimal-net target is currently broken in Contiki +ifeq ($(TARGET), minimal-net) +CFLAGS += -DHARD_CODED_ADDRESS=\"fdfd::10\" +${info INFO: compiling with large buffers} +CFLAGS += -DUIP_CONF_BUFFER_SIZE=1300 +CFLAGS += -DREST_MAX_CHUNK_SIZE=1024 +CFLAGS += -DCOAP_MAX_HEADER_SIZE=176 +CFLAGS += -DUIP_CONF_IPV6_RPL=0 +endif + +# optional rules to get assembly +#$(OBJECTDIR)/%.o: asmdir/%.S +# $(CC) $(CFLAGS) -MMD -c $< -o $@ +# @$(FINALIZE_DEPENDENCY) +# +#asmdir/%.S: %.c +# $(CC) $(CFLAGS) -MMD -S $< -o $@ + +# border router rules +$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c + (cd $(CONTIKI)/tools && $(MAKE) tunslip6) + +connect-router: $(CONTIKI)/tools/tunslip6 + sudo $(CONTIKI)/tools/tunslip6 aaaa::1/64 + +connect-router-cooja: $(CONTIKI)/tools/tunslip6 + sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 -p 60001 aaaa::1/64 + +connect-router-native: $(CONTIKI)/examples/ipv6/native-border-router/border-router.native + sudo $(CONTIKI)/exmples/ipv6/native-border-router/border-router.native -a 127.0.0.1 -p 60001 aaaa::1/64 + +connect-minimal: + sudo ip address add fdfd::1/64 dev tap0 + +avr-size: $(EXE).$(TARGET).sz + +flash: $(EXE).$(TARGET).u $(EXE).$(TARGET).eu + +.PHONY: flash avr-size +.PRECIOUS: $(EXE).$(TARGET).hex $(EXE).$(TARGET).eep diff --git a/examples/osd/maclayertest/README.md b/examples/osd/maclayertest/README.md new file mode 100644 index 000000000..0a02cf8e6 --- /dev/null +++ b/examples/osd/maclayertest/README.md @@ -0,0 +1,14 @@ +Potentiometer Driver +==================== + +This App allows sending potentiometer values to a remote node. This is +currently used to change colors of the led-strip app but the resource +used and the IP address are configurable -- so we can use it for any +other destination. + +The app sends its value to the remote only if the value has changed. In +addition it has a retransmit interval (in seconds) that can retransmit +the value after a timeout if the value has not changed. Setting this +retransmit interval to 0 will turn off the retransmit feature. Note that +we sample the value only every second: We don't want to use up the whole +bandwidth for this app alone. diff --git a/examples/osd/maclayertest/flash.sh b/examples/osd/maclayertest/flash.sh new file mode 100755 index 000000000..e82962073 --- /dev/null +++ b/examples/osd/maclayertest/flash.sh @@ -0,0 +1,2 @@ +#!/bin/bash +make TARGET=osd-merkur-128 flash diff --git a/examples/osd/maclayertest/maclayertest.c b/examples/osd/maclayertest/maclayertest.c new file mode 100644 index 000000000..177eebc1b --- /dev/null +++ b/examples/osd/maclayertest/maclayertest.c @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2015, Ralf Schlatterbeck Open Source Consulting + * All rights reserved. + * + * 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. + */ + +/** + * \file + * Potentiometer for regulating LED-strip brightness per color + * \author + * Ralf Schlatterbeck + */ + +#include +#include +#include +#include +#include "contiki.h" +#include "contiki-net.h" +#include "rest-engine.h" +#include "er-coap-engine.h" +#include "uiplib.h" +#include "generic_resource.h" +#include "Arduino.h" + +/* + * Resources to be activated need to be imported through the extern keyword. + * The build system automatically compiles the resources in the + * corresponding sub-directory. + */ + +#if PLATFORM_HAS_BATTERY +#include "dev/battery-sensor.h" +extern resource_t res_battery; +#endif + +#if PLATFORM_HAS_RADIO +#include "dev/radio-sensor.h" +extern resource_t res_radio; +#endif + +#define REMOTE_PORT UIP_HTONS(COAP_DEFAULT_PORT) +// should be the same :-) +#define UIP_NTOHS(x) UIP_HTONS(x) +#define SERVER_NODE(ip) \ + uip_ip6addr(ip,0xfe80,0,0,0,0x0221,0x2eff,0xff00,0x665a) + /*uip_ip6addr(ip,0x2001,0xdb8,0xc001,0xf00d,0x22e,0xffff,0x34,0xa600)*/ +#define LOOP_INTERVAL (2 * CLOCK_SECOND) + +uip_ipaddr_t server_ipaddr, tmp_addr; +char server_resource [20] = "s/led"; +int interval = 2; /* Retransmit interval after no change in value */ + +uint8_t led_pin=4; +uint8_t led_status; + + +static size_t +ip_to_string (const char *name, const char *uri, char *buf, size_t bsize) +{ + #define IP(x) UIP_NTOHS(server_ipaddr.u16[x]) + return snprintf + ( buf, bsize, "%x:%x:%x:%x:%x:%x:%x:%x" + , IP(0), IP(1), IP(2), IP(3), IP(4), IP(5), IP(6), IP(7) + ); +} + +int ip_from_string (const char *name, const char *uri, const char *s) +{ + /* Returns 1 if successful, only copy valid address */ + if (uiplib_ip6addrconv (s, &tmp_addr)) { + uip_ip6addr_copy (&server_ipaddr, &tmp_addr); + return 0; + } + return -1; +} + +GENERIC_RESOURCE + ( server_ip + , ip + , ipv6_address + , 1 + , ip_from_string + , ip_to_string + ); + +static size_t +resource_to_string (const char *name, const char *uri, char *buf, size_t bsize) +{ + return snprintf (buf, bsize, "%s", server_resource); +} + +int resource_from_string (const char *name, const char *uri, const char *s) +{ + strncpy (server_resource, s, sizeof (server_resource)); + server_resource [sizeof (server_resource) - 1] = 0; + return 0; +} + +GENERIC_RESOURCE + ( server_resource + , led-resource + , resource-name + , 1 + , resource_from_string + , resource_to_string + ); + +static size_t +interval_to_string (const char *name, const char *uri, char *buf, size_t bsize) +{ + return snprintf (buf, bsize, "%d", interval); +} + +int interval_from_string (const char *name, const char *uri, const char *s) +{ + interval = atoi (s); + return 0; +} + +GENERIC_RESOURCE + ( interval + , interval + , s + , 0 + , interval_from_string + , interval_to_string + ); + +/* Passed to COAP_BLOCKING_REQUEST to handle responses */ +void chunk_handler (void *response) +{ + const uint8_t *chunk; + int len = coap_get_payload (response, &chunk); + printf ("|%.*s", len, (char *)chunk); +} + +PROCESS(poti, "Potentiometer"); +AUTOSTART_PROCESSES(&poti); + +PROCESS_THREAD(poti, ev, data) +{ + + static struct etimer loop_timer; + PROCESS_BEGIN(); + + /* Initialize the REST engine. */ + rest_init_engine (); + SERVER_NODE (&server_ipaddr); + + // switch off the led + pinMode(led_pin, OUTPUT); + digitalWrite(led_pin, HIGH); + led_status=0; + + /* Activate the application-specific resources. */ +#if PLATFORM_HAS_BATTERY + SENSORS_ACTIVATE(battery_sensor); + rest_activate_resource (&res_battery, "s/battery"); +#endif + rest_activate_resource (&res_server_ip, "poti/ip"); + rest_activate_resource (&res_server_resource, "poti/resource"); + rest_activate_resource (&res_interval, "poti/interval"); + + etimer_set (&loop_timer, LOOP_INTERVAL); + /* Define application-specific events here. */ + while(1) { + static coap_packet_t request [1]; /* Array: treat as pointer */ + static uint8_t val = 0; + + PROCESS_WAIT_EVENT(); + if (etimer_expired (&loop_timer)) { + + if (1) { + char buf [9]; + coap_transaction_t *transaction; + if(val==0){ + sprintf (buf, "mode=%s", "on"); + val=1; + digitalWrite(led_pin, LOW); + led_status=1; + }else{ + sprintf (buf, "mode=%s", "off"); + val=0; + digitalWrite(led_pin, HIGH); + led_status=0; + } + printf ("%s\n", buf); + coap_init_message (request, COAP_TYPE_NON, COAP_PUT, 0); + coap_set_header_uri_path (request, server_resource); + coap_set_header_content_format (request, REST.type.TEXT_PLAIN); + coap_set_payload (request, buf, strlen (buf)); + request->mid = coap_get_mid (); + transaction = coap_new_transaction + (request->mid, &server_ipaddr, REMOTE_PORT); + transaction->packet_len = coap_serialize_message + (request, transaction->packet); + coap_send_transaction (transaction); + } + etimer_reset (&loop_timer); + } + } /* while (1) */ + + PROCESS_END(); +} diff --git a/examples/osd/maclayertest/project-conf.h b/examples/osd/maclayertest/project-conf.h new file mode 100644 index 000000000..ab46b9879 --- /dev/null +++ b/examples/osd/maclayertest/project-conf.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2013, Matthias Kovatsch + * All rights reserved. + * + * 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. + * + * + */ + +#ifndef PROJECT_ERBIUM_CONF_H_ +#define PROJECT_ERBIUM_CONF_H_ + +#define PLATFORM_HAS_INFO 1 +#define PLATFORM_HAS_BATTERY 1 +#define PLATFORM_HAS_DS1820 1 +#define PLATFORM_HAS_DHT11HUM 1 +//#define PLATFORM_HAS_DHT11TEMP 1 +#define PLATFORM_HAS_LEDS 1 + + +/* Some platforms have weird includes. */ +#undef IEEE802154_CONF_PANID + +/* Disabling RDC for demo purposes. Core updates often require more memory. */ +/* For projects, optimize memory and enable RDC again. */ +// #undef NETSTACK_CONF_RDC +//#define NETSTACK_CONF_RDC nullrdc_driver + +/* Increase rpl-border-router IP-buffer when using more than 64. */ +#undef REST_MAX_CHUNK_SIZE +#define REST_MAX_CHUNK_SIZE 64 + +/* Estimate your header size, especially when using Proxy-Uri. */ +/* +#undef COAP_MAX_HEADER_SIZE +#define COAP_MAX_HEADER_SIZE 70 +*/ + +/* The IP buffer size must fit all other hops, in particular the border router. */ + +#undef UIP_CONF_BUFFER_SIZE +#define UIP_CONF_BUFFER_SIZE 256 + + +/* Multiplies with chunk size, be aware of memory constraints. */ +#undef COAP_MAX_OPEN_TRANSACTIONS +#define COAP_MAX_OPEN_TRANSACTIONS 4 + +/* Must be <= open transaction number, default is COAP_MAX_OPEN_TRANSACTIONS-1. */ +/* +#undef COAP_MAX_OBSERVERS +#define COAP_MAX_OBSERVERS 2 +*/ + +/* Filtering .well-known/core per query can be disabled to save space. */ +/* +#undef COAP_LINK_FORMAT_FILTERING +#define COAP_LINK_FORMAT_FILTERING 0 +*/ + +/* Save some memory for the sky platform. */ +/* +#undef NBR_TABLE_CONF_MAX_NEIGHBORS +#define NBR_TABLE_CONF_MAX_NEIGHBORS 10 +#undef UIP_CONF_MAX_ROUTES +#define UIP_CONF_MAX_ROUTES 10 +*/ + +/* Reduce 802.15.4 frame queue to save RAM. */ +/* +#undef QUEUEBUF_CONF_NUM +#define QUEUEBUF_CONF_NUM 4 +*/ + +/* +#undef SICSLOWPAN_CONF_FRAG +#define SICSLOWPAN_CONF_FRAG 1 +*/ + +/* For Debug: Dont allow MCU sleeping between channel checks */ +#undef RDC_CONF_MCU_SLEEP +#define RDC_CONF_MCU_SLEEP 0 + +#endif /* PROJECT_ERBIUM_CONF_H_ */ diff --git a/examples/osd/maclayertest/run.sh b/examples/osd/maclayertest/run.sh new file mode 100755 index 000000000..5d5cbbbb4 --- /dev/null +++ b/examples/osd/maclayertest/run.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# For the ages-old bootloader (before 2014) you want to use +# BOOTLOADER_GET_MAC=0x0001f3a0 as parameter to make below. +make clean TARGET=osd-merkur-128 +make TARGET=osd-merkur-128 From 6a2d13216ad7f68c3561ed9e9c5d41078a1e3612 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Thu, 11 Aug 2016 19:46:33 +0200 Subject: [PATCH 02/19] add mcu_sleep_off and on --- apps/arduino/arduino-process.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/arduino/arduino-process.c b/apps/arduino/arduino-process.c index 29d591b22..d1b21dd09 100644 --- a/apps/arduino/arduino-process.c +++ b/apps/arduino/arduino-process.c @@ -57,7 +57,7 @@ #include "hw-arduino.h" #include "contiki.h" -#define DEBUG 0 +#define DEBUG 1 #if DEBUG #include #define PRINTF(...) printf(__VA_ARGS__) @@ -135,7 +135,9 @@ PROCESS_THREAD(arduino_sketch, ev, data) #endif /* PLATFORM_HAS_BUTTON */ if(etimer_expired(&loop_periodic_timer)) { - loop (); + mcu_sleep_off(); + loop (); + mcu_sleep_on(); etimer_reset(&loop_periodic_timer); } } From c42a75d9d66cb85a13f78da9d2f00887ba6b41c5 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Thu, 11 Aug 2016 23:49:45 +0200 Subject: [PATCH 03/19] optimize power consumtion --- apps/arduino/arduino-process.c | 4 +++- examples/osd/triggerbaord/project-conf.h | 5 +++++ examples/osd/triggerbaord/sketch.pde | 6 ++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/arduino/arduino-process.c b/apps/arduino/arduino-process.c index d1b21dd09..6b190ac2a 100644 --- a/apps/arduino/arduino-process.c +++ b/apps/arduino/arduino-process.c @@ -57,7 +57,7 @@ #include "hw-arduino.h" #include "contiki.h" -#define DEBUG 1 +#define DEBUG 0 #if DEBUG #include #define PRINTF(...) printf(__VA_ARGS__) @@ -124,6 +124,7 @@ PROCESS_THREAD(arduino_sketch, ev, data) PROCESS_WAIT_EVENT(); #if PLATFORM_HAS_BUTTON if(ev == sensors_event && data == &button_sensor) { + mcu_sleep_off(); PRINTF("*******BUTTON*******\n"); /* Call the event_handler for this application-specific event. */ @@ -131,6 +132,7 @@ PROCESS_THREAD(arduino_sketch, ev, data) /* Also call the separate response example handler. */ res_separate.resume(); + mcu_sleep_on(); } #endif /* PLATFORM_HAS_BUTTON */ diff --git a/examples/osd/triggerbaord/project-conf.h b/examples/osd/triggerbaord/project-conf.h index d2a76eadf..510c66786 100644 --- a/examples/osd/triggerbaord/project-conf.h +++ b/examples/osd/triggerbaord/project-conf.h @@ -36,10 +36,15 @@ #define PLATFORM_HAS_BUTTON 1 #define PLATFORM_HAS_BATTERY 1 +#define LOOP_INTERVAL (10 * CLOCK_SECOND) + /* For Debug: Dont allow MCU sleeping between channel checks */ //#undef RDC_CONF_MCU_SLEEP //#define RDC_CONF_MCU_SLEEP 0 +/* Save energy */ +//#define RDC_CONF_PT_YIELD_OFF + /* Disabling RDC for demo purposes. Core updates often require more memory. */ /* For projects, optimize memory and enable RDC again. */ //#undef NETSTACK_CONF_RDC diff --git a/examples/osd/triggerbaord/sketch.pde b/examples/osd/triggerbaord/sketch.pde index d294e6fe2..73aeb00f7 100644 --- a/examples/osd/triggerbaord/sketch.pde +++ b/examples/osd/triggerbaord/sketch.pde @@ -46,12 +46,10 @@ void setup (void) rest_activate_resource(&res_event, "s/button"); // rest_activate_resource (&res_battery, "p/server"); - NETSTACK_MAC.off(1); +// NETSTACK_MAC.off(1); } void loop (void) { - mcu_sleep_off(); - - mcu_sleep_on(); + } From 6e67d1415c8fcc603d51a089197ec7c89fb63a9a Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Fri, 12 Aug 2016 07:46:30 +0200 Subject: [PATCH 04/19] shorter button flipping test --- cpu/avr/dev/button-sensor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/avr/dev/button-sensor.c b/cpu/avr/dev/button-sensor.c index 4bf62ea5a..067df7246 100644 --- a/cpu/avr/dev/button-sensor.c +++ b/cpu/avr/dev/button-sensor.c @@ -27,7 +27,7 @@ ISR(INT4_vect) if(BUTTON_CHECK_IRQ()) { if(timer_expired(&debouncetimer)) { // led1_on(); - timer_set(&debouncetimer, CLOCK_SECOND / 4); + timer_set(&debouncetimer, CLOCK_SECOND / 8); sensors_changed(&button_sensor); // led1_off(); } From 9408743938e6b943c000755085b66cf4c9b722dd Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Fri, 12 Aug 2016 07:50:17 +0200 Subject: [PATCH 05/19] move to arduino app --- examples/osd/triggerbaord/sketch.pde | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/osd/triggerbaord/sketch.pde b/examples/osd/triggerbaord/sketch.pde index d294e6fe2..73aeb00f7 100644 --- a/examples/osd/triggerbaord/sketch.pde +++ b/examples/osd/triggerbaord/sketch.pde @@ -46,12 +46,10 @@ void setup (void) rest_activate_resource(&res_event, "s/button"); // rest_activate_resource (&res_battery, "p/server"); - NETSTACK_MAC.off(1); +// NETSTACK_MAC.off(1); } void loop (void) { - mcu_sleep_off(); - - mcu_sleep_on(); + } From 50a34d12356042991291c10022a5784a447eb764 Mon Sep 17 00:00:00 2001 From: Ralf Schlatterbeck Date: Fri, 12 Aug 2016 22:03:44 +0200 Subject: [PATCH 06/19] Fix whitespace --- apps/arduino/arduino-process.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/arduino/arduino-process.c b/apps/arduino/arduino-process.c index 6b190ac2a..8cda5a0ae 100644 --- a/apps/arduino/arduino-process.c +++ b/apps/arduino/arduino-process.c @@ -77,13 +77,13 @@ extern volatile uint8_t mcusleepcycle; extern resource_t res_event, res_separate; #endif /* PLATFORM_HAS_BUTTON */ -volatile uint8_t mcusleepcycleval; +volatile uint8_t mcusleepcycleval; /*-------------- enabled sleep mode ----------------------------------------*/ void mcu_sleep_init(void) { - mcusleepcycleval=mcusleepcycle; + mcusleepcycleval=mcusleepcycle; } void mcu_sleep_on(void) @@ -113,7 +113,7 @@ PROCESS(arduino_sketch, "Arduino Sketch Wrapper"); PROCESS_THREAD(arduino_sketch, ev, data) { static struct etimer loop_periodic_timer; - + PROCESS_BEGIN(); adc_init (); mcu_sleep_init (); @@ -138,7 +138,7 @@ PROCESS_THREAD(arduino_sketch, ev, data) if(etimer_expired(&loop_periodic_timer)) { mcu_sleep_off(); - loop (); + loop (); mcu_sleep_on(); etimer_reset(&loop_periodic_timer); } From 265d4e8723f6b37848926eb4570b2a1ca5b52de7 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Mon, 15 Aug 2016 18:34:37 +0200 Subject: [PATCH 07/19] shorter button deflipping time --- cpu/avr/dev/button-sensor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/avr/dev/button-sensor.c b/cpu/avr/dev/button-sensor.c index 4bf62ea5a..067df7246 100644 --- a/cpu/avr/dev/button-sensor.c +++ b/cpu/avr/dev/button-sensor.c @@ -27,7 +27,7 @@ ISR(INT4_vect) if(BUTTON_CHECK_IRQ()) { if(timer_expired(&debouncetimer)) { // led1_on(); - timer_set(&debouncetimer, CLOCK_SECOND / 4); + timer_set(&debouncetimer, CLOCK_SECOND / 8); sensors_changed(&button_sensor); // led1_off(); } From cf40f59843cdc010a5cf205a87cd5ce042acf855 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Mon, 15 Aug 2016 20:22:49 +0200 Subject: [PATCH 08/19] add pin status --- cpu/avr/dev/button-sensor.c | 6 ++++-- examples/osd/triggerbaord/project-conf.h | 12 +++--------- examples/osd/triggerbaord/resources/res-event.c | 17 +++++++++++++++-- platform/osd-merkur-256/contiki-conf.h | 3 +++ 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/cpu/avr/dev/button-sensor.c b/cpu/avr/dev/button-sensor.c index 067df7246..cb50259ba 100644 --- a/cpu/avr/dev/button-sensor.c +++ b/cpu/avr/dev/button-sensor.c @@ -11,6 +11,7 @@ const struct sensors_sensor button_sensor; static struct timer debouncetimer; static int status(int type); static int enabled = 0; +volatile static int bstate; struct sensors_sensor *sensors[1]; unsigned char sensors_flags[1]; @@ -28,6 +29,7 @@ ISR(INT4_vect) if(timer_expired(&debouncetimer)) { // led1_on(); timer_set(&debouncetimer, CLOCK_SECOND / 8); + bstate = (PINE & _BV(PE4) ? 0 : 1); sensors_changed(&button_sensor); // led1_off(); } @@ -39,9 +41,9 @@ ISR(INT4_vect) static int value(int type) { - return (PINE & _BV(PE4) ? 0 : 1) || !timer_expired(&debouncetimer); + //return (PINE & _BV(PE4) ? 0 : 1) || !timer_expired(&debouncetimer); - //return 0; + return bstate; } static int diff --git a/examples/osd/triggerbaord/project-conf.h b/examples/osd/triggerbaord/project-conf.h index 510c66786..a0808564f 100644 --- a/examples/osd/triggerbaord/project-conf.h +++ b/examples/osd/triggerbaord/project-conf.h @@ -51,8 +51,8 @@ //#define NETSTACK_CONF_RDC nullrdc_driver /* Increase rpl-border-router IP-buffer when using more than 64. */ -#undef REST_MAX_CHUNK_SIZE -#define REST_MAX_CHUNK_SIZE 64 +//#undef REST_MAX_CHUNK_SIZE +//#define REST_MAX_CHUNK_SIZE 64 /* Estimate your header size, especially when using Proxy-Uri. */ /* @@ -68,7 +68,7 @@ /* Multiplies with chunk size, be aware of memory constraints. */ #undef COAP_MAX_OPEN_TRANSACTIONS -#define COAP_MAX_OPEN_TRANSACTIONS 4 +#define COAP_MAX_OPEN_TRANSACTIONS 8 /* Must be <= open transaction number, default is COAP_MAX_OPEN_TRANSACTIONS-1. */ /* @@ -82,10 +82,4 @@ #define COAP_LINK_FORMAT_FILTERING 0 */ - - - - - - #endif /* PROJECT_RPL_WEB_CONF_H_ */ diff --git a/examples/osd/triggerbaord/resources/res-event.c b/examples/osd/triggerbaord/resources/res-event.c index 7524d2ad2..8bc68102d 100644 --- a/examples/osd/triggerbaord/resources/res-event.c +++ b/examples/osd/triggerbaord/resources/res-event.c @@ -39,6 +39,7 @@ #include #include "rest-engine.h" #include "er-coap.h" +#include "dev/button-sensor.h" #define DEBUG 0 #if DEBUG @@ -76,8 +77,20 @@ static int32_t event_counter = 0; static void res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) { - REST.set_header_content_type(response, REST.type.TEXT_PLAIN); - REST.set_response_payload(response, buffer, snprintf((char *)buffer, preferred_size, "EVENT %lu", event_counter)); + int buttonstate = button_sensor.value(0); + + unsigned int accept = -1; + REST.get_header_accept(request, &accept); + if(accept == -1 || accept == REST.type.TEXT_PLAIN) { + REST.set_header_content_type(response, REST.type.TEXT_PLAIN); + REST.set_response_payload(response, buffer, snprintf((char *)buffer, preferred_size, "EVENT %lu STATE %d", event_counter, buttonstate)); + } else if(accept == REST.type.APPLICATION_JSON) { + REST.set_header_content_type(response, REST.type.APPLICATION_JSON); + REST.set_response_payload(response, buffer, snprintf((char *)buffer, preferred_size, "{'EVENT':%lu ,'STATE': %d}", event_counter, buttonstate)); + } else { + REST.set_response_status(response, REST.status.NOT_ACCEPTABLE); + REST.set_response_payload(response, buffer, snprintf((char *)buffer, preferred_size, "Supporting content-types text/plain and application/json")); + } /* A post_handler that handles subscriptions/observing will be called for periodic resources by the framework. */ } diff --git a/platform/osd-merkur-256/contiki-conf.h b/platform/osd-merkur-256/contiki-conf.h index fb8cf3178..519d86d86 100644 --- a/platform/osd-merkur-256/contiki-conf.h +++ b/platform/osd-merkur-256/contiki-conf.h @@ -174,6 +174,8 @@ typedef unsigned short uip_stats_t; #define NETSTACK_CONF_RDC sicslowmac_driver #define NETSTACK_CONF_FRAMER framer_802154 #define NETSTACK_CONF_RADIO rf230_driver +/* CCA theshold energy -91 to -61 dBm (default -77). Set this smaller than the $ */ +#define RF230_CONF_CCA_THRES -85 /* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */ #define RF230_CONF_AUTOACK 1 /* Request 802.15.4 ACK on all packets sent (else autoretry). This is primarily for testing. */ @@ -228,6 +230,7 @@ typedef unsigned short uip_stats_t; #define CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION 0 #define CONTIKIMAC_CONF_COMPOWER 1 #define RIMESTATS_CONF_ENABLED 0 +#define WITH_FAST_SLEEP 0 #if NETSTACK_CONF_WITH_IPV6 #define NETSTACK_CONF_FRAMER framer_802154 From d3431a0b5467decce8d0c82746eb7bc0f2351fc1 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Tue, 16 Aug 2016 11:11:32 +0200 Subject: [PATCH 09/19] bugfix contiki mac layer droped packets --- platform/osd-merkur-128/contiki-conf.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/osd-merkur-128/contiki-conf.h b/platform/osd-merkur-128/contiki-conf.h index 043dff995..002387cc4 100644 --- a/platform/osd-merkur-128/contiki-conf.h +++ b/platform/osd-merkur-128/contiki-conf.h @@ -173,6 +173,8 @@ typedef unsigned short uip_stats_t; #define NETSTACK_CONF_RDC sicslowmac_driver #define NETSTACK_CONF_FRAMER framer_802154 #define NETSTACK_CONF_RADIO rf230_driver +/* CCA theshold energy -91 to -61 dBm (default -77). Set this smaller than the $ */ +#define RF230_CONF_CCA_THRES -85 /* AUTOACK receive mode gives better rssi measurements, even if ACK is never requested */ #define RF230_CONF_AUTOACK 1 /* Request 802.15.4 ACK on all packets sent (else autoretry). This is primarily for testing. */ @@ -227,6 +229,7 @@ typedef unsigned short uip_stats_t; #define CONTIKIMAC_CONF_WITH_PHASE_OPTIMIZATION 0 #define CONTIKIMAC_CONF_COMPOWER 1 #define RIMESTATS_CONF_ENABLED 0 +#define WITH_FAST_SLEEP 0 #if NETSTACK_CONF_WITH_IPV6 #define NETSTACK_CONF_FRAMER framer_802154 From 6c7dc58574eea3c891894360ffe16f29466eefcf Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Tue, 16 Aug 2016 11:13:57 +0200 Subject: [PATCH 10/19] make it more flexible to user in other projects --- examples/osd/arduino-merkurboard/project-conf.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/osd/arduino-merkurboard/project-conf.h b/examples/osd/arduino-merkurboard/project-conf.h index e0b72b6dc..2d5781ca4 100644 --- a/examples/osd/arduino-merkurboard/project-conf.h +++ b/examples/osd/arduino-merkurboard/project-conf.h @@ -44,10 +44,12 @@ /* For projects, optimize memory and enable RDC again. */ //#undef NETSTACK_CONF_RDC //#define NETSTACK_CONF_RDC nullrdc_driver +//#undef NETSTACK_CONF_MAC +//#define NETSTACK_CONF_MAC nullmac_driver /* Increase rpl-border-router IP-buffer when using more than 64. */ -#undef REST_MAX_CHUNK_SIZE -#define REST_MAX_CHUNK_SIZE 64 +//#undef REST_MAX_CHUNK_SIZE +//#define REST_MAX_CHUNK_SIZE 64 /* Estimate your header size, especially when using Proxy-Uri. */ /* @@ -78,9 +80,4 @@ */ - - - - - #endif /* PROJECT_RPL_WEB_CONF_H_ */ From 12e77a1e58b1fcbfedd5a4663f5999af93a34999 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Thu, 18 Aug 2016 17:26:37 +0200 Subject: [PATCH 11/19] bugfix cca threshold --- platform/osd-merkur-128/contiki-conf.h | 2 ++ platform/osd-merkur-256/contiki-conf.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/platform/osd-merkur-128/contiki-conf.h b/platform/osd-merkur-128/contiki-conf.h index 002387cc4..638145710 100644 --- a/platform/osd-merkur-128/contiki-conf.h +++ b/platform/osd-merkur-128/contiki-conf.h @@ -246,6 +246,8 @@ typedef unsigned short uip_stats_t; #define RF230_CONF_FRAME_RETRIES 1 /* Long csma backoffs will compromise radio cycling; set to 0 for 1 csma */ #define RF230_CONF_CSMA_RETRIES 0 +/* CCA theshold energy -91 to -61 dBm (default -77). Set this smaller than the $ */ +#define RF230_CONF_CCA_THRES -90 #define SICSLOWPAN_CONF_FRAG 1 #define SICSLOWPAN_CONF_MAXAGE 3 /* 211 bytes per queue buffer. Contikimac burst mode needs 15 for a 1280 byte MTU */ diff --git a/platform/osd-merkur-256/contiki-conf.h b/platform/osd-merkur-256/contiki-conf.h index 519d86d86..e66aac285 100644 --- a/platform/osd-merkur-256/contiki-conf.h +++ b/platform/osd-merkur-256/contiki-conf.h @@ -247,6 +247,8 @@ typedef unsigned short uip_stats_t; #define RF230_CONF_FRAME_RETRIES 1 /* Long csma backoffs will compromise radio cycling; set to 0 for 1 csma */ #define RF230_CONF_CSMA_RETRIES 0 +/* CCA theshold energy -91 to -61 dBm (default -77). Set this smaller than the $ */ +#define RF230_CONF_CCA_THRES -90 #define SICSLOWPAN_CONF_FRAG 1 #define SICSLOWPAN_CONF_MAXAGE 3 /* 211 bytes per queue buffer. Contikimac burst mode needs 15 for a 1280 byte MTU */ From 1d2447d69da09cd169016aedf0f5195b67932ccf Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Thu, 18 Aug 2016 17:30:39 +0200 Subject: [PATCH 12/19] add noncorsec section --- examples/osd/triggerbaord/project-conf.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/examples/osd/triggerbaord/project-conf.h b/examples/osd/triggerbaord/project-conf.h index a0808564f..62e1d8d2b 100644 --- a/examples/osd/triggerbaord/project-conf.h +++ b/examples/osd/triggerbaord/project-conf.h @@ -82,4 +82,22 @@ #define COAP_LINK_FORMAT_FILTERING 0 */ +/* +#undef LLSEC802154_CONF_ENABLED +#define LLSEC802154_CONF_ENABLED 1 +#undef NETSTACK_CONF_FRAMER +#define NETSTACK_CONF_FRAMER noncoresec_framer +#undef NETSTACK_CONF_LLSEC +#define NETSTACK_CONF_LLSEC noncoresec_driver +#undef NONCORESEC_CONF_SEC_LVL +#define NONCORESEC_CONF_SEC_LVL 1 + +#define NONCORESEC_CONF_KEY { 0x00 , 0x01 , 0x02 , 0x03 , \ + 0x04 , 0x05 , 0x06 , 0x07 , \ + 0x08 , 0x09 , 0x0A , 0x0B , \ + 0x0C , 0x0D , 0x0E , 0x0F } + +*/ + #endif /* PROJECT_RPL_WEB_CONF_H_ */ + From a70a51acc20d79f61b5002d546467025356d5f45 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Fri, 19 Aug 2016 18:18:09 +0200 Subject: [PATCH 13/19] fake return value to 0 for better range, function rf230_cca have a bug --- cpu/avr/radio/rf230bb/rf230bb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index a6b7572cf..624018f36 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -1796,7 +1796,8 @@ rf230_cca(void) // if (cca & 0x40) {/*DEBUGFLOW('3')*/;} else {rf230_pending=1;DEBUGFLOW('4');} if (cca & 0x40) { // DEBUGFLOW('5'); - return 1; +// return 1; + return 0; } else { // DEBUGFLOW('6'); busyexit: From 8b887ca42918e663fcd7563f4f5910c5787bd98e Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Sat, 20 Aug 2016 14:09:44 +0200 Subject: [PATCH 14/19] add button led bled to project --- .../osd/triggerbaord/resources/res-bled.c | 104 ++++++++++++++++++ examples/osd/triggerbaord/sketch.pde | 15 ++- .../osd-merkur-128/Makefile.osd-merkur-128 | 2 +- 3 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 examples/osd/triggerbaord/resources/res-bled.c diff --git a/examples/osd/triggerbaord/resources/res-bled.c b/examples/osd/triggerbaord/resources/res-bled.c new file mode 100644 index 000000000..0afa1889d --- /dev/null +++ b/examples/osd/triggerbaord/resources/res-bled.c @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich + * All rights reserved. + * + * 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. + */ + +/** + * \file + * Door resource + * \author + * Harald Pichler + */ + +#include "contiki.h" + +#include +#include "rest-engine.h" +#include "Arduino.h" + +static void res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); +static void res_post_put_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset); + +/* A simple getter example. Returns the reading from the sensor with a simple etag */ +RESOURCE(res_bled, + "title=\"LED: , POST/PUT mode=on|off\";rt=\"Control\"", + res_get_handler, + res_post_put_handler, + res_post_put_handler, + NULL); + +extern uint8_t bled_pin; +extern uint8_t bled_status; + +static void +res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) +{ + unsigned int accept = -1; + REST.get_header_accept(request, &accept); + + if(accept == -1 || accept == REST.type.TEXT_PLAIN) { + REST.set_header_content_type(response, REST.type.TEXT_PLAIN); + snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d", bled_status); + + REST.set_response_payload(response, buffer, strlen((char *)buffer)); + } else if(accept == REST.type.APPLICATION_JSON) { + REST.set_header_content_type(response, REST.type.APPLICATION_JSON); + snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'led':%d}", bled_status); + + REST.set_response_payload(response, buffer, strlen((char *)buffer)); + } else { + REST.set_response_status(response, REST.status.NOT_ACCEPTABLE); + const char *msg = "Supporting content-types text/plain and application/json"; + REST.set_response_payload(response, msg, strlen(msg)); + } +} + +static void +res_post_put_handler(void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) +{ + size_t len = 0; + const char *mode = NULL; + int success = 1; + + if(success && (len = REST.get_post_variable(request, "mode", &mode))) { + if(strncmp(mode, "on", len) == 0) { + digitalWrite(bled_pin, HIGH); + bled_status=1; + } else if(strncmp(mode, "off", len) == 0) { + digitalWrite(bled_pin, LOW); + bled_status=0; + } else { + success = 0; + } + } else { + success = 0; + } if(!success) { + REST.set_response_status(response, REST.status.BAD_REQUEST); + } +} diff --git a/examples/osd/triggerbaord/sketch.pde b/examples/osd/triggerbaord/sketch.pde index 73aeb00f7..9980238b1 100644 --- a/examples/osd/triggerbaord/sketch.pde +++ b/examples/osd/triggerbaord/sketch.pde @@ -16,10 +16,9 @@ extern "C" { #include "net/netstack.h" #include "dev/button-sensor.h" - - extern resource_t - res_led, + res_led, + res_bled, res_battery, res_cputemp, res_event, @@ -28,6 +27,8 @@ extern resource_t uint8_t led_pin=4; uint8_t led_status; +uint8_t bled_pin=7; +uint8_t bled_status; } void setup (void) @@ -36,15 +37,19 @@ void setup (void) pinMode(led_pin, OUTPUT); digitalWrite(led_pin, HIGH); led_status=0; + // switch off the bled + pinMode(bled_pin, OUTPUT); + digitalWrite(bled_pin, LOW); + bled_status=0; // sensors SENSORS_ACTIVATE(button_sensor); // init coap resourcen rest_init_engine (); rest_activate_resource (&res_led, "s/led"); + rest_activate_resource (&res_bled, "s/bled"); rest_activate_resource (&res_battery, "s/battery"); rest_activate_resource (&res_cputemp, "s/cputemp"); - rest_activate_resource(&res_event, "s/button"); -// rest_activate_resource (&res_battery, "p/server"); + rest_activate_resource(&res_event, "s/button"); // NETSTACK_MAC.off(1); } diff --git a/platform/osd-merkur-128/Makefile.osd-merkur-128 b/platform/osd-merkur-128/Makefile.osd-merkur-128 index 8817f3855..48881a6f0 100644 --- a/platform/osd-merkur-128/Makefile.osd-merkur-128 +++ b/platform/osd-merkur-128/Makefile.osd-merkur-128 @@ -85,7 +85,7 @@ include $(CONTIKIAVR)/Makefile.avr include $(CONTIKIAVR)/radio/Makefile.radio MODULES += core/net/mac core/net core/net/mac/sicslowmac \ - core/net/mac/contikimac core/net/llsec \ + core/net/mac/contikimac core/net/llsec core/net/llsec/noncoresec \ # core/net/ipv6 core/net/ipv4 core/net/ip \ # core/net/rime \ # core/net/rpl \ From 6cf4e147ed64f25413b00c06b04b044b1c9c83bd Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Sat, 20 Aug 2016 14:32:26 +0200 Subject: [PATCH 15/19] add noncoresec --- platform/osd-merkur-256/Makefile.osd-merkur-256 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/osd-merkur-256/Makefile.osd-merkur-256 b/platform/osd-merkur-256/Makefile.osd-merkur-256 index 0a60d2044..36828e93b 100644 --- a/platform/osd-merkur-256/Makefile.osd-merkur-256 +++ b/platform/osd-merkur-256/Makefile.osd-merkur-256 @@ -85,7 +85,7 @@ include $(CONTIKIAVR)/Makefile.avr include $(CONTIKIAVR)/radio/Makefile.radio MODULES += core/net/mac core/net core/net/mac/sicslowmac \ - core/net/mac/contikimac core/net/llsec \ + core/net/mac/contikimac core/net/llsec core/net/llsec/noncoresec \ # core/net/ipv6 core/net/ipv4 core/net/ip \ # core/net/rime \ # core/net/rpl \ From 0190c261e2a2d65bb079389cf3e77caa5b4461ce Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Mon, 22 Aug 2016 22:15:41 +0200 Subject: [PATCH 16/19] use led1_on --- examples/osd/climate2/er-example-server.c | 13 +++++++------ examples/osd/climate2/project-conf.h | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/osd/climate2/er-example-server.c b/examples/osd/climate2/er-example-server.c index c3342c9e3..8daf9e6b8 100644 --- a/examples/osd/climate2/er-example-server.c +++ b/examples/osd/climate2/er-example-server.c @@ -82,7 +82,7 @@ extern resource_t res_ds1820; #endif #if defined (PLATFORM_HAS_LEDS) -#include "dev/leds.h" +#include "dev/led.h" extern resource_t res_leds; #endif @@ -100,7 +100,8 @@ void hw_init() { #if defined (PLATFORM_HAS_LEDS) - leds_off(LEDS_RED); +// leds_off(LEDS_RED); +led1_off(); #endif #if PLATFORM_HAS_DS1820 ds1820_temp(); @@ -139,10 +140,10 @@ PROCESS_THREAD(rest_server_example, ev, data) PRINTF("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE); /* if static routes are used rather than RPL */ -#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) && !defined (CONTIKI_TARGET_NATIVE) - set_global_address(); - configure_routing(); -#endif +//#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) && !defined (CONTIKI_TARGET_NATIVE) +// set_global_address(); +// configure_routing(); +//#endif /* Initialize the OSD Hardware. */ hw_init(); diff --git a/examples/osd/climate2/project-conf.h b/examples/osd/climate2/project-conf.h index 11c9b1dd4..0bc192b3a 100644 --- a/examples/osd/climate2/project-conf.h +++ b/examples/osd/climate2/project-conf.h @@ -41,11 +41,11 @@ /* Some platforms have weird includes. */ -#undef IEEE802154_CONF_PANID +//#undef IEEE802154_CONF_PANID /* Save energy */ -#define RDC_CONF_PT_YIELD_OFF +//#define RDC_CONF_PT_YIELD_OFF /* Disabling RDC for demo purposes. Core updates often require more memory. */ /* For projects, optimize memory and enable RDC again. */ From 3af0cc460cfbe732ede639a47ded36630a573695 Mon Sep 17 00:00:00 2001 From: Flo Date: Mon, 22 Aug 2016 22:53:01 +0200 Subject: [PATCH 17/19] set max-age header --- examples/osd/triggerbaord/resources/res-event.c | 3 +++ 1 file changed, 3 insertions(+) mode change 100644 => 100755 examples/osd/triggerbaord/resources/res-event.c diff --git a/examples/osd/triggerbaord/resources/res-event.c b/examples/osd/triggerbaord/resources/res-event.c old mode 100644 new mode 100755 index 8bc68102d..6470c311b --- a/examples/osd/triggerbaord/resources/res-event.c +++ b/examples/osd/triggerbaord/resources/res-event.c @@ -93,6 +93,9 @@ res_get_handler(void *request, void *response, uint8_t *buffer, uint16_t preferr } /* A post_handler that handles subscriptions/observing will be called for periodic resources by the framework. */ + + // tell client when to schedule re-registration: 1 Hour + REST.set_header_max_age(response, /* uint32_t, Seconds */ 3600); } /* * Additionally, res_event_handler must be implemented for each EVENT_RESOURCE. From ec34b8640c6afdab5440448a1e18cd538c749b22 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Tue, 23 Aug 2016 20:51:21 +0200 Subject: [PATCH 18/19] bugfix dallas remove first space --- examples/osd/arduino-climate3/sketch.pde | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/osd/arduino-climate3/sketch.pde b/examples/osd/arduino-climate3/sketch.pde index 9f9cb22d7..3e729d277 100644 --- a/examples/osd/arduino-climate3/sketch.pde +++ b/examples/osd/arduino-climate3/sketch.pde @@ -120,7 +120,7 @@ void setup (void) rest_init_engine (); rest_activate_resource (&res_htu21dtemp, "s/temp"); rest_activate_resource (&res_htu21dhum, "s/hum"); - rest_activate_resource (&res_dtemp1, "s/t1/temp"); + rest_activate_resource (&res_dtemp1, "s/tempd"); rest_activate_resource (&res_battery, "s/battery"); } @@ -149,6 +149,9 @@ void loop (void) if(htu21d_hum_s[0]==' '){ memcpy (htu21d_hum_s,htu21d_hum_s+1,strlen(htu21d_hum_s)+1); } + if(d_temp_s[0]==' '){ + memcpy (d_temp_s,d_temp_s+1,strlen(d_temp_s)+1); + } // debug only printf("Temp: %s",htu21d_temp_s); From eeb90bab7789807562d9f57a3394b67b74b49857 Mon Sep 17 00:00:00 2001 From: Flo Date: Wed, 24 Aug 2016 00:59:47 +0200 Subject: [PATCH 19/19] gets rid of 'deprecated conversion from string constant to char*' --- examples/osd/triggerbaord/sketch.pde | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 examples/osd/triggerbaord/sketch.pde diff --git a/examples/osd/triggerbaord/sketch.pde b/examples/osd/triggerbaord/sketch.pde old mode 100644 new mode 100755 index 9980238b1..d026c6985 --- a/examples/osd/triggerbaord/sketch.pde +++ b/examples/osd/triggerbaord/sketch.pde @@ -45,11 +45,13 @@ void setup (void) SENSORS_ACTIVATE(button_sensor); // init coap resourcen rest_init_engine (); + #pragma GCC diagnostic ignored "-Wwrite-strings" rest_activate_resource (&res_led, "s/led"); rest_activate_resource (&res_bled, "s/bled"); rest_activate_resource (&res_battery, "s/battery"); rest_activate_resource (&res_cputemp, "s/cputemp"); rest_activate_resource(&res_event, "s/button"); + #pragma GCC diagnostic pop // NETSTACK_MAC.off(1); }