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 endif
# linker optimizations # linker optimizations
CFLAGS += -ffunction-sections SMALL=1
LDFLAGS += -Wl,--gc-sections,--undefined=_reset_vector__,--undefined=InterruptVectors,--undefined=_copy_data_init__,--undefined=_clear_bss_init__,--undefined=_end_of_init__
# REST framework, requires WITH_COAP # REST framework, requires WITH_COAP
ifeq ($(WITH_COAP), 7) ifeq ($(WITH_COAP), 7)

View file

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

View file

@ -93,7 +93,7 @@
* 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(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. * 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) helloworld_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
const char *len = NULL; const char *len = NULL;
int length = 12; /* ------->| */ /* Some data that has the length up to REST_MAX_CHUNK_SIZE. For more, see the chunk resource. */
char *message = "Hello World! ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789?!at 86 now+2+4at 99 now100..105..110..115..120..125..130..135..140..145..150..155..160"; 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. */ /* 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)) { 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. */ /* 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 void
mirror_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) 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\""); RESOURCE(chunks, METHOD_GET, "chunks", "title=\"Blockwise demo\";rt=\"Data\"");
#define CHUNKS_TOTAL 1030 #define CHUNKS_TOTAL 2050
void void
chunks_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) 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) if (*offset>=CHUNKS_TOTAL)
{ {
REST.set_response_status(response, REST.status.BAD_OPTION); 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; return;
} }
@ -310,7 +312,7 @@ chunks_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
REST.set_response_payload(response, buffer, strpos); 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; *offset += strpos;
/* Signal end of resource. */ /* Signal end of resource. */
@ -395,7 +397,7 @@ event_event_handler(resource_t *r)
#if defined (PLATFORM_HAS_LEDS) #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*/ /*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 void
led_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) 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))) { if ((len=REST.get_query_variable(request, "color", &color))) {
PRINTF("color %.*s\n", len, color); PRINTF("color %.*s\n", len, color);
if (strncmp(color, "red", len)==0) { if (strncmp(color, "r", len)==0) {
led = LEDS_RED; led = LEDS_RED;
} else if(strncmp(color,"green", len)==0) { } else if(strncmp(color,"g", len)==0) {
led = LEDS_GREEN; led = LEDS_GREEN;
} else if (strncmp(color,"blue", len)==0) { } else if (strncmp(color,"b", len)==0) {
led = LEDS_BLUE; led = LEDS_BLUE;
} else { } else {
success = 0; success = 0;
@ -524,7 +526,6 @@ battery_handler(void* request, void* response, uint8_t *buffer, uint16_t preferr
} }
#endif /* PLATFORM_HAS_BATTERY */ #endif /* PLATFORM_HAS_BATTERY */
PROCESS(rest_server_example, "Rest Server Example"); PROCESS(rest_server_example, "Rest Server Example");
AUTOSTART_PROCESSES(&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_led);
rest_activate_resource(&resource_toggle); rest_activate_resource(&resource_toggle);
#endif /* PLATFORM_HAS_LEDS */ #endif /* PLATFORM_HAS_LEDS */
#if defined (PLATFORM_HAS_LIGHT) #if defined (PLATFORM_HAS_LIGHT)
SENSORS_ACTIVATE(light_sensor); SENSORS_ACTIVATE(light_sensor);
rest_activate_resource(&resource_light); rest_activate_resource(&resource_light);

View file

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