Restructured Erbium example resources.

This commit is contained in:
Matthias Kovatsch 2011-12-07 20:51:03 +01:00
parent 36763cabbd
commit 6e0bb440ea

View file

@ -125,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, "mirror", "title=\"Returns your decoded message\";rt=\"Debug\""); RESOURCE(mirror, METHOD_GET | METHOD_POST | METHOD_PUT | METHOD_DELETE, "debug/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)
@ -282,7 +282,7 @@ mirror_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
* These chunk-wise resources must set the offset value to its new position or -1 of the end is reached. * These chunk-wise resources must set the offset value to its new position or -1 of the end is reached.
* (The offset for CoAP's blockwise transfer can go up to 2'147'481'600 = ~2047 M for block size 2048 (reduced to 1024 in observe-03.) * (The offset for CoAP's blockwise transfer can go up to 2'147'481'600 = ~2047 M for block size 2048 (reduced to 1024 in observe-03.)
*/ */
RESOURCE(chunks, METHOD_GET, "chunks", "title=\"Blockwise demo\";rt=\"Data\""); RESOURCE(chunks, METHOD_GET, "debug/chunks", "title=\"Blockwise demo\";rt=\"Data\"");
#define CHUNKS_TOTAL 2050 #define CHUNKS_TOTAL 2050
@ -335,7 +335,7 @@ chunks_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
* It takes an additional period parameter, which defines the interval to call [name]_periodic_handler(). * It takes an additional period parameter, which defines the interval to call [name]_periodic_handler().
* A default post_handler takes care of subscriptions by managing a list of subscribers to notify. * A default post_handler takes care of subscriptions by managing a list of subscribers to notify.
*/ */
PERIODIC_RESOURCE(polling, METHOD_GET, "poll", "title=\"Periodic demo\";rt=\"Observable\"", 5*CLOCK_SECOND); PERIODIC_RESOURCE(polling, METHOD_GET, "debug/poll", "title=\"Periodic demo\";rt=\"Observable\"", 5*CLOCK_SECOND);
void void
polling_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) polling_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
@ -372,7 +372,7 @@ polling_periodic_handler(resource_t *r)
* Additionally takes a period parameter that defines the interval to call [name]_periodic_handler(). * Additionally takes a period parameter that defines the interval to call [name]_periodic_handler().
* A default post_handler takes care of subscriptions and manages a list of subscribers to notify. * A default post_handler takes care of subscriptions and manages a list of subscribers to notify.
*/ */
EVENT_RESOURCE(event, METHOD_GET, "event", "title=\"Event demo\";rt=\"Observable\""); EVENT_RESOURCE(event, METHOD_GET, "sensors/button", "title=\"Event demo\";rt=\"Observable\"");
void void
event_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) event_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
@ -405,7 +405,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=\"LEDs: ?color=r|g|b, POST/PUT mode=on|off\";rt=\"Control\""); RESOURCE(led, METHOD_POST | METHOD_PUT , "actuators/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)
@ -452,7 +452,7 @@ led_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_s
} }
/* A simple actuator example. Toggles the red led */ /* A simple actuator example. Toggles the red led */
RESOURCE(toggle, METHOD_GET | METHOD_PUT | METHOD_POST, "toggle", "title=\"Red LED\";rt=\"Control\""); 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) toggle_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
@ -462,7 +462,7 @@ toggle_handler(void* request, void* response, uint8_t *buffer, uint16_t preferre
#if defined (PLATFORM_HAS_LIGHT) #if defined (PLATFORM_HAS_LIGHT)
/* 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(light, METHOD_GET, "light", "title=\"Photosynthetic and solar light (supports JSON)\";rt=\"LightSensor\""); RESOURCE(light, METHOD_GET, "sensors/light", "title=\"Photosynthetic and solar light (supports JSON)\";rt=\"LightSensor\"");
void void
light_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) light_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset)
{ {
@ -503,7 +503,7 @@ light_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred
#if defined (PLATFORM_HAS_BATTERY) #if 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, "battery", "title=\"Battery status\";rt=\"Battery\""); RESOURCE(battery, METHOD_GET, "sensors/battery", "title=\"Battery status\";rt=\"Battery\"");
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)
{ {