added max-age and content-format

Fork of mbedConnectorInterface by Doug Anson

Committer:
ansond
Date:
Wed Jan 28 14:43:46 2015 +0000
Revision:
5:a929d65eb385
Parent:
2:853f9ecc12df
Child:
24:a6915e19814e
updates should be close to final

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:b438482ebbfc 1 /**
ansond 0:b438482ebbfc 2 * @file StaticResource.h
ansond 0:b438482ebbfc 3 * @brief mbed CoAP Endpoint Static Resource class
ansond 0:b438482ebbfc 4 * @author Doug Anson/Chris Paola
ansond 0:b438482ebbfc 5 * @version 1.0
sam_grove 2:853f9ecc12df 6 * @see
ansond 0:b438482ebbfc 7 *
ansond 0:b438482ebbfc 8 * Copyright (c) 2014
ansond 0:b438482ebbfc 9 *
ansond 0:b438482ebbfc 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 0:b438482ebbfc 11 * you may not use this file except in compliance with the License.
ansond 0:b438482ebbfc 12 * You may obtain a copy of the License at
ansond 0:b438482ebbfc 13 *
ansond 0:b438482ebbfc 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 0:b438482ebbfc 15 *
ansond 0:b438482ebbfc 16 * Unless required by applicable law or agreed to in writing, software
ansond 0:b438482ebbfc 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 0:b438482ebbfc 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 0:b438482ebbfc 19 * See the License for the specific language governing permissions and
ansond 0:b438482ebbfc 20 * limitations under the License.
ansond 0:b438482ebbfc 21 */
sam_grove 2:853f9ecc12df 22
sam_grove 2:853f9ecc12df 23 #include "StaticResource.h"
sam_grove 2:853f9ecc12df 24
sam_grove 2:853f9ecc12df 25 // NSDL libraries
sam_grove 2:853f9ecc12df 26 #include "nsdl_support.h"
sam_grove 2:853f9ecc12df 27
sam_grove 2:853f9ecc12df 28 // Constructor
sam_grove 2:853f9ecc12df 29 StaticResource::StaticResource(const Logger *logger,const char *name, const char *value) : Resource<string>(logger,string(name),string(value))
sam_grove 2:853f9ecc12df 30 {
sam_grove 2:853f9ecc12df 31 }
sam_grove 2:853f9ecc12df 32
sam_grove 2:853f9ecc12df 33 // Constructor
sam_grove 2:853f9ecc12df 34 StaticResource::StaticResource(const Logger *logger,const char *name,const string value) : Resource<string>(logger,string(name),string(value))
sam_grove 2:853f9ecc12df 35 {
sam_grove 2:853f9ecc12df 36 }
sam_grove 2:853f9ecc12df 37
sam_grove 2:853f9ecc12df 38 // Constructor with buffer lengths
sam_grove 2:853f9ecc12df 39 StaticResource::StaticResource(const Logger *logger,const string name,const string value) : Resource<string>(logger,string(name),string(value))
sam_grove 2:853f9ecc12df 40 {
sam_grove 2:853f9ecc12df 41 }
sam_grove 2:853f9ecc12df 42
sam_grove 2:853f9ecc12df 43 // Copy constructor
sam_grove 2:853f9ecc12df 44 StaticResource::StaticResource(const StaticResource &resource) : Resource<string>((const Resource<string> &)resource)
sam_grove 2:853f9ecc12df 45 {
sam_grove 2:853f9ecc12df 46 }
sam_grove 2:853f9ecc12df 47
sam_grove 2:853f9ecc12df 48 // Destructor
sam_grove 2:853f9ecc12df 49 StaticResource::~StaticResource()
sam_grove 2:853f9ecc12df 50 {
sam_grove 2:853f9ecc12df 51 }
sam_grove 2:853f9ecc12df 52
sam_grove 2:853f9ecc12df 53 // Bind resource to Endpoint
sam_grove 2:853f9ecc12df 54 void StaticResource::bind(void *p)
sam_grove 2:853f9ecc12df 55 {
ansond 0:b438482ebbfc 56 if (p != NULL) {
ansond 0:b438482ebbfc 57 sn_nsdl_resource_info_s *resource_ptr = (sn_nsdl_resource_info_s *)p;
ansond 0:b438482ebbfc 58 const uint8_t *name = (const uint8_t *)(this->getName().c_str());
ansond 0:b438482ebbfc 59 const uint8_t *value = (const uint8_t *)(this->getValue().c_str());
ansond 0:b438482ebbfc 60 int name_length = this->getName().size();
ansond 0:b438482ebbfc 61 int value_length = this->getValue().size();
ansond 0:b438482ebbfc 62 nsdl_create_static_resource(resource_ptr,name_length,(uint8_t *)name,0,0,(uint8_t *)value,value_length);
ansond 5:a929d65eb385 63 this->logger()->log("StaticResource: [%s] value: [%s] bound",name,value);
sam_grove 2:853f9ecc12df 64 } else {
ansond 5:a929d65eb385 65 this->logger()->log("StaticResource: NULL parameter in bind()");
ansond 0:b438482ebbfc 66 }
sam_grove 2:853f9ecc12df 67 }