Factor resources, fix time

Now there is a generic resource that can generate and parse
application/json as well as text/plain. It can be re-used, only the
from_string and to_string routines have to be written and the resource
properly set up. A new resource format is specified, see
GENERIC_RESOURCE in, e.g., examples/osd/pwm-example. This is now used in
all my examples, namely pwm-example, arduino-sketch, wallclock-time.

There was an off by one error for the month in time formatting (in
gmtime and localtime). And the leap-year computation was broken. Both
fixed now, so we get a correct date. For localtime we are still 2 hours
off because daylight saving isn't implemented yet.

Also renamed gmtime to utc.
This commit is contained in:
Ralf Schlatterbeck 2014-06-27 22:25:51 +02:00
parent 4f20df042f
commit d5284eebe1
12 changed files with 488 additions and 612 deletions

View file

@ -286,7 +286,7 @@ PROCESS_THREAD(rest_server_example, ev, data)
#endif
rest_activate_resource(&resource_timestamp);
rest_activate_resource(&resource_localtime);
rest_activate_resource(&resource_gmtime);
rest_activate_resource(&resource_utc);
/* Define application-specific events here. */
while(1) {