Fixed Erbium example simulation

This commit is contained in:
Matthias Kovatsch 2011-10-10 14:16:27 +02:00
parent dd71927576
commit ce6f8de078
4 changed files with 45 additions and 39 deletions

View file

@ -24,8 +24,7 @@ CFLAGS += -DUIP_CONF_IPV6_RPL=1
endif
# linker optimizations
CFLAGS += -ffunction-sections
LDFLAGS += -Wl,--gc-sections,--undefined=_reset_vector__,--undefined=InterruptVectors,--undefined=_copy_data_init__,--undefined=_clear_bss_init__,--undefined=_end_of_init__
SMALL=1
# REST framework, requires WITH_COAP
ifeq ($(WITH_COAP), 7)

View file

@ -34,9 +34,11 @@
#define SICSLOWPAN_CONF_FRAG 1
#ifndef QUEUEBUF_CONF_NUM
#define QUEUEBUF_CONF_NUM 6
#endif
/* Save some memory for the sky platform */
#undef UIP_CONF_DS6_NBR_NBU
#define UIP_CONF_DS6_NBR_NBU 10
#undef UIP_CONF_DS6_ROUTE_NBU
#define UIP_CONF_DS6_ROUTE_NBU 10
/* Increase rpl-border-router IP-buffer when using 128 */
#ifndef REST_MAX_CHUNK_SIZE
@ -62,4 +64,6 @@
#define WEBSERVER_CONF_CFS_CONNS 2
#endif
#endif /* __PROJECT_RPL_WEB_CONF_H__ */

View file

