seedeye powerswitch: update coap

The powerswitch app was using old an older implementation of er-coap.
This updates it.
This commit is contained in:
Brad Campbell 2015-05-14 17:14:56 -04:00
parent 3b6d9e5a64
commit 869768902b
2 changed files with 11 additions and 44 deletions

View File

@ -7,42 +7,8 @@ all: remotepowerswitch
CONTIKI=../../../
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
WITH_COAP=13
# 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
APPS += er-coap
APPS += rest-engine
CONTIKI_WITH_IPV6 = 1
include $(CONTIKI)/Makefile.include

View File

@ -55,13 +55,12 @@
#include "contiki.h"
#include "contiki-net.h"
#include "erbium.h"
#include "rest-engine.h"
#include "dev/leds.h"
#include <p32xxxx.h>
RESOURCE(toggle, METHOD_GET | METHOD_PUT | METHOD_POST, "actuators/powerswitch", "title=\"Red LED\";rt=\"Control\"");
void
toggle_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
@ -69,6 +68,8 @@ toggle_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
PORTEbits.RE0 = !PORTEbits.RE0;
}
RESOURCE(resource_toggle, "title=\"Red LED\";rt=\"Control\"", toggle_handler, toggle_handler, toggle_handler, NULL);
PROCESS(remote_power_switch, "Remote Power Switch");
@ -83,7 +84,7 @@ PROCESS_THREAD(remote_power_switch, ev, data)
TRISEbits.TRISE0 = 0;
PORTEbits.RE0 = 0;
rest_activate_resource(&resource_toggle);
rest_activate_resource(&resource_toggle, "actuators/powerswitch");
while(1) {
PROCESS_WAIT_EVENT();