initial upload
This commit is contained in:
parent
114d7e883a
commit
ee1759ba4a
102
examples/osd/arduino-roomalert/Makefile
Normal file
102
examples/osd/arduino-roomalert/Makefile
Normal file
|
@ -0,0 +1,102 @@
|
|||
# Set this to the name of your sketch (without extension .pde)
|
||||
SKETCH=sketch
|
||||
|
||||
all: arduino-example \
|
||||
arduino-example.osd-merkur.hex arduino-example.osd-merkur.eep
|
||||
|
||||
# variable for this Makefile
|
||||
# configure CoAP implementation (3|7|12|13) (er-coap-07 also supports CoAP draft 08)
|
||||
WITH_COAP=13
|
||||
|
||||
# for some platforms
|
||||
UIP_CONF_IPV6=1
|
||||
# IPv6 make config disappeared completely
|
||||
CFLAGS += -DUIP_CONF_IPV6=1
|
||||
|
||||
CONTIKI=../../..
|
||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||
|
||||
PROJECT_SOURCEFILES += resource_pir.c ${SKETCH}.cpp
|
||||
|
||||
# variable for Makefile.include
|
||||
ifneq ($(TARGET), minimal-net)
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL=1
|
||||
else
|
||||
# minimal-net does not support RPL under Linux and is mostly used to test CoAP only
|
||||
${info INFO: compiling without RPL}
|
||||
CFLAGS += -DUIP_CONF_IPV6_RPL=0
|
||||
CFLAGS += -DHARD_CODED_ADDRESS=\"fdfd::10\"
|
||||
${info INFO: compiling with large buffers}
|
||||
CFLAGS += -DUIP_CONF_BUFFER_SIZE=2048
|
||||
CFLAGS += -DREST_MAX_CHUNK_SIZE=1024
|
||||
CFLAGS += -DCOAP_MAX_HEADER_SIZE=640
|
||||
endif
|
||||
|
||||
# linker optimizations
|
||||
SMALL=1
|
||||
|
||||
# REST framework, requires WITH_COAP
|
||||
ifeq ($(WITH_COAP), 13)
|
||||
${info INFO: compiling with CoAP-13}
|
||||
CFLAGS += -DWITH_COAP=13
|
||||
CFLAGS += -DREST=coap_rest_implementation
|
||||
CFLAGS += -DUIP_CONF_TCP=0
|
||||
APPS += er-coap-13
|
||||
else ifeq ($(WITH_COAP), 12)
|
||||
${info INFO: compiling with CoAP-12}
|
||||
CFLAGS += -DWITH_COAP=12
|
||||
CFLAGS += -DREST=coap_rest_implementation
|
||||
CFLAGS += -DUIP_CONF_TCP=0
|
||||
APPS += er-coap-12
|
||||
else ifeq ($(WITH_COAP), 7)
|
||||
${info INFO: compiling with CoAP-08}
|
||||
CFLAGS += -DWITH_COAP=7
|
||||
CFLAGS += -DREST=coap_rest_implementation
|
||||
CFLAGS += -DUIP_CONF_TCP=0
|
||||
APPS += er-coap-07
|
||||
else ifeq ($(WITH_COAP), 3)
|
||||
${info INFO: compiling with CoAP-03}
|
||||
CFLAGS += -DWITH_COAP=3
|
||||
CFLAGS += -DREST=coap_rest_implementation
|
||||
CFLAGS += -DUIP_CONF_TCP=0
|
||||
APPS += er-coap-03
|
||||
else
|
||||
${info INFO: compiling with HTTP}
|
||||
CFLAGS += -DWITH_HTTP
|
||||
CFLAGS += -DREST=http_rest_implementation
|
||||
CFLAGS += -DUIP_CONF_TCP=1
|
||||
APPS += er-http-engine
|
||||
endif
|
||||
|
||||
APPS += erbium time json arduino json-resource
|
||||
|
||||
include $(CONTIKI)/Makefile.include
|
||||
include $(CONTIKI)/apps/arduino/Makefile.include
|
||||
|
||||
arduino-example.osd-merkur.hex: arduino-example.osd-merkur
|
||||
avr-objcopy -j .text -j .data -O ihex arduino-example.osd-merkur \
|
||||
arduino-example.osd-merkur.hex
|
||||
|
||||
arduino-example.osd-merkur.eep: arduino-example.osd-merkur
|
||||
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||
--change-section-lma .eeprom=0 -O ihex \
|
||||
arduino-example.osd-merkur arduino-example.osd-merkur.eep
|
||||
|
||||
flash: arduino-example.osd-merkur.hex arduino-example.osd-merkur.eep
|
||||
avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U \
|
||||
flash:w:arduino-example.osd-merkur.hex:a -U \
|
||||
eeprom:w:arduino-example.osd-merkur.eep:a
|
||||
|
||||
.PHONY: flash
|
||||
|
||||
$(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 aaaa::1/64
|
||||
|
||||
connect-minimal:
|
||||
sudo ip address add fdfd::1/64 dev tap0
|
11
examples/osd/arduino-roomalert/README.md
Normal file
11
examples/osd/arduino-roomalert/README.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
Arduino compatibility example
|
||||
=============================
|
||||
|
||||
This example shows that it is now possible to re-use arduino sketches in
|
||||
Contiki. This example documents the necessary magic. Arduino specifies
|
||||
two routines, `setup` and `loop`. Before `setup` is called, the
|
||||
framework initializes hardware. In original Arduino, all this is done in
|
||||
a `main` function (in C). For contiki we define a process that does the
|
||||
same.
|
||||
|
||||
See the documentation file in apps/contiki-compat/README.md
|
2
examples/osd/arduino-roomalert/arduino-example.c
Normal file
2
examples/osd/arduino-roomalert/arduino-example.c
Normal file
|
@ -0,0 +1,2 @@
|
|||
#include <arduino-process.h>
|
||||
AUTOSTART_PROCESSES(&arduino_sketch);
|
2
examples/osd/arduino-roomalert/flash.sh
Executable file
2
examples/osd/arduino-roomalert/flash.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
make TARGET=osd-merkur flash
|
101
examples/osd/arduino-roomalert/project-conf.h
Normal file
101
examples/osd/arduino-roomalert/project-conf.h
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
||||
* 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_RPL_WEB_CONF_H_
|
||||
#define PROJECT_RPL_WEB_CONF_H_
|
||||
|
||||
#define PLATFORM_HAS_LEDS 1
|
||||
//#define PLATFORM_HAS_BUTTON 1
|
||||
#define PLATFORM_HAS_BATTERY 1
|
||||
|
||||
#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
|
||||
|
||||
/* 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
|
||||
*/
|
||||
|
||||
#endif /* PROJECT_RPL_WEB_CONF_H_ */
|
42
examples/osd/arduino-roomalert/resource_pir.c
Normal file
42
examples/osd/arduino-roomalert/resource_pir.c
Normal file
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* \file
|
||||
* Resource for Arduino analog read
|
||||
* \author
|
||||
* Harald Pichler <harald@the-develop.net>
|
||||
*
|
||||
* \brief get/put pwm and period for LED pin
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "contiki.h"
|
||||
#include "jsonparse.h"
|
||||
/* Only coap 13 for now */
|
||||
#include "er-coap-13.h"
|
||||
#include "generic_resource.h"
|
||||
#include "resource_pir.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
size_t
|
||||
pir_v (const char *name, uint8_t is_json, char *buf, size_t bufsize)
|
||||
{
|
||||
pir_value = digitalRead(pir_pin);
|
||||
return snprintf
|
||||
(buf, bufsize, "%d", pir_value);
|
||||
}
|
||||
|
||||
GENERIC_RESOURCE \
|
||||
( pir, METHOD_GET
|
||||
, "pir/v"
|
||||
, Moisture value
|
||||
, V
|
||||
, NULL
|
||||
, pir_v
|
||||
);
|
||||
|
||||
/*
|
||||
* VI settings, see coding style
|
||||
* ex:ts=8:et:sw=2
|
||||
*/
|
30
examples/osd/arduino-roomalert/resource_pir.h
Normal file
30
examples/osd/arduino-roomalert/resource_pir.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* \defgroup Arduino LED PWM example
|
||||
*
|
||||
* Resource definition for Arduino LED PWM module
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Resource definitions for the Arduino LED PWM module
|
||||
*
|
||||
* \author
|
||||
* Ralf Schlatterbeck <rsc@tux.runtux.com>
|
||||
*/
|
||||
|
||||
#ifndef pir_h
|
||||
#define pir_h
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
#include "erbium.h"
|
||||
#include "er-coap-13.h"
|
||||
|
||||
extern uint8_t pir_pin;
|
||||
extern uint16_t pir_value;
|
||||
|
||||
extern resource_t resource_pir;
|
||||
|
||||
#endif // pir_h
|
||||
/** @} */
|
5
examples/osd/arduino-roomalert/run.sh
Executable file
5
examples/osd/arduino-roomalert/run.sh
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
# For the new bootloader (using a jump-table) you want to use
|
||||
# BOOTLOADER_GET_MAC=0x0001ff80 (which is the current default)
|
||||
make clean TARGET=osd-merkur
|
||||
make TARGET=osd-merkur BOOTLOADER_GET_MAC=0x0001f3a0
|
34
examples/osd/arduino-roomalert/sketch.pde
Normal file
34
examples/osd/arduino-roomalert/sketch.pde
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Sample arduino sketch using contiki features.
|
||||
* We turn the LED off
|
||||
* We allow read the water sensor
|
||||
* Unfortunately sleeping for long times in loop() isn't currently
|
||||
* possible, something turns off the CPU (including PWM outputs) if a
|
||||
* Proto-Thread is taking too long. We need to find out how to sleep in
|
||||
* a Contiki-compatible way.
|
||||
* Note that for a normal arduino sketch you won't have to include any
|
||||
* of the contiki-specific files here, the sketch should just work.
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include <stdio.h>
|
||||
#include "resource_pir.h"
|
||||
|
||||
#define LED_PIN 4
|
||||
|
||||
uint8_t pir_pin = A5;
|
||||
uint16_t pir_value = 0;
|
||||
}
|
||||
|
||||
void setup (void)
|
||||
{
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
rest_init_engine ();
|
||||
rest_activate_resource (&resource_pir);
|
||||
}
|
||||
|
||||
void loop (void)
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in a new issue