added max-age and content-format

Fork of mbedConnectorInterface by Doug Anson

Committer:
michaeljkoster
Date:
Tue Apr 14 04:00:01 2015 +0000
Revision:
52:822611156e35
Parent:
27:eb6818ad257a
added interfaces for max-age and content-format

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 24:a6915e19814e 1 /**
ansond 24:a6915e19814e 2 * @file DataWrapper.h
ansond 26:b06a19916f05 3 * @brief mbed CoAP Endpoint Data Wrapper class (header)
ansond 24:a6915e19814e 4 * @author Doug Anson
ansond 24:a6915e19814e 5 * @version 1.0
ansond 24:a6915e19814e 6 * @see
ansond 24:a6915e19814e 7 *
ansond 24:a6915e19814e 8 * Copyright (c) 2014
ansond 24:a6915e19814e 9 *
ansond 24:a6915e19814e 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 24:a6915e19814e 11 * you may not use this file except in compliance with the License.
ansond 24:a6915e19814e 12 * You may obtain a copy of the License at
ansond 24:a6915e19814e 13 *
ansond 24:a6915e19814e 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 24:a6915e19814e 15 *
ansond 24:a6915e19814e 16 * Unless required by applicable law or agreed to in writing, software
ansond 24:a6915e19814e 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 24:a6915e19814e 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 24:a6915e19814e 19 * See the License for the specific language governing permissions and
ansond 24:a6915e19814e 20 * limitations under the License.
ansond 24:a6915e19814e 21 */
ansond 24:a6915e19814e 22
ansond 24:a6915e19814e 23 #ifndef __DATA_WRAPPER_H__
ansond 24:a6915e19814e 24 #define __DATA_WRAPPER_H__
ansond 24:a6915e19814e 25
ansond 24:a6915e19814e 26 // mbed support
ansond 24:a6915e19814e 27 #include "mbed.h"
ansond 24:a6915e19814e 28
ansond 24:a6915e19814e 29 class DataWrapper {
ansond 24:a6915e19814e 30 public:
ansond 24:a6915e19814e 31 /**
ansond 24:a6915e19814e 32 Default constructor
ansond 26:b06a19916f05 33 @param data input the buffer to use for operations
ansond 26:b06a19916f05 34 @param data_length input the data length
ansond 24:a6915e19814e 35 */
ansond 24:a6915e19814e 36 DataWrapper(uint8_t *data,int data_length);
ansond 24:a6915e19814e 37
ansond 24:a6915e19814e 38 /**
ansond 25:1fc958ac14d1 39 Default constructor (alloc)
ansond 26:b06a19916f05 40 @param data_length input the data length (alloc)
ansond 25:1fc958ac14d1 41 */
ansond 25:1fc958ac14d1 42 DataWrapper(int data_length);
ansond 25:1fc958ac14d1 43
ansond 25:1fc958ac14d1 44 /**
ansond 24:a6915e19814e 45 Default copy constructor
ansond 26:b06a19916f05 46 @param data input the DataWrapper to copy
ansond 24:a6915e19814e 47 */
ansond 24:a6915e19814e 48 DataWrapper(const DataWrapper &data);
ansond 24:a6915e19814e 49
ansond 24:a6915e19814e 50 /**
ansond 24:a6915e19814e 51 Destructor
ansond 24:a6915e19814e 52 */
ansond 24:a6915e19814e 53 virtual ~DataWrapper();
ansond 24:a6915e19814e 54
ansond 24:a6915e19814e 55 /**
ansond 26:b06a19916f05 56 Wrap the data (trivial in base class)
ansond 26:b06a19916f05 57 @param data input the data to wrap
ansond 26:b06a19916f05 58 @param data_length input the length of the data to wrap
ansond 24:a6915e19814e 59 */
ansond 24:a6915e19814e 60 virtual void wrap(uint8_t *data,int data_length);
ansond 24:a6915e19814e 61
ansond 24:a6915e19814e 62 /**
ansond 26:b06a19916f05 63 Unwrap the data (trivial in base class)
ansond 26:b06a19916f05 64 @param data input the data to unwrap
ansond 26:b06a19916f05 65 @param data_length input the length of the data to unwrap
ansond 24:a6915e19814e 66 */
ansond 24:a6915e19814e 67 virtual void unwrap(uint8_t *data,int data_length);
ansond 24:a6915e19814e 68
ansond 24:a6915e19814e 69 /**
ansond 24:a6915e19814e 70 Get the wrap/unwrap result
ansond 24:a6915e19814e 71 @return pointer to the data buffer of DataWrapper containing the wrap/unwrap result
ansond 24:a6915e19814e 72 */
ansond 24:a6915e19814e 73 uint8_t *get() { return this->m_data; }
ansond 24:a6915e19814e 74
ansond 24:a6915e19814e 75 /**
ansond 24:a6915e19814e 76 Get the wrap/unwrap result length
ansond 24:a6915e19814e 77 @return length of the wrap/unwrap data result
ansond 24:a6915e19814e 78 */
ansond 24:a6915e19814e 79 int length() { return this->m_data_length; }
ansond 24:a6915e19814e 80
ansond 24:a6915e19814e 81 /**
ansond 24:a6915e19814e 82 Reset the wrapper
ansond 24:a6915e19814e 83 */
ansond 24:a6915e19814e 84 void reset();
ansond 26:b06a19916f05 85
ansond 27:eb6818ad257a 86 /**
ansond 27:eb6818ad257a 87 Set the new application key
ansond 27:eb6818ad257a 88 @param appkey input the new appkey (encrypted) to set
ansond 27:eb6818ad257a 89 @param appkey_length input the new appkey (encrypted) length
ansond 27:eb6818ad257a 90 */
ansond 27:eb6818ad257a 91 virtual void setAppKey(uint8_t *appkey,int appkey_length);
ansond 27:eb6818ad257a 92
ansond 25:1fc958ac14d1 93 protected:
ansond 25:1fc958ac14d1 94 uint8_t *m_data;
ansond 25:1fc958ac14d1 95
ansond 24:a6915e19814e 96 private:
ansond 25:1fc958ac14d1 97 bool m_alloced;
ansond 24:a6915e19814e 98 int m_data_length;
ansond 25:1fc958ac14d1 99 int m_data_length_max;
ansond 24:a6915e19814e 100 };
ansond 24:a6915e19814e 101
ansond 24:a6915e19814e 102 #endif // __DATA_WRAPPER_H__