Factor/Fix generic resources
Now the old GENERIC_RESOURCE macros works again (but usage has changed). Common resources (battery, leds, radio) are now in resources-common.
This commit is contained in:
parent
76e39b2b5d
commit
baaa2c5741
59 changed files with 440 additions and 2705 deletions
|
@ -1,19 +1,18 @@
|
|||
# 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
|
||||
ifeq ($(TARGET), osd-merkur)
|
||||
PLATFORM_FILES= avr-size arduino-example.osd-merkur.hex \
|
||||
arduino-example.osd-merkur.eep
|
||||
endif
|
||||
|
||||
# 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
|
||||
all: arduino-example $(PLATFORM_FILES)
|
||||
|
||||
CONTIKI=../../..
|
||||
|
||||
# Contiki IPv6 configuration
|
||||
CONTIKI_WITH_IPV6 = 1
|
||||
|
||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||
|
||||
PROJECT_SOURCEFILES += resource_led_pwm.c ${SKETCH}.cpp
|
||||
|
@ -35,44 +34,17 @@ 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
|
||||
# REST Engine shall use Erbium CoAP implementation
|
||||
APPS += er-coap
|
||||
APPS += rest-engine
|
||||
APPS += time json arduino json-resource
|
||||
|
||||
include $(CONTIKI)/Makefile.include
|
||||
include $(CONTIKI)/apps/arduino/Makefile.include
|
||||
|
||||
avr-size: arduino-example.osd-merkur
|
||||
avr-size -C --mcu=MCU=atmega128rfa1 arduino-example.osd-merkur
|
||||
|
||||
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
|
||||
|
@ -87,7 +59,7 @@ flash: arduino-example.osd-merkur.hex arduino-example.osd-merkur.eep
|
|||
flash:w:arduino-example.osd-merkur.hex:a -U \
|
||||
eeprom:w:arduino-example.osd-merkur.eep:a
|
||||
|
||||
.PHONY: flash
|
||||
.PHONY: flash avr-size
|
||||
|
||||
$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c
|
||||
(cd $(CONTIKI)/tools && $(MAKE) tunslip6)
|
||||
|
|
|
@ -18,18 +18,17 @@
|
|||
#define led_pwm_h
|
||||
#include "contiki.h"
|
||||
#include "contiki-net.h"
|
||||
#include "erbium.h"
|
||||
#include "er-coap-13.h"
|
||||
#include "er-coap.h"
|
||||
|
||||
extern uint8_t pwm;
|
||||
extern uint8_t period_100ms;
|
||||
extern uint16_t analog2_voltage;
|
||||
extern uint16_t analog5_voltage;
|
||||
|
||||
extern resource_t resource_led_pwm;
|
||||
extern resource_t resource_led_period;
|
||||
extern resource_t resource_analog2_voltage;
|
||||
extern resource_t resource_analog5_voltage;
|
||||
extern resource_t res_led_pwm;
|
||||
extern resource_t res_led_period;
|
||||
extern resource_t res_analog2_voltage;
|
||||
extern resource_t res_analog5_voltage;
|
||||
|
||||
#endif // led_pwm_h
|
||||
/** @} */
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
#include <string.h>
|
||||
#include "contiki.h"
|
||||
#include "jsonparse.h"
|
||||
/* Only coap 13 for now */
|
||||
#include "er-coap-13.h"
|
||||
#include "er-coap.h"
|
||||
#include "generic_resource.h"
|
||||
#include "led_pwm.h"
|
||||
|
||||
|
@ -34,8 +33,7 @@ pwm_to_string (const char *name, uint8_t is_json, char *buf, size_t bufsize)
|
|||
}
|
||||
|
||||
GENERIC_RESOURCE \
|
||||
( led_pwm, METHOD_GET | METHOD_PUT
|
||||
, "led/pwm"
|
||||
( led_pwm
|
||||
, LED PWM
|
||||
, duty-cycle
|
||||
, pwm_from_string
|
||||
|
@ -61,8 +59,7 @@ period_to_string (const char *name, uint8_t is_json, char *buf, size_t bufsize)
|
|||
}
|
||||
|
||||
GENERIC_RESOURCE \
|
||||
( led_period, METHOD_GET | METHOD_PUT
|
||||
, "led/period"
|
||||
( led_period
|
||||
, LED Period
|
||||
, ms
|
||||
, period_from_string
|
||||
|
@ -77,8 +74,7 @@ analog2_v (const char *name, uint8_t is_json, char *buf, size_t bufsize)
|
|||
}
|
||||
|
||||
GENERIC_RESOURCE \
|
||||
( analog2_voltage, METHOD_GET
|
||||
, "analog/2"
|
||||
( analog2_voltage
|
||||
, Analog 2 voltage
|
||||
, V
|
||||
, NULL
|
||||
|
@ -93,8 +89,7 @@ analog5_v (const char *name, uint8_t is_json, char *buf, size_t bufsize)
|
|||
}
|
||||
|
||||
GENERIC_RESOURCE \
|
||||
( analog5_voltage, METHOD_GET
|
||||
, "analog/5"
|
||||
( analog5_voltage
|
||||
, Analog 5 voltage
|
||||
, V
|
||||
, NULL
|
||||
|
|
|
@ -25,10 +25,10 @@ void setup (void)
|
|||
{
|
||||
arduino_pwm_timer_init ();
|
||||
rest_init_engine ();
|
||||
rest_activate_resource (&resource_led_pwm);
|
||||
rest_activate_resource (&resource_led_period);
|
||||
rest_activate_resource (&resource_analog2_voltage);
|
||||
rest_activate_resource (&resource_analog5_voltage);
|
||||
rest_activate_resource (&res_led_pwm, "led/pwm");
|
||||
rest_activate_resource (&res_led_period, "led/period");
|
||||
rest_activate_resource (&res_analog2_voltage, "analog/2");
|
||||
rest_activate_resource (&res_analog5_voltage, "analog/5");
|
||||
}
|
||||
|
||||
void loop (void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue