|
Contiki 3.x
|
Sample resource. More...
#include "er-server.h"#include "rest-engine.h"#include "pb_decode.h"#include "pb_encode.h"#include "readings.pb.h"#include "store.h"#include <inttypes.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include "debug.h"Go to the source code of this file.
Macros | |
| #define | MAX_URI_LENGTH 20 |
| Maximum length of a URI. | |
| #define | NO_SAMPLE_ID -1 |
| Indicates no trailing sample id was found in the URI. | |
| #define | INVALID_SAMPLE_ID -2 |
| Indicates a sample id was found in the URI, but that it could not be sucesfully parsed. | |
| #define | SEPARATOR_CHAR '/' |
| The separator used in URIs, either as a character, or as a string literal. | |
Functions | |
| static void | res_get_handler (void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) |
| Get handler for Samples. More... | |
| static void | res_delete_handler (void *request, void *response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset) |
| Delete handler for Samples. More... | |
| static int16_t | parse_sample_id (void *request) |
| Parse a trailing sample id from a URI. More... | |
| PARENT_RESOURCE (res_sample,"Sample", res_get_handler, NULL, NULL, res_delete_handler) | |
| Sample ressource. More... | |
Sample resource.
Serves stored samples, and can delete them. Arthur Fabre 2015
Definition in file res_sample.c.
| PARENT_RESOURCE | ( | res_sample | , |
| "Sample" | , | ||
| res_get_handler | , | ||
| NULL | , | ||
| NULL | , | ||
| res_delete_handler | |||
| ) |
Sample ressource.
Parent ressource as we use URL based parametes (like GET /sample/32)
|
static |
Parse a trailing sample id from a URI.
Deals with validating the ID, trailing slashes.
Definition at line 157 of file res_sample.c.
References INVALID_SAMPLE_ID, MAX_URI_LENGTH, NO_SAMPLE_ID, NULL, and SEPARATOR_CHAR.
Referenced by res_delete_handler(), and res_get_handler().
|
static |
Delete handler for Samples.
Supports deleting arbitrary Samples. Format is DELETE /sample/23 to delete sample #23
Definition at line 135 of file res_sample.c.
References INVALID_SAMPLE_ID, NO_SAMPLE_ID, parse_sample_id(), and store_delete_sample().
|
static |
Get handler for Samples.
Supports the optional param id. Serves latest if id isn't specified. Format is GET /sample/23 to get sample #23. GET /sample to get the latest sample.
Definition at line 72 of file res_sample.c.
References INVALID_SAMPLE_ID, NO_SAMPLE_ID, parse_sample_id(), store_get_latest_raw_sample(), and store_get_raw_sample().
1.8.6