add coap18
This commit is contained in:
parent
b97d6878c0
commit
b2847f4756
5 changed files with 482 additions and 562 deletions
|
@ -1,21 +1,21 @@
|
||||||
all: er-example-server
|
ifeq ($(TARGET), osd-merkur)
|
||||||
|
PLATFORM_FILES= avr-size er-example-server.osd-merkur.hex \
|
||||||
|
er-example-server.osd-merkur.eep
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: er-example-server $(PLATFORM_FILES)
|
||||||
# use this target explicitly if requried: er-plugtest-server
|
# use this target explicitly if requried: er-plugtest-server
|
||||||
|
|
||||||
|
|
||||||
# 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=../../..
|
CONTIKI=../../..
|
||||||
|
|
||||||
|
# Contiki IPv6 configuration
|
||||||
|
CONTIKI_WITH_IPV6 = 1
|
||||||
|
|
||||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||||
|
|
||||||
# pcintkey
|
# pcintkey
|
||||||
PROJECT_SOURCEFILES += pcintkey.c
|
PROJECT_SOURCEFILES += pcintkey.c
|
||||||
|
PROJECT_SOURCEFILES += statusled.c
|
||||||
|
|
||||||
# variable for Makefile.include
|
# variable for Makefile.include
|
||||||
ifneq ($(TARGET), minimal-net)
|
ifneq ($(TARGET), minimal-net)
|
||||||
|
@ -34,63 +34,39 @@ endif
|
||||||
# linker optimizations
|
# linker optimizations
|
||||||
SMALL=1
|
SMALL=1
|
||||||
|
|
||||||
# REST framework, requires WITH_COAP
|
# REST Engine shall use Erbium CoAP implementation
|
||||||
ifeq ($(WITH_COAP), 13)
|
APPS += er-coap
|
||||||
${info INFO: compiling with CoAP-13}
|
APPS += rest-engine
|
||||||
CFLAGS += -DWITH_COAP=13
|
APPS += json json-resource
|
||||||
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
|
|
||||||
|
|
||||||
# optional rules to get assembly
|
|
||||||
#CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
|
|
||||||
#CUSTOM_RULE_S_TO_OBJECTDIR_O = 1
|
|
||||||
|
|
||||||
include $(CONTIKI)/Makefile.include
|
include $(CONTIKI)/Makefile.include
|
||||||
|
|
||||||
# optional rules to get assembly
|
avr-size: er-example-server.osd-merkur
|
||||||
#$(OBJECTDIR)/%.o: asmdir/%.S
|
avr-size -C --mcu=MCU=atmega128rfa1 er-example-server.osd-merkur
|
||||||
# $(CC) $(CFLAGS) -MMD -c $< -o $@
|
|
||||||
# @$(FINALIZE_DEPENDENCY)
|
|
||||||
#
|
|
||||||
#asmdir/%.S: %.c
|
|
||||||
# $(CC) $(CFLAGS) -MMD -S $< -o $@
|
|
||||||
|
|
||||||
# border router rules
|
er-example-server.osd-merkur.hex: er-example-server.osd-merkur
|
||||||
$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c
|
avr-objcopy -j .text -j .data -O ihex er-example-server.osd-merkur \
|
||||||
|
er-example-server.osd-merkur.hex
|
||||||
|
|
||||||
|
er-example-server.osd-merkur.eep: er-example-server.osd-merkur
|
||||||
|
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||||
|
--change-section-lma .eeprom=0 -O ihex \
|
||||||
|
er-example-server.osd-merkur er-example-server.osd-merkur.eep
|
||||||
|
|
||||||
|
flash: er-example-server.osd-merkur.hex er-example-server.osd-merkur.eep
|
||||||
|
avrdude -pm128rfa1 -c arduino -P/dev/ttyUSB0 -b57600 -e -U \
|
||||||
|
flash:w:er-example-server.osd-merkur.hex:a -U \
|
||||||
|
eeprom:w:er-example-server.osd-merkur.eep:a
|
||||||
|
|
||||||
|
.PHONY: flash avr-size
|
||||||
|
|
||||||
|
$(CONTIKI)/tools/tunslip6: $(CONTIKI)/tools/tunslip6.c
|
||||||
(cd $(CONTIKI)/tools && $(MAKE) tunslip6)
|
(cd $(CONTIKI)/tools && $(MAKE) tunslip6)
|
||||||
|
|
||||||
connect-router: $(CONTIKI)/tools/tunslip6
|
connect-router: $(CONTIKI)/tools/tunslip6
|
||||||
sudo $(CONTIKI)/tools/tunslip6 aaaa::1/64
|
sudo $(CONTIKI)/tools/tunslip6 aaaa::1/64
|
||||||
|
|
||||||
connect-router-cooja: $(CONTIKI)/tools/tunslip6
|
connect-router-cooja: $(CONTIKI)/tools/tunslip6
|
||||||
sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 aaaa::1/64
|
sudo $(CONTIKI)/tools/tunslip6 -a 127.0.0.1 aaaa::1/64
|
||||||
|
|
||||||
connect-minimal:
|
connect-minimal:
|
||||||
|
|
|
@ -42,25 +42,34 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
#include "contiki-net.h"
|
#include "contiki-net.h"
|
||||||
|
#include <avr/eeprom.h>
|
||||||
|
#include "rest-engine.h"
|
||||||
|
|
||||||
|
#define PLATFORM_HAS_LED 1
|
||||||
|
//#define PLATFORM_HAS_BUTTON 1
|
||||||
|
#define PLATFORM_HAS_OPTRIAC 1
|
||||||
|
#define PLATFORM_HAS_TEMPERATURE 1
|
||||||
|
#define PLATFORM_HAS_BATTERY 1
|
||||||
|
|
||||||
|
|
||||||
/* Define which resources to include to meet memory constraints. */
|
/* Define which resources to include to meet memory constraints. */
|
||||||
#define REST_RES_INFO 1
|
#define REST_RES_MODEL 1
|
||||||
|
#define REST_RES_NAME 1
|
||||||
|
#define REST_RES_SW 1
|
||||||
|
#define REST_RES_RESET 1
|
||||||
|
#define REST_RES_TIMER 1
|
||||||
#define REST_RES_OPTRIAC 1
|
#define REST_RES_OPTRIAC 1
|
||||||
#define REST_RES_TEMPERATURE 1
|
#define REST_RES_TEMPERATURE 1
|
||||||
#define REST_RES_EVENT 0
|
#define REST_RES_LED 1
|
||||||
#define REST_RES_LEDS 0
|
|
||||||
#define REST_RES_TOGGLE 0
|
|
||||||
#define REST_RES_BATTERY 1
|
#define REST_RES_BATTERY 1
|
||||||
|
|
||||||
#include "erbium.h"
|
|
||||||
#include "pcintkey.h"
|
#include "pcintkey.h"
|
||||||
|
#include "statusled.h"
|
||||||
|
|
||||||
#include "dev/led.h"
|
|
||||||
#if defined (PLATFORM_HAS_BUTTON)
|
#if defined (PLATFORM_HAS_BUTTON)
|
||||||
#include "dev/button-sensor.h"
|
#include "dev/button-sensor.h"
|
||||||
#endif
|
#endif
|
||||||
#if defined (PLATFORM_HAS_LEDS)
|
#if defined (PLATFORM_HAS_LED)
|
||||||
#include "dev/leds.h"
|
#include "dev/leds.h"
|
||||||
#endif
|
#endif
|
||||||
#if defined (PLATFORM_HAS_OPTRIAC)
|
#if defined (PLATFORM_HAS_OPTRIAC)
|
||||||
|
@ -73,20 +82,7 @@
|
||||||
#include "dev/battery-sensor.h"
|
#include "dev/battery-sensor.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "dev/optriac.h"
|
|
||||||
|
|
||||||
/* For CoAP-specific example: not required for normal RESTful Web service. */
|
|
||||||
#if WITH_COAP == 3
|
|
||||||
#include "er-coap-03.h"
|
|
||||||
#elif WITH_COAP == 7
|
|
||||||
#include "er-coap-07.h"
|
|
||||||
#elif WITH_COAP == 12
|
|
||||||
#include "er-coap-12.h"
|
|
||||||
#elif WITH_COAP == 13
|
|
||||||
#include "er-coap-13.h"
|
|
||||||
#else
|
|
||||||
#warning "Erbium example without CoAP-specifc functionality"
|
|
||||||
#endif /* CoAP-specific example */
|
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -100,13 +96,15 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
uint8_t g_triac_a = 0;
|
||||||
|
uint8_t g_triac_b = 0;
|
||||||
|
|
||||||
#if REST_RES_INFO
|
/******************************************************************************/
|
||||||
|
#if REST_RES_MODEL
|
||||||
/*
|
/*
|
||||||
* Resources are defined by the RESOURCE macro.
|
* Resources are defined by the RESOURCE macro.
|
||||||
* Signature: resource name, the RESTful methods it handles, and its URI path (omitting the leading slash).
|
* Signature: resource name, the RESTful methods it handles, and its URI path (omitting the leading slash).
|
||||||
*/
|
*/
|
||||||
RESOURCE(info, METHOD_GET, "info", "title=\"Info\";rt=\"text\"");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A handler function named [resource name]_handler must be implemented for each RESOURCE.
|
* A handler function named [resource name]_handler must be implemented for each RESOURCE.
|
||||||
|
@ -115,7 +113,7 @@ RESOURCE(info, METHOD_GET, "info", "title=\"Info\";rt=\"text\"");
|
||||||
* If a smaller block size is requested for CoAP, the REST framework automatically splits the data.
|
* If a smaller block size is requested for CoAP, the REST framework automatically splits the data.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
info_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
model_get_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||||
{
|
{
|
||||||
char message[100];
|
char message[100];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -123,8 +121,7 @@ info_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_
|
||||||
|
|
||||||
/* Some data that has the length up to REST_MAX_CHUNK_SIZE. For more, see the chunk resource. */
|
/* Some data that has the length up to REST_MAX_CHUNK_SIZE. For more, see the chunk resource. */
|
||||||
// jSON Format
|
// jSON Format
|
||||||
index += sprintf(message + index,"{\n \"Version\" : \"V1.0pre2\",\n");
|
index += sprintf(message + index,"{\n \"model\" : \"LightActor\"\n");
|
||||||
index += sprintf(message + index," \"name\" : \"light-actor\"\n");
|
|
||||||
index += sprintf(message + index,"}\n");
|
index += sprintf(message + index,"}\n");
|
||||||
|
|
||||||
length = strlen(message);
|
length = strlen(message);
|
||||||
|
@ -133,11 +130,270 @@ info_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_
|
||||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||||
REST.set_response_payload(response, buffer, length);
|
REST.set_response_payload(response, buffer, length);
|
||||||
}
|
}
|
||||||
|
RESOURCE(res_model, "title=\"model\";rt=\"simple.dev.md\"", model_get_handler, NULL, NULL, NULL);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
#if REST_RES_SW
|
||||||
|
/*
|
||||||
|
* Resources are defined by the RESOURCE macro.
|
||||||
|
* Signature: resource name, the RESTful methods it handles, and its URI path (omitting the leading slash).
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A handler function named [resource name]_handler must be implemented for each RESOURCE.
|
||||||
|
* A buffer for the response payload is provided through the buffer pointer. Simple resources can ignore
|
||||||
|
* preferred_size and offset, but must respect the REST_MAX_CHUNK_SIZE limit for the buffer.
|
||||||
|
* If a smaller block size is requested for CoAP, the REST framework automatically splits the data.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
sw_get_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||||
|
{
|
||||||
|
char message[100];
|
||||||
|
int index = 0;
|
||||||
|
int length = 0; /* |<-------->| */
|
||||||
|
|
||||||
|
/* Some data that has the length up to REST_MAX_CHUNK_SIZE. For more, see the chunk resource. */
|
||||||
|
// jSON Format
|
||||||
|
index += sprintf(message + index,"{\n \"sw\" : \"V1.0\"\n");
|
||||||
|
index += sprintf(message + index,"}\n");
|
||||||
|
|
||||||
|
length = strlen(message);
|
||||||
|
memcpy(buffer, message,length );
|
||||||
|
|
||||||
|
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||||
|
REST.set_response_payload(response, buffer, length);
|
||||||
|
}
|
||||||
|
RESOURCE(res_sw, "title=\"Software Version\";rt=\"simple.dev.sv\"", sw_get_handler, NULL, NULL, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
#if REST_RES_NAME
|
||||||
|
/*
|
||||||
|
* Resources are defined by the RESOURCE macro.
|
||||||
|
* Signature: resource name, the RESTful methods it handles, and its URI path (omitting the leading slash).
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* eeprom space */
|
||||||
|
#define P_NAME "Testboard"
|
||||||
|
#define P_NAME_MAX 17
|
||||||
|
uint8_t eemem_p_name[P_NAME_MAX] EEMEM = P_NAME;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A handler function named [resource name]_handler must be implemented for each RESOURCE.
|
||||||
|
* A buffer for the response payload is provided through the buffer pointer. Simple resources can ignore
|
||||||
|
* preferred_size and offset, but must respect the REST_MAX_CHUNK_SIZE limit for the buffer.
|
||||||
|
* If a smaller block size is requested for CoAP, the REST framework automatically splits the data.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
name_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||||
|
{
|
||||||
|
uint8_t eebuffer[32];
|
||||||
|
char message[100];
|
||||||
|
int index = 0;
|
||||||
|
int length = 0; /* |<-------->| */
|
||||||
|
const char *name = NULL;
|
||||||
|
int success = 1;
|
||||||
|
|
||||||
|
switch(REST.get_method_type(request)){
|
||||||
|
case METHOD_GET:
|
||||||
|
cli();
|
||||||
|
eeprom_read_block (eebuffer, &eemem_p_name, sizeof(eemem_p_name));
|
||||||
|
sei();
|
||||||
|
/* Some data that has the length up to REST_MAX_CHUNK_SIZE. For more, see the chunk resource. */
|
||||||
|
// jSON Format
|
||||||
|
index += sprintf(message + index,"{\n \"name\" : \"%s\"\n",eebuffer);
|
||||||
|
index += sprintf(message + index,"}\n");
|
||||||
|
|
||||||
|
length = strlen(message);
|
||||||
|
memcpy(buffer, message,length );
|
||||||
|
|
||||||
|
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||||
|
REST.set_response_payload(response, buffer, length);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case METHOD_POST:
|
||||||
|
if (success && (length=REST.get_post_variable(request, "name", &name))) {
|
||||||
|
PRINTF("name %s\n", name);
|
||||||
|
if (length < P_NAME_MAX) {
|
||||||
|
memcpy(&eebuffer, name,length);
|
||||||
|
eebuffer[length]=0;
|
||||||
|
cli();
|
||||||
|
eeprom_write_block(&eebuffer, &eemem_p_name, sizeof(eemem_p_name));
|
||||||
|
sei();
|
||||||
|
} else {
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
if (!success) {
|
||||||
|
REST.set_response_status(response, REST.status.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RESOURCE(res_name, "title=\"name\";rt=\"simple.dev.n\"", name_handler, NULL, name_handler, NULL );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
#if REST_RES_TIMER
|
||||||
|
/*A simple actuator example*/
|
||||||
|
|
||||||
|
/* eeprom space */
|
||||||
|
#define P_TIMER "60"
|
||||||
|
#define P_TIMER_MAX 10
|
||||||
|
uint8_t eemem_p_timer[P_TIMER_MAX] EEMEM = P_TIMER;
|
||||||
|
|
||||||
|
int gtimer_read(){
|
||||||
|
uint8_t eebuffer[32];
|
||||||
|
|
||||||
|
cli();
|
||||||
|
eeprom_read_block (eebuffer, &eemem_p_timer, sizeof(eemem_p_timer));
|
||||||
|
sei();
|
||||||
|
return atoi((const char *)eebuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
timer_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||||
|
{
|
||||||
|
uint8_t eebuffer[32];
|
||||||
|
const char *timer = NULL;
|
||||||
|
char message[100];
|
||||||
|
int length = 0; /* |<-------->| */
|
||||||
|
int index = 0;
|
||||||
|
int success = 1;
|
||||||
|
|
||||||
|
switch(REST.get_method_type(request)){
|
||||||
|
|
||||||
|
case METHOD_GET:
|
||||||
|
cli();
|
||||||
|
eeprom_read_block (eebuffer, &eemem_p_timer, sizeof(eemem_p_timer));
|
||||||
|
sei();
|
||||||
|
/* Some data that has the length up to REST_MAX_CHUNK_SIZE. For more, see the chunk resource. */
|
||||||
|
// jSON Format
|
||||||
|
index += sprintf(message + index,"{\n \"timer\" : \"%s\"\n",eebuffer);
|
||||||
|
index += sprintf(message + index,"}\n");
|
||||||
|
|
||||||
|
length = strlen(message);
|
||||||
|
memcpy(buffer, message,length );
|
||||||
|
|
||||||
|
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||||
|
REST.set_response_payload(response, buffer, length);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case METHOD_POST:
|
||||||
|
if (success && (length=REST.get_post_variable(request, "timer", &timer))) {
|
||||||
|
PRINTF("name %s\n", timer);
|
||||||
|
if (length < P_TIMER_MAX) {
|
||||||
|
memcpy(&eebuffer, timer,length);
|
||||||
|
eebuffer[length]=0;
|
||||||
|
cli();
|
||||||
|
eeprom_write_block(&eebuffer, &eemem_p_timer, sizeof(eemem_p_timer));
|
||||||
|
sei();
|
||||||
|
} else {
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
if (!success) {
|
||||||
|
REST.set_response_status(response, REST.status.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RESOURCE(res_timer, "title=\"timer\";rt=\"timer\"", timer_handler, NULL, timer_handler, NULL );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
#if REST_RES_RESET
|
||||||
|
/*A simple actuator example*/
|
||||||
|
|
||||||
|
/* eeprom space */
|
||||||
|
#define P_RESET "0"
|
||||||
|
#define P_RESET_MAX 10
|
||||||
|
uint8_t eemem_p_reset[P_RESET_MAX] EEMEM = P_RESET;
|
||||||
|
|
||||||
|
void
|
||||||
|
reset_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||||
|
{
|
||||||
|
uint8_t eebuffer[32];
|
||||||
|
const char *mode = NULL;
|
||||||
|
char message[100];
|
||||||
|
int length = 0; /* |<-------->| */
|
||||||
|
int index = 0;
|
||||||
|
int reset = 0;
|
||||||
|
size_t len = 0;
|
||||||
|
int success = 1;
|
||||||
|
|
||||||
|
switch(REST.get_method_type(request)){
|
||||||
|
|
||||||
|
case METHOD_GET:
|
||||||
|
cli();
|
||||||
|
eeprom_read_block (eebuffer, &eemem_p_reset, sizeof(eemem_p_reset));
|
||||||
|
sei();
|
||||||
|
/* Some data that has the length up to REST_MAX_CHUNK_SIZE. For more, see the chunk resource. */
|
||||||
|
// jSON Format
|
||||||
|
index += sprintf(message + index,"{\n \"reset\" : \"%s\"\n",eebuffer);
|
||||||
|
index += sprintf(message + index,"}\n");
|
||||||
|
|
||||||
|
length = strlen(message);
|
||||||
|
memcpy(buffer, message,length );
|
||||||
|
|
||||||
|
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||||
|
REST.set_response_payload(response, buffer, length);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case METHOD_POST:
|
||||||
|
if (success && (len=REST.get_post_variable(request, "mode", &mode))) {
|
||||||
|
PRINTF("mode %s\n", mode);
|
||||||
|
if (strncmp(mode, "on", len)==0) {
|
||||||
|
length=strlen(P_NAME);
|
||||||
|
memcpy(&eebuffer, P_NAME,length);
|
||||||
|
eebuffer[length]=0;
|
||||||
|
cli();
|
||||||
|
eeprom_write_block(&eebuffer, &eemem_p_name, sizeof(eemem_p_name));
|
||||||
|
sei();
|
||||||
|
length=strlen(P_TIMER);
|
||||||
|
memcpy(&eebuffer, P_TIMER,length);
|
||||||
|
eebuffer[length]=0;
|
||||||
|
cli();
|
||||||
|
eeprom_write_block(&eebuffer, &eemem_p_timer, sizeof(eemem_p_timer));
|
||||||
|
eeprom_read_block (eebuffer, &eemem_p_reset, sizeof(eemem_p_reset));
|
||||||
|
sei();
|
||||||
|
reset= atoi((char*)eebuffer) + 1;
|
||||||
|
length=sprintf((char*)eebuffer,"%d",reset);
|
||||||
|
cli();
|
||||||
|
eeprom_write_block(&eebuffer, &eemem_p_reset, sizeof(eemem_p_reset));
|
||||||
|
sei();
|
||||||
|
} else {
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
if (!success) {
|
||||||
|
REST.set_response_status(response, REST.status.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RESOURCE(res_reset, "title=\"reset\";rt=\"reset\"", reset_handler, NULL, reset_handler, NULL );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
// pcintkey_ext
|
// pcintkey_ext
|
||||||
/*A simple actuator example. read the key button status*/
|
/*A simple actuator example. read the key button status*/
|
||||||
RESOURCE(extbutton, METHOD_GET | METHOD_PUT , "sensors/extbutton", "title=\"ext.Button\";rt=\"Text\"");
|
|
||||||
void
|
void
|
||||||
extbutton_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
extbutton_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||||
{
|
{
|
||||||
|
@ -179,7 +435,7 @@ extbutton_handler(void* request, void* response, uint8_t *buffer, uint16_t prefe
|
||||||
REST.set_response_payload(response, buffer, length);
|
REST.set_response_payload(response, buffer, length);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case METHOD_PUT:
|
case METHOD_POST:
|
||||||
|
|
||||||
if (success && (len=REST.get_post_variable(request, "name", &name))) {
|
if (success && (len=REST.get_post_variable(request, "name", &name))) {
|
||||||
PRINTF("name %s\n", name);
|
PRINTF("name %s\n", name);
|
||||||
|
@ -196,192 +452,21 @@ extbutton_handler(void* request, void* response, uint8_t *buffer, uint16_t prefe
|
||||||
REST.set_response_status(response, REST.status.BAD_REQUEST);
|
REST.set_response_status(response, REST.status.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*A simple actuator example, post variable mode, relay is activated or deactivated*/
|
RESOURCE(res_extbutton, "title=\"button\";rt=\"button\"", extbutton_handler, NULL, extbutton_handler, NULL );
|
||||||
RESOURCE(led1, METHOD_GET | METHOD_PUT , "actuators/led1", "title=\"Led1\";rt=\"led\"");
|
|
||||||
|
/******************************************************************************/
|
||||||
|
#if REST_RES_LED
|
||||||
|
/*A simple actuator example, depending on the color query parameter and post variable mode, corresponding led is activated or deactivated*/
|
||||||
|
|
||||||
void
|
void
|
||||||
led1_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
led1_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||||
{
|
{
|
||||||
char mode[10];
|
|
||||||
static uint8_t led1 = 0;
|
|
||||||
static char name[17]="led1";
|
|
||||||
int success = 1;
|
|
||||||
|
|
||||||
char temp[100];
|
|
||||||
int index = 0;
|
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
const char *pmode = NULL;
|
|
||||||
const char *pname = NULL;
|
|
||||||
|
|
||||||
switch(REST.get_method_type(request)){
|
|
||||||
case METHOD_GET:
|
|
||||||
// jSON Format
|
|
||||||
index += sprintf(temp + index,"{\n \"name\" : \"%s\",\n",name);
|
|
||||||
if(led1 == 0)
|
|
||||||
index += sprintf(temp + index," \"mode\" : \"off\"\n");
|
|
||||||
if(led1 == 1)
|
|
||||||
index += sprintf(temp + index," \"mode\" : \"on\"\n");
|
|
||||||
index += sprintf(temp + index,"}\n");
|
|
||||||
|
|
||||||
len = strlen(temp);
|
|
||||||
memcpy(buffer, temp,len );
|
|
||||||
|
|
||||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
|
||||||
REST.set_response_payload(response, buffer, len);
|
|
||||||
break;
|
|
||||||
case METHOD_POST:
|
|
||||||
success = 0;
|
|
||||||
break;
|
|
||||||
case METHOD_PUT:
|
|
||||||
if (success && (len=REST.get_post_variable(request, "mode", &pmode))) {
|
|
||||||
PRINTF("name %s\n", mode);
|
|
||||||
memcpy(mode, pmode,len);
|
|
||||||
mode[len]=0;
|
|
||||||
if (!strcmp(mode, "on")) {
|
|
||||||
led1_on();
|
|
||||||
led1 = 1;
|
|
||||||
} else if (!strcmp(mode, "off")) {
|
|
||||||
led1_off();
|
|
||||||
led1 = 0;
|
|
||||||
} else {
|
|
||||||
success = 0;
|
|
||||||
}
|
|
||||||
} else if (success && (len=REST.get_post_variable(request, "name", &pname))) {
|
|
||||||
PRINTF("name %s\n", name);
|
|
||||||
memcpy(name, pname,len);
|
|
||||||
name[len]=0;
|
|
||||||
} else {
|
|
||||||
success = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
success = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!success) {
|
|
||||||
REST.set_response_status(response, REST.status.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
#if defined (PLATFORM_HAS_OPTRIAC)
|
|
||||||
/******************************************************************************/
|
|
||||||
#if REST_RES_OPTRIAC
|
|
||||||
/*A simple actuator example*/
|
|
||||||
RESOURCE(optriac, METHOD_GET | METHOD_POST | METHOD_PUT , "actuators/optriac", "title=\"TRIAC: ?type=a|b, POST/PUT mode=on|off\";rt=\"Control\"");
|
|
||||||
|
|
||||||
void
|
|
||||||
optriac_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
|
||||||
{
|
|
||||||
const char *type = NULL;
|
|
||||||
const char *mode = NULL;
|
|
||||||
static char namea[17]="Triac-a";
|
|
||||||
static char nameb[17]="Triac-b";
|
|
||||||
|
|
||||||
char temp[100];
|
|
||||||
int index = 0;
|
|
||||||
size_t len = 0;
|
|
||||||
|
|
||||||
uint8_t triac = 0;
|
|
||||||
int success = 1;
|
|
||||||
switch(REST.get_method_type(request)){
|
|
||||||
case METHOD_GET:
|
|
||||||
// jSON Format
|
|
||||||
index += sprintf(temp + index,"{\n \"%s\" : ",namea);
|
|
||||||
if(optriac_sensor.value(OPTRIAC_SENSOR_A) == 0)
|
|
||||||
index += sprintf(temp + index,"\"off\",\n");
|
|
||||||
if(optriac_sensor.value(OPTRIAC_SENSOR_A) == 1)
|
|
||||||
index += sprintf(temp + index,"\"on\",\n");
|
|
||||||
index += sprintf(temp + index," \"%s\" : ",nameb);
|
|
||||||
if(optriac_sensor.value(OPTRIAC_SENSOR_B) == 0)
|
|
||||||
index += sprintf(temp + index,"\"off\"\n");
|
|
||||||
if(optriac_sensor.value(OPTRIAC_SENSOR_B) == 1)
|
|
||||||
index += sprintf(temp + index,"\"on\"\n");
|
|
||||||
index += sprintf(temp + index,"}\n");
|
|
||||||
|
|
||||||
len = strlen(temp);
|
|
||||||
memcpy(buffer, temp,len );
|
|
||||||
|
|
||||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
|
||||||
REST.set_response_payload(response, buffer, len);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case METHOD_POST:
|
|
||||||
success = 0;
|
|
||||||
break;
|
|
||||||
case METHOD_PUT:
|
|
||||||
if ((len=REST.get_query_variable(request, "type", &type))) {
|
|
||||||
PRINTF("type %.*s\n", len, type);
|
|
||||||
|
|
||||||
if (strncmp(type, "a", len)==0) {
|
|
||||||
triac = OPTRIAC_SENSOR_A;
|
|
||||||
} else if(strncmp(type,"b", len)==0) {
|
|
||||||
triac = OPTRIAC_SENSOR_B;
|
|
||||||
} else {
|
|
||||||
triac = OPTRIAC_SENSOR_A;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
success = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success && (len=REST.get_post_variable(request, "mode", &mode))) {
|
|
||||||
PRINTF("mode %s\n", mode);
|
|
||||||
|
|
||||||
if (strncmp(mode, "on", len)==0) {
|
|
||||||
led1_on(); // Debug
|
|
||||||
optriac_sensor.configure(triac,1);
|
|
||||||
} else if (strncmp(mode, "off", len)==0) {
|
|
||||||
optriac_sensor.configure(triac,0);
|
|
||||||
led1_off(); // Debug
|
|
||||||
} else {
|
|
||||||
success = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
success = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
success = 0;
|
|
||||||
}
|
|
||||||
if (!success) {
|
|
||||||
REST.set_response_status(response, REST.status.BAD_REQUEST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/******************************************************************************/
|
|
||||||
#endif /* PLATFORM_HAS_OPTRIAC */
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
#if defined (PLATFORM_HAS_LEDS)
|
|
||||||
/******************************************************************************/
|
|
||||||
#if REST_RES_LEDS
|
|
||||||
/*A simple actuator example, depending on the color query parameter and post variable mode, corresponding led is activated or deactivated*/
|
|
||||||
RESOURCE(leds, METHOD_POST | METHOD_PUT , "actuators/leds", "title=\"LEDs: ?color=r|g|b, POST/PUT mode=on|off\";rt=\"Control\"");
|
|
||||||
|
|
||||||
void
|
|
||||||
leds_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
|
||||||
{
|
|
||||||
size_t len = 0;
|
|
||||||
const char *color = NULL;
|
|
||||||
const char *mode = NULL;
|
const char *mode = NULL;
|
||||||
uint8_t led = 0;
|
uint8_t led = 0;
|
||||||
int success = 1;
|
int success = 1;
|
||||||
|
|
||||||
if ((len=REST.get_query_variable(request, "color", &color))) {
|
led = LEDS_RED;
|
||||||
PRINTF("color %.*s\n", len, color);
|
|
||||||
|
|
||||||
if (strncmp(color, "r", len)==0) {
|
|
||||||
led = LEDS_RED;
|
|
||||||
} else if(strncmp(color,"g", len)==0) {
|
|
||||||
led = LEDS_GREEN;
|
|
||||||
} else if (strncmp(color,"b", len)==0) {
|
|
||||||
led = LEDS_BLUE;
|
|
||||||
} else {
|
|
||||||
success = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
success = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success && (len=REST.get_post_variable(request, "mode", &mode))) {
|
if (success && (len=REST.get_post_variable(request, "mode", &mode))) {
|
||||||
PRINTF("mode %s\n", mode);
|
PRINTF("mode %s\n", mode);
|
||||||
|
@ -401,45 +486,128 @@ leds_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_
|
||||||
REST.set_response_status(response, REST.status.BAD_REQUEST);
|
REST.set_response_status(response, REST.status.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
RESOURCE(res_led1, "title=\"LED: PUT mode=on|off\";rt=\"simple.act.led\"", led1_handler, NULL, led1_handler, NULL );
|
||||||
|
|
||||||
|
/*A simple actuator example, depending on the color query parameter and post variable mode, corresponding led is activated or deactivated*/
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
#if REST_RES_TOGGLE
|
|
||||||
/* A simple actuator example. Toggles the red led */
|
|
||||||
RESOURCE(toggle, METHOD_GET | METHOD_PUT | METHOD_POST, "actuators/toggle", "title=\"Red LED\";rt=\"Control\"");
|
|
||||||
void
|
void
|
||||||
toggle_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
led2_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||||
{
|
{
|
||||||
leds_toggle(LEDS_RED);
|
size_t len = 0;
|
||||||
}
|
const char *mode = NULL;
|
||||||
#endif
|
int success = 1;
|
||||||
#endif /* PLATFORM_HAS_LEDS */
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
if (success && (len=REST.get_post_variable(request, "mode", &mode))) {
|
||||||
|
PRINTF("mode %s\n", mode);
|
||||||
|
|
||||||
|
if (strncmp(mode, "on", len)==0) {
|
||||||
|
statusled_on();
|
||||||
|
} else if (strncmp(mode, "off", len)==0) {
|
||||||
|
statusled_off();
|
||||||
|
} else {
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
REST.set_response_status(response, REST.status.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RESOURCE(res_led2, "title=\"LED: PUT mode=on|off\";rt=\"simple.act.led\"", led2_handler, NULL, led2_handler, NULL );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if REST_RES_OPTRIAC
|
||||||
|
/*A simple actuator example*/
|
||||||
|
|
||||||
|
void
|
||||||
|
optriac_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||||
|
{
|
||||||
|
const char *mode = NULL;
|
||||||
|
static char namea[17]="Triac-a";
|
||||||
|
static char nameb[17]="Triac-b";
|
||||||
|
|
||||||
|
char temp[100];
|
||||||
|
int index = 0;
|
||||||
|
size_t len = 0;
|
||||||
|
int success = 1;
|
||||||
|
|
||||||
|
switch(REST.get_method_type(request)){
|
||||||
|
case METHOD_GET:
|
||||||
|
// jSON Format
|
||||||
|
index += sprintf(temp + index,"{\n \"%s\" : ",namea);
|
||||||
|
if(optriac_sensor.value(OPTRIAC_SENSOR_1) == 0)
|
||||||
|
index += sprintf(temp + index,"\"off\",\n");
|
||||||
|
if(optriac_sensor.value(OPTRIAC_SENSOR_1) == 1)
|
||||||
|
index += sprintf(temp + index,"\"on\",\n");
|
||||||
|
index += sprintf(temp + index," \"%s\" : ",nameb);
|
||||||
|
if(optriac_sensor.value(OPTRIAC_SENSOR_2) == 0)
|
||||||
|
index += sprintf(temp + index,"\"off\"\n");
|
||||||
|
if(optriac_sensor.value(OPTRIAC_SENSOR_2) == 1)
|
||||||
|
index += sprintf(temp + index,"\"on\"\n");
|
||||||
|
index += sprintf(temp + index,"}\n");
|
||||||
|
|
||||||
|
len = strlen(temp);
|
||||||
|
memcpy(buffer, temp,len );
|
||||||
|
|
||||||
|
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||||
|
REST.set_response_payload(response, buffer, len);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case METHOD_PUT:
|
||||||
|
if (success && (len=REST.get_post_variable(request, "mode", &mode))) {
|
||||||
|
PRINTF("mode %s\n", mode);
|
||||||
|
if (strncmp(mode, "on", len)==0) {
|
||||||
|
optriac_sensor.configure(OPTRIAC_SENSOR_1,1);
|
||||||
|
optriac_sensor.configure(OPTRIAC_SENSOR_2,1);
|
||||||
|
statusled_on();
|
||||||
|
} else if (strncmp(mode, "off", len)==0) {
|
||||||
|
optriac_sensor.configure(OPTRIAC_SENSOR_1,0);
|
||||||
|
optriac_sensor.configure(OPTRIAC_SENSOR_2,0);
|
||||||
|
statusled_off();
|
||||||
|
} else {
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
success = 0;
|
||||||
|
}
|
||||||
|
if (!success) {
|
||||||
|
REST.set_response_status(response, REST.status.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RESOURCE(res_optriac, "title=\"TRIAC, PUT mode=on|off\";rt=\"simple.act.triac\"", optriac_handler, NULL, optriac_handler, NULL );
|
||||||
|
#endif /* PLATFORM_HAS_OPTRIAC */
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
#if REST_RES_TEMPERATURE && defined (PLATFORM_HAS_TEMPERATURE)
|
#if REST_RES_TEMPERATURE && defined (PLATFORM_HAS_TEMPERATURE)
|
||||||
/* A simple getter example. Returns the reading from light sensor with a simple etag */
|
/* A simple getter example. Returns the reading from light sensor with a simple etag */
|
||||||
RESOURCE(temperature, METHOD_GET, "sensors/cputemp", "title=\"Temperature status\";rt=\"temperature-c\"");
|
|
||||||
void
|
void
|
||||||
temperature_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
temperature_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||||
{
|
{
|
||||||
int temperature = temperature_sensor.value(0);
|
int temperature = temperature_sensor.value(0);
|
||||||
|
|
||||||
|
unsigned int accept = -1;
|
||||||
|
REST.get_header_accept(request, &accept);
|
||||||
|
|
||||||
const uint16_t *accept = NULL;
|
if(accept == -1 || accept == REST.type.TEXT_PLAIN)
|
||||||
int num = REST.get_header_accept(request, &accept);
|
|
||||||
|
|
||||||
if ((num==0) || (num && accept[0]==REST.type.TEXT_PLAIN))
|
|
||||||
{
|
{
|
||||||
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
||||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d", temperature);
|
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d.%02d", temperature/100, temperature % 100);
|
||||||
|
|
||||||
|
|
||||||
REST.set_response_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
|
REST.set_response_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
|
||||||
}
|
}
|
||||||
else if (num && (accept[0]==REST.type.APPLICATION_JSON))
|
else if (accept == REST.type.APPLICATION_JSON)
|
||||||
{
|
{
|
||||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'temperature':%d}", temperature);
|
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'temperature':%d.%02d}", temperature/100, temperature % 100);
|
||||||
|
|
||||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||||
}
|
}
|
||||||
|
@ -450,32 +618,33 @@ temperature_handler(void* request, void* response, uint8_t *buffer, uint16_t pre
|
||||||
REST.set_response_payload(response, msg, strlen(msg));
|
REST.set_response_payload(response, msg, strlen(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RESOURCE(res_temperature, "title=\"Temperature status\";rt=\"temperature-c\"", temperature_handler, NULL, NULL, NULL );
|
||||||
#endif /* PLATFORM_HAS_TEMPERATURE */
|
#endif /* PLATFORM_HAS_TEMPERATURE */
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
#if REST_RES_BATTERY && defined (PLATFORM_HAS_BATTERY)
|
#if REST_RES_BATTERY && defined (PLATFORM_HAS_BATTERY)
|
||||||
/* A simple getter example. Returns the reading from light sensor with a simple etag */
|
/* A simple getter example. Returns the reading from light sensor with a simple etag */
|
||||||
RESOURCE(battery, METHOD_GET, "sensors/battery", "title=\"Battery status\";rt=\"battery-mV\"");
|
|
||||||
void
|
void
|
||||||
battery_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
battery_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
|
||||||
{
|
{
|
||||||
int battery = battery_sensor.value(0);
|
int battery = battery_sensor.value(0);
|
||||||
|
|
||||||
|
unsigned int accept = -1;
|
||||||
|
REST.get_header_accept(request, &accept);
|
||||||
|
|
||||||
const uint16_t *accept = NULL;
|
if(accept == -1 || accept == REST.type.TEXT_PLAIN)
|
||||||
int num = REST.get_header_accept(request, &accept);
|
|
||||||
|
|
||||||
if ((num==0) || (num && accept[0]==REST.type.TEXT_PLAIN))
|
|
||||||
{
|
{
|
||||||
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
REST.set_header_content_type(response, REST.type.TEXT_PLAIN);
|
||||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d", battery);
|
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "%d.%02d", battery/1000, battery % 1000);
|
||||||
|
|
||||||
REST.set_response_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
|
REST.set_response_payload(response, (uint8_t *)buffer, strlen((char *)buffer));
|
||||||
}
|
}
|
||||||
else if (num && (accept[0]==REST.type.APPLICATION_JSON))
|
else if (accept == REST.type.APPLICATION_JSON)
|
||||||
{
|
{
|
||||||
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
REST.set_header_content_type(response, REST.type.APPLICATION_JSON);
|
||||||
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{'battery':%d}", battery);
|
snprintf((char *)buffer, REST_MAX_CHUNK_SIZE, "{\"battery\":%d.%02d}", battery/1000, battery % 1000);
|
||||||
|
|
||||||
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
REST.set_response_payload(response, buffer, strlen((char *)buffer));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -485,6 +654,8 @@ battery_handler(void* request, void* response, uint8_t *buffer, uint16_t preferr
|
||||||
REST.set_response_payload(response, msg, strlen(msg));
|
REST.set_response_payload(response, msg, strlen(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RESOURCE(res_battery, "title=\"Battery status\";rt=\"battery-mV\"", battery_handler, NULL, NULL, NULL );
|
||||||
|
|
||||||
#endif /* PLATFORM_HAS_BATTERY */
|
#endif /* PLATFORM_HAS_BATTERY */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
@ -493,7 +664,8 @@ battery_handler(void* request, void* response, uint8_t *buffer, uint16_t preferr
|
||||||
void
|
void
|
||||||
hw_init()
|
hw_init()
|
||||||
{
|
{
|
||||||
led1_off();
|
leds_off(LEDS_RED);
|
||||||
|
statusledinit();
|
||||||
key_init();
|
key_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,36 +713,41 @@ PROCESS_THREAD(rest_server_example, ev, data)
|
||||||
rest_init_engine();
|
rest_init_engine();
|
||||||
|
|
||||||
/* Activate the application-specific resources. */
|
/* Activate the application-specific resources. */
|
||||||
rest_activate_resource(&resource_led1);
|
#if REST_RES_MODEL
|
||||||
rest_activate_resource(&resource_extbutton);
|
rest_activate_resource(&res_model,"p/model");
|
||||||
#if REST_RES_INFO
|
|
||||||
rest_activate_resource(&resource_info);
|
|
||||||
#endif
|
#endif
|
||||||
|
#if REST_RES_SW
|
||||||
|
rest_activate_resource(&res_sw,"p/sw");
|
||||||
|
#endif
|
||||||
|
#if REST_RES_NAME
|
||||||
|
rest_activate_resource(&res_name,"p/name");
|
||||||
|
#endif
|
||||||
|
#if REST_RES_RESET
|
||||||
|
rest_activate_resource(&res_reset,"p/reset");
|
||||||
|
#endif
|
||||||
|
#if REST_RES_TIMER
|
||||||
|
rest_activate_resource(&res_timer,"a/timer");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
rest_activate_resource(&res_extbutton,"s/extbutton");
|
||||||
/* Activate the application-specific resources. */
|
/* Activate the application-specific resources. */
|
||||||
#if REST_RES_OPTRIAC
|
#if REST_RES_OPTRIAC
|
||||||
SENSORS_ACTIVATE(optriac_sensor);
|
SENSORS_ACTIVATE(optriac_sensor);
|
||||||
rest_activate_resource(&resource_optriac);
|
rest_activate_resource(&res_optriac,"a/optriac");
|
||||||
#endif
|
#endif
|
||||||
#if defined (PLATFORM_HAS_PIR) && (REST_RES_EVENT)
|
#if defined (PLATFORM_HAS_LED)
|
||||||
SENSORS_ACTIVATE(pir_sensor);
|
#if REST_RES_LED
|
||||||
rest_activate_event_resource(&resource_pir);
|
rest_activate_resource(&res_led1,"a/led1");
|
||||||
PRINTF("ACTIVATE PIR\n");
|
rest_activate_resource(&res_led2,"a/led2");
|
||||||
#endif
|
#endif
|
||||||
#if defined (PLATFORM_HAS_LEDS)
|
#endif /* PLATFORM_HAS_LED */
|
||||||
#if REST_RES_LEDS
|
|
||||||
rest_activate_resource(&resource_leds);
|
|
||||||
#endif
|
|
||||||
#if REST_RES_TOGGLE
|
|
||||||
rest_activate_resource(&resource_toggle);
|
|
||||||
#endif
|
|
||||||
#endif /* PLATFORM_HAS_LEDS */
|
|
||||||
#if defined (PLATFORM_HAS_TEMPERATURE) && REST_RES_TEMPERATURE
|
#if defined (PLATFORM_HAS_TEMPERATURE) && REST_RES_TEMPERATURE
|
||||||
SENSORS_ACTIVATE(temperature_sensor);
|
SENSORS_ACTIVATE(temperature_sensor);
|
||||||
rest_activate_resource(&resource_temperature);
|
rest_activate_resource(&res_temperature,"s/cputemp");
|
||||||
#endif
|
#endif
|
||||||
#if defined (PLATFORM_HAS_BATTERY) && REST_RES_BATTERY
|
#if defined (PLATFORM_HAS_BATTERY) && REST_RES_BATTERY
|
||||||
SENSORS_ACTIVATE(battery_sensor);
|
SENSORS_ACTIVATE(battery_sensor);
|
||||||
rest_activate_resource(&resource_battery);
|
rest_activate_resource(&res_battery,"s/battery");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
etimer_set(&ds_periodic_timer, MESURE_INTERVAL);
|
etimer_set(&ds_periodic_timer, MESURE_INTERVAL);
|
||||||
|
@ -597,11 +774,11 @@ PROCESS_THREAD(rest_server_example, ev, data)
|
||||||
ext5 = is_button_ext5();
|
ext5 = is_button_ext5();
|
||||||
PRINTF("Toggle Triac A\n");
|
PRINTF("Toggle Triac A\n");
|
||||||
// Toggle Triac A
|
// Toggle Triac A
|
||||||
if(optriac_sensor.value(OPTRIAC_SENSOR_A) == 0){
|
if(optriac_sensor.value(OPTRIAC_SENSOR_1) == 0){
|
||||||
optriac_sensor.configure(OPTRIAC_SENSOR_A,1);
|
optriac_sensor.configure(OPTRIAC_SENSOR_1,1);
|
||||||
led1_on();
|
led1_on();
|
||||||
}else{
|
}else{
|
||||||
optriac_sensor.configure(OPTRIAC_SENSOR_A,0);
|
optriac_sensor.configure(OPTRIAC_SENSOR_1,0);
|
||||||
led1_off();
|
led1_off();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,11 +786,11 @@ PROCESS_THREAD(rest_server_example, ev, data)
|
||||||
ext6 = is_button_ext6();
|
ext6 = is_button_ext6();
|
||||||
PRINTF("Toggle Triac B\n");
|
PRINTF("Toggle Triac B\n");
|
||||||
// Toggle Triac B
|
// Toggle Triac B
|
||||||
if(optriac_sensor.value(OPTRIAC_SENSOR_B) == 0){
|
if(optriac_sensor.value(OPTRIAC_SENSOR_2) == 0){
|
||||||
optriac_sensor.configure(OPTRIAC_SENSOR_B,1);
|
optriac_sensor.configure(OPTRIAC_SENSOR_2,1);
|
||||||
led2_on();
|
led2_on();
|
||||||
}else{
|
}else{
|
||||||
optriac_sensor.configure(OPTRIAC_SENSOR_B,0);
|
optriac_sensor.configure(OPTRIAC_SENSOR_2,0);
|
||||||
led2_off();
|
led2_off();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,14 +62,14 @@ void
|
||||||
key_init(void)
|
key_init(void)
|
||||||
{
|
{
|
||||||
// Pairing Button
|
// Pairing Button
|
||||||
PORTB |= (1<<PORTB4); // Set port PORTE bint 4 with pullup resistor
|
// PORTB |= (1<<PORTE0); // Set port PORTE pint 0 with pullup resistor
|
||||||
DDRB |= (1<<DDB4); // Set pin as input
|
// DDRB |= (1<<DDE0); // Set pin as input
|
||||||
// ext1
|
// ext1
|
||||||
PORTB |= (1<<PORTB5); // Set port PORTE bint 5 with pullup resistor
|
PORTF |= (1<<PORTF6); // Set port PORTF pint 6 with pullup resistor
|
||||||
DDRB |= (1<<DDB5); // Set pin as input
|
DDRF |= (1<<DDF6); // Set pin as input
|
||||||
// ext2
|
// ext2
|
||||||
PORTB |= (1<<PORTB6); // Set port PORTE bint 6 with pullup resistor
|
PORTF |= (1<<PORTF7); // Set port PORTF pint 7 with pullup resistor
|
||||||
DDRB |= (1<<DDB6); // Set pin as input
|
DDRF |= (1<<DDF7); // Set pin as input
|
||||||
// Interrupt
|
// Interrupt
|
||||||
//PCICR |= _BV(PCIE0);
|
//PCICR |= _BV(PCIE0);
|
||||||
//PCMSK0 |= _BV(PCINT4) | _BV(PCINT5) | _BV(PCINT6);
|
//PCMSK0 |= _BV(PCINT4) | _BV(PCINT5) | _BV(PCINT6);
|
||||||
|
@ -87,7 +87,7 @@ uint8_t
|
||||||
is_button_ext4(void)
|
is_button_ext4(void)
|
||||||
{
|
{
|
||||||
/* Return true if button has been pressed. */
|
/* Return true if button has been pressed. */
|
||||||
if ( PINB & (1<<PINB4) ) {
|
if ( PINE & (1<<PINE0) ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -98,7 +98,7 @@ uint8_t
|
||||||
is_button_ext5(void)
|
is_button_ext5(void)
|
||||||
{
|
{
|
||||||
/* Return true if button has been pressed. */
|
/* Return true if button has been pressed. */
|
||||||
if ( PINB & (1<<PINB5) ) {
|
if ( PINF & (1<<PINF6) ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -109,7 +109,7 @@ uint8_t
|
||||||
is_button_ext6(void)
|
is_button_ext6(void)
|
||||||
{
|
{
|
||||||
/* Return true if button has been pressed. */
|
/* Return true if button has been pressed. */
|
||||||
if ( PINB & (1<<PINB6) ) {
|
if ( PINF & (1<<PINF7) ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
|
@ -32,12 +32,6 @@
|
||||||
#ifndef PROJECT_RPL_WEB_CONF_H_
|
#ifndef PROJECT_RPL_WEB_CONF_H_
|
||||||
#define PROJECT_RPL_WEB_CONF_H_
|
#define PROJECT_RPL_WEB_CONF_H_
|
||||||
|
|
||||||
//#define PLATFORM_HAS_LEDS 1
|
|
||||||
//#define PLATFORM_HAS_BUTTON 1
|
|
||||||
#define PLATFORM_HAS_OPTRIAC 1
|
|
||||||
#define PLATFORM_HAS_TEMPERATURE 1
|
|
||||||
#define PLATFORM_HAS_BATTERY 1
|
|
||||||
|
|
||||||
#define SICSLOWPAN_CONF_FRAG 1
|
#define SICSLOWPAN_CONF_FRAG 1
|
||||||
|
|
||||||
/* For Debug: Dont allow MCU sleeping between channel checks */
|
/* For Debug: Dont allow MCU sleeping between channel checks */
|
||||||
|
|
|
@ -1,227 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<simconf>
|
|
||||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mrm</project>
|
|
||||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/mspsim</project>
|
|
||||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/avrora</project>
|
|
||||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/serial_socket</project>
|
|
||||||
<project EXPORT="discard">[CONTIKI_DIR]/tools/cooja/apps/collect-view</project>
|
|
||||||
<simulation>
|
|
||||||
<title>REST with RPL router</title>
|
|
||||||
<delaytime>-2147483648</delaytime>
|
|
||||||
<randomseed>123456</randomseed>
|
|
||||||
<motedelay_us>1000000</motedelay_us>
|
|
||||||
<radiomedium>
|
|
||||||
se.sics.cooja.radiomediums.UDGM
|
|
||||||
<transmitting_range>50.0</transmitting_range>
|
|
||||||
<interference_range>50.0</interference_range>
|
|
||||||
<success_ratio_tx>1.0</success_ratio_tx>
|
|
||||||
<success_ratio_rx>1.0</success_ratio_rx>
|
|
||||||
</radiomedium>
|
|
||||||
<events>
|
|
||||||
<logoutput>40000</logoutput>
|
|
||||||
</events>
|
|
||||||
<motetype>
|
|
||||||
se.sics.cooja.mspmote.SkyMoteType
|
|
||||||
<identifier>rplroot</identifier>
|
|
||||||
<description>Sky RPL Root</description>
|
|
||||||
<source EXPORT="discard">[CONTIKI_DIR]/examples/ipv6/rpl-border-router/border-router.c</source>
|
|
||||||
<commands EXPORT="discard">make border-router.sky TARGET=sky</commands>
|
|
||||||
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/ipv6/rpl-border-router/border-router.sky</firmware>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyByteRadio</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
|
||||||
</motetype>
|
|
||||||
<motetype>
|
|
||||||
se.sics.cooja.mspmote.SkyMoteType
|
|
||||||
<identifier>server</identifier>
|
|
||||||
<description>Erbium Server</description>
|
|
||||||
<source EXPORT="discard">[CONTIKI_DIR]/examples/er-rest-example/er-example-server.c</source>
|
|
||||||
<commands EXPORT="discard">make er-example-server.sky TARGET=sky</commands>
|
|
||||||
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/er-rest-example/er-example-server.sky</firmware>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyByteRadio</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
|
||||||
</motetype>
|
|
||||||
<motetype>
|
|
||||||
se.sics.cooja.mspmote.SkyMoteType
|
|
||||||
<identifier>client</identifier>
|
|
||||||
<description>Erbium Client</description>
|
|
||||||
<source EXPORT="discard">[CONTIKI_DIR]/examples/er-rest-example/er-example-client.c</source>
|
|
||||||
<commands EXPORT="discard">make er-example-client.sky TARGET=sky</commands>
|
|
||||||
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/er-rest-example/er-example-client.sky</firmware>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.interfaces.MoteAttributes</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspClock</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyByteRadio</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
|
||||||
<moteinterface>se.sics.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
|
||||||
</motetype>
|
|
||||||
<mote>
|
|
||||||
<breakpoints />
|
|
||||||
<interface_config>
|
|
||||||
se.sics.cooja.interfaces.Position
|
|
||||||
<x>33.260163187353555</x>
|
|
||||||
<y>30.643217359962595</y>
|
|
||||||
<z>0.0</z>
|
|
||||||
</interface_config>
|
|
||||||
<interface_config>
|
|
||||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
|
||||||
<id>1</id>
|
|
||||||
</interface_config>
|
|
||||||
<motetype_identifier>rplroot</motetype_identifier>
|
|
||||||
</mote>
|
|
||||||
<mote>
|
|
||||||
<breakpoints />
|
|
||||||
<interface_config>
|
|
||||||
se.sics.cooja.interfaces.Position
|
|
||||||
<x>46.57186415376375</x>
|
|
||||||
<y>40.35946215910942</y>
|
|
||||||
<z>0.0</z>
|
|
||||||
</interface_config>
|
|
||||||
<interface_config>
|
|
||||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
|
||||||
<id>2</id>
|
|
||||||
</interface_config>
|
|
||||||
<motetype_identifier>server</motetype_identifier>
|
|
||||||
</mote>
|
|
||||||
<mote>
|
|
||||||
<breakpoints />
|
|
||||||
<interface_config>
|
|
||||||
se.sics.cooja.interfaces.Position
|
|
||||||
<x>18.638049428485125</x>
|
|
||||||
<y>47.55034515769599</y>
|
|
||||||
<z>0.0</z>
|
|
||||||
</interface_config>
|
|
||||||
<interface_config>
|
|
||||||
se.sics.cooja.mspmote.interfaces.MspMoteID
|
|
||||||
<id>3</id>
|
|
||||||
</interface_config>
|
|
||||||
<motetype_identifier>client</motetype_identifier>
|
|
||||||
</mote>
|
|
||||||
</simulation>
|
|
||||||
<plugin>
|
|
||||||
se.sics.cooja.plugins.SimControl
|
|
||||||
<width>259</width>
|
|
||||||
<z>0</z>
|
|
||||||
<height>179</height>
|
|
||||||
<location_x>0</location_x>
|
|
||||||
<location_y>0</location_y>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
se.sics.cooja.plugins.Visualizer
|
|
||||||
<plugin_config>
|
|
||||||
<skin>se.sics.cooja.plugins.skins.IDVisualizerSkin</skin>
|
|
||||||
<skin>se.sics.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
|
||||||
<skin>se.sics.cooja.plugins.skins.MoteTypeVisualizerSkin</skin>
|
|
||||||
<skin>se.sics.cooja.plugins.skins.AttributeVisualizerSkin</skin>
|
|
||||||
<skin>se.sics.cooja.plugins.skins.LEDVisualizerSkin</skin>
|
|
||||||
<skin>se.sics.cooja.plugins.skins.AddressVisualizerSkin</skin>
|
|
||||||
<viewport>3.61568947862321 0.0 0.0 3.61568947862321 15.610600779367 -85.92728269158351</viewport>
|
|
||||||
</plugin_config>
|
|
||||||
<width>300</width>
|
|
||||||
<z>2</z>
|
|
||||||
<height>178</height>
|
|
||||||
<location_x>261</location_x>
|
|
||||||
<location_y>1</location_y>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
se.sics.cooja.plugins.LogListener
|
|
||||||
<plugin_config>
|
|
||||||
<filter />
|
|
||||||
<coloring />
|
|
||||||
</plugin_config>
|
|
||||||
<width>762</width>
|
|
||||||
<z>3</z>
|
|
||||||
<height>491</height>
|
|
||||||
<location_x>2</location_x>
|
|
||||||
<location_y>182</location_y>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
se.sics.cooja.plugins.RadioLogger
|
|
||||||
<plugin_config>
|
|
||||||
<split>150</split>
|
|
||||||
<analyzers name="6lowpan" />
|
|
||||||
</plugin_config>
|
|
||||||
<width>451</width>
|
|
||||||
<z>-1</z>
|
|
||||||
<height>305</height>
|
|
||||||
<location_x>73</location_x>
|
|
||||||
<location_y>140</location_y>
|
|
||||||
<minimized>true</minimized>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
SerialSocketServer
|
|
||||||
<mote_arg>0</mote_arg>
|
|
||||||
<width>422</width>
|
|
||||||
<z>4</z>
|
|
||||||
<height>74</height>
|
|
||||||
<location_x>578</location_x>
|
|
||||||
<location_y>18</location_y>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
se.sics.cooja.plugins.TimeLine
|
|
||||||
<plugin_config>
|
|
||||||
<mote>0</mote>
|
|
||||||
<mote>1</mote>
|
|
||||||
<mote>2</mote>
|
|
||||||
<showRadioRXTX />
|
|
||||||
<showRadioHW />
|
|
||||||
<showLEDs />
|
|
||||||
<showWatchpoints />
|
|
||||||
<split>125</split>
|
|
||||||
<zoomfactor>25.49079397896416</zoomfactor>
|
|
||||||
</plugin_config>
|
|
||||||
<width>1624</width>
|
|
||||||
<z>5</z>
|
|
||||||
<height>252</height>
|
|
||||||
<location_x>6</location_x>
|
|
||||||
<location_y>712</location_y>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
se.sics.cooja.plugins.MoteInterfaceViewer
|
|
||||||
<mote_arg>2</mote_arg>
|
|
||||||
<plugin_config>
|
|
||||||
<interface>Serial port</interface>
|
|
||||||
<scrollpos>0,0</scrollpos>
|
|
||||||
</plugin_config>
|
|
||||||
<width>853</width>
|
|
||||||
<z>1</z>
|
|
||||||
<height>491</height>
|
|
||||||
<location_x>765</location_x>
|
|
||||||
<location_y>182</location_y>
|
|
||||||
</plugin>
|
|
||||||
</simconf>
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue