seedeye powerswitch: update coap

The powerswitch app was using old an older implementation of er-coap.
This updates it.
ico
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=../../../ CONTIKI=../../../
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\" CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
WITH_COAP=13 APPS += er-coap
APPS += rest-engine
# 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
CONTIKI_WITH_IPV6 = 1 CONTIKI_WITH_IPV6 = 1
include $(CONTIKI)/Makefile.include include $(CONTIKI)/Makefile.include

View File

@ -1,13 +1,13 @@
/* /*
* Remote Power Switch Example for the Seed-Eye Board * Remote Power Switch Example for the Seed-Eye Board
* Copyright (c) 2013, Giovanni Pellerano * Copyright (c) 2013, Giovanni Pellerano
* *
* Ownership: Scuola Superiore Sant'Anna (http://www.sssup.it) and * Ownership: Scuola Superiore Sant'Anna (http://www.sssup.it) and
* Consorzio Nazionale Interuniversitario per le Telecomunicazioni * Consorzio Nazionale Interuniversitario per le Telecomunicazioni
* (http://www.cnit.it). * (http://www.cnit.it).
* *
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
@ -33,7 +33,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
*/ */
/** /**
* \addtogroup Remote Power Switch Example for the Seed-Eye Board * \addtogroup Remote Power Switch Example for the Seed-Eye Board
* *
@ -55,20 +55,21 @@
#include "contiki.h" #include "contiki.h"
#include "contiki-net.h" #include "contiki-net.h"
#include "erbium.h" #include "rest-engine.h"
#include "dev/leds.h" #include "dev/leds.h"
#include <p32xxxx.h> #include <p32xxxx.h>
RESOURCE(toggle, METHOD_GET | METHOD_PUT | METHOD_POST, "actuators/powerswitch", "title=\"Red LED\";rt=\"Control\"");
void void
toggle_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) toggle_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
leds_toggle(LEDS_RED); leds_toggle(LEDS_RED);
PORTEbits.RE0 = !PORTEbits.RE0; 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"); PROCESS(remote_power_switch, "Remote Power Switch");
@ -79,11 +80,11 @@ PROCESS_THREAD(remote_power_switch, ev, data)
PROCESS_BEGIN(); PROCESS_BEGIN();
rest_init_engine(); rest_init_engine();
TRISEbits.TRISE0 = 0; TRISEbits.TRISE0 = 0;
PORTEbits.RE0 = 0; PORTEbits.RE0 = 0;
rest_activate_resource(&resource_toggle); rest_activate_resource(&resource_toggle, "actuators/powerswitch");
while(1) { while(1) {
PROCESS_WAIT_EVENT(); PROCESS_WAIT_EVENT();