/** * \file * Resource for gmtime (utc) / localtime handling * \author * Ralf Schlatterbeck * * \brief get time as a string in utc or localtime */ #include #include #include #include "contiki.h" #include "time.h" #include "time_resource.h" #include "jsonparse.h" /* Only coap 13 for now */ #include "er-coap-13.h" RESOURCE \ ( localtime , METHOD_GET , "clock/localtime" , "title=\"Time\";rt=\"localtime\"" ); RESOURCE \ ( gmtime , METHOD_GET , "clock/utc" , "title=\"Time\";rt=\"utc\"" ); void time_handler ( void* request , void* response , uint8_t *buffer , uint16_t preferred_size , int32_t *offset , struct tm *(*method)(const time_t *,struct tm *) ) { int success = 1; char temp[100]; int index = 0; int length = 0; /* |<-------->| */ struct timeval tv; struct tm tm; int i = 0; int n_acc = 0; const uint16_t *accept = NULL; uint16_t a_ctype = REST.type.APPLICATION_JSON; /* for now json is default */ /* Looks like accepted content-type isn't currently supported */ n_acc = REST.get_header_accept (request, &accept); for (i=0; i