@ -93,7 +93,7 @@
* Resources are defined by the RESOURCE macro.
* Signature: resource name, the RESTful methods it handles, and its URI path (omitting the leading slash).
*/
RESOURCE(helloworld, METHOD_GET, "hello", "title=\"Hello world (set length with ?len query)\";rt=\"Text\"");
RESOURCE(helloworld, METHOD_GET, "hello", "title=\"Hello world: ?len=0..\";rt=\"Text\"");
/*
* A handler function named [resource name]_handler must be implemented for each RESOURCE.
@ -105,8 +105,9 @@ void
helloworld_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{
const char *len = NULL;
int length = 12; /* ------->| */
char *message = "Hello World! ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789?!at 86 now+2+4at 99 now100..105..110..115..120..125..130..135..140..145..150..155..160";
/* Some data that has the length up to REST_MAX_CHUNK_SIZE. For more, see the chunk resource. */
char const * const message = "Hello World! ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxy";
int length = 12; /* |<-------->| */
/* The query string can be retrieved by rest_get_query() or parsed for its key-value pairs. */
if (REST.get_query_variable(request, "len", &len)) {
@ -124,7 +125,7 @@ helloworld_handler(void* request, void* response, uint8_t *buffer, uint16_t pref
}
/* This resource mirrors the incoming request. It shows how to access the options and how to set them for the response. */
RESOURCE(mirror, METHOD_GET | METHOD_POST | METHOD_PUT | METHOD_DELETE | HAS_SUB_RESOURCES, "mirror", "title=\"Returns your decoded message\";rt=\"Debug\"");
RESOURCE(mirror, METHOD_GET | METHOD_POST | METHOD_PUT | METHOD_DELETE, "mirror", "title=\"Returns your decoded message\";rt=\"Debug\"");
void
mirror_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
@ -283,7 +284,7 @@ mirror_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
*/
RESOURCE(chunks, METHOD_GET, "chunks", "title=\"Blockwise demo\";rt=\"Data\"");
#define CHUNKS_TOTAL 1030
#define CHUNKS_TOTAL 2050
void
chunks_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
@ -294,7 +295,8 @@ chunks_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
if (*offset>=CHUNKS_TOTAL)
{
REST.set_response_status(response, REST.status.BAD_OPTION);
REST.set_response_payload(response, (uint8_t*)"Block out of scope", 18);
/* A block error message should not exceed the minimum block size (16). */
REST.set_response_payload(response, (uint8_t*)"BlockOutOfScope", 15);
return;
}
@ -310,7 +312,7 @@ chunks_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
REST.set_response_payload(response, buffer, strpos);
/* Signal chunk awareness of resource to framework. */
/* IMPORTANT for chunk-wise resources: Signal chunk awareness to REST engine. */
*offset += strpos;
/* Signal end of resource. */
@ -395,7 +397,7 @@ event_event_handler(resource_t *r)
#if defined (PLATFORM_HAS_LEDS)
/*A simple actuator example, depending on the color query parameter and post variable mode, corresponding led is activated or deactivated*/
RESOURCE(led, METHOD_POST | METHOD_PUT , "leds", "title=\"Led control (use ?color=red|green|blue and POST/PUT mode=on|off)\";rt=\"Control\"");
RESOURCE(led, METHOD_POST | METHOD_PUT , "leds", "title=\"LEDs: ?color=r|g|b, POST/PUT mode=on|off\";rt=\"Control\"");
void
led_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
@ -409,11 +411,11 @@ led_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_s
if ((len=REST.get_query_variable(request, "color", &color))) {
PRINTF("color %.*s\n", len, color);
if (strncmp(color, "red", len)==0) {
if (strncmp(color, "r", len)==0) {
led = LEDS_RED;
} else if(strncmp(color,"green", len)==0) {
} else if(strncmp(color,"g", len)==0) {
led = LEDS_GREEN;
} else if (strncmp(color,"blue", len)==0) {
} else if (strncmp(color,"b", len)==0) {
led = LEDS_BLUE;
} else {
success = 0;
@ -524,7 +526,6 @@ battery_handler(void* request, void* response, uint8_t *buffer, uint16_t preferr
}
#endif /* PLATFORM_HAS_BATTERY */
PROCESS(rest_server_example, "Rest Server Example");
AUTOSTART_PROCESSES(&rest_server_example);
@ -569,6 +570,7 @@ PROCESS_THREAD(rest_server_example, ev, data)
rest_activate_resource(&resource_led);
rest_activate_resource(&resource_toggle);
#endif /* PLATFORM_HAS_LEDS */
#if defined (PLATFORM_HAS_LIGHT)
SENSORS_ACTIVATE(light_sensor);
rest_activate_resource(&resource_light);

View file

@ -47,9 +47,9 @@
se.sics.cooja.mspmote.SkyMoteType
<identifier>skyweb</identifier>
<description>Rest</description>
<source EXPORT="discard">[CONTIKI_DIR]/examples/rest-example/rest-server-example.c</source>
<source EXPORT="discard">[CONTIKI_DIR]/examples/er-rest-example/rest-server-example.c</source>
<commands EXPORT="discard">make rest-server-example.sky TARGET=sky</commands>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/rest-example/rest-server-example.sky</firmware>
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/er-rest-example/rest-server-example.sky</firmware>
<moteinterface>se.sics.cooja.interfaces.Position</moteinterface>
<moteinterface>se.sics.cooja.interfaces.RimeAddress</moteinterface>
<moteinterface>se.sics.cooja.interfaces.IPAddress</moteinterface>
@ -98,7 +98,7 @@
<plugin>
se.sics.cooja.plugins.SimControl
<width>259</width>
<z>1</z>
<z>5</z>
<height>179</height>
<location_x>0</location_x>
<location_y>0</location_y>
@ -115,21 +115,22 @@
<viewport>7.9849281638410705 0.0 0.0 7.9849281638410705 -133.27812697619663 -225.04752569190535</viewport>
</plugin_config>
<width>300</width>
<z>0</z>
<z>4</z>
<height>175</height>
<location_x>371</location_x>
<location_y>2</location_y>
<location_x>263</location_x>
<location_y>3</location_y>
</plugin>
<plugin>
se.sics.cooja.plugins.LogListener
<plugin_config>
<filter />
<coloring />
</plugin_config>
<width>762</width>
<z>3</z>
<width>560</width>
<z>1</z>
<height>326</height>
<location_x>12</location_x>
<location_y>294</location_y>
<location_x>1</location_x>
<location_y>293</location_y>
</plugin>
<plugin>
se.sics.cooja.plugins.RadioLogger
@ -148,10 +149,10 @@
SerialSocketServer
<mote_arg>0</mote_arg>
<width>422</width>
<z>5</z>
<z>2</z>
<height>74</height>
<location_x>1234</location_x>
<location_y>93</location_y>
<location_x>39</location_x>
<location_y>199</location_y>
</plugin>
<plugin>
se.sics.cooja.plugins.TimeLine
@ -166,10 +167,10 @@
<zoomfactor>25.49079397896416</zoomfactor>
</plugin_config>
<width>1624</width>
<z>4</z>
<z>3</z>
<height>252</height>
<location_x>166</location_x>
<location_y>699</location_y>
<location_x>4</location_x>
<location_y>622</location_y>
</plugin>
<plugin>
se.sics.cooja.plugins.MoteInterfaceViewer
@ -178,11 +179,11 @@
<interface>Serial port</interface>
<scrollpos>0,0</scrollpos>
</plugin_config>
<width>662</width>
<z>2</z>
<height>362</height>
<location_x>7</location_x>
<location_y>221</location_y>
<width>702</width>
<z>0</z>
<height>646</height>
<location_x>564</location_x>
<location_y>2</location_y>
</plugin>
</simconf>