observe updates

Fork of mbedConnectorInterface by Doug Anson

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DataWrapper.h Source File

DataWrapper.h

Go to the documentation of this file.
00001 /**
00002  * @file    DataWrapper.h
00003  * @brief   mbed CoAP Endpoint Data Wrapper class (header)
00004  * @author  Doug Anson
00005  * @version 1.0
00006  * @see
00007  *
00008  * Copyright (c) 2014
00009  *
00010  * Licensed under the Apache License, Version 2.0 (the "License");
00011  * you may not use this file except in compliance with the License.
00012  * You may obtain a copy of the License at
00013  *
00014  *     http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing, software
00017  * distributed under the License is distributed on an "AS IS" BASIS,
00018  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019  * See the License for the specific language governing permissions and
00020  * limitations under the License.
00021  */
00022 
00023 #ifndef __DATA_WRAPPER_H__
00024 #define __DATA_WRAPPER_H__
00025 
00026 // mbed support
00027 #include "mbed.h"
00028 
00029 class DataWrapper {
00030     public:
00031         /**
00032         Default constructor
00033         @param data input the buffer to use for operations
00034         @param data_length input the data length
00035         */
00036         DataWrapper(uint8_t *data,int data_length);
00037         
00038         /**
00039         Default constructor (alloc)
00040         @param data_length input the data length (alloc)
00041         */
00042         DataWrapper(int data_length);
00043         
00044         /**
00045         Default copy constructor
00046         @param data input the DataWrapper to copy
00047         */
00048         DataWrapper(const DataWrapper &data);
00049         
00050         /**
00051         Destructor
00052         */
00053         virtual ~DataWrapper();
00054         
00055         /**
00056         Wrap the data (trivial in base class)
00057         @param data input the data to wrap
00058         @param data_length input the length of the data to wrap
00059         */
00060         virtual void wrap(uint8_t *data,int data_length);
00061         
00062         /**
00063         Unwrap the data (trivial in base class)
00064         @param data input the data to unwrap
00065         @param data_length input the length of the data to unwrap
00066         */
00067         virtual void unwrap(uint8_t *data,int data_length);
00068         
00069         /**
00070         Get the wrap/unwrap result
00071         @return pointer to the data buffer of DataWrapper containing the wrap/unwrap result
00072         */
00073         uint8_t *get() { return this->m_data; }
00074         
00075         /**
00076         Get the wrap/unwrap result length
00077         @return length of the wrap/unwrap data result
00078         */
00079         int length() { return this->m_data_length; }
00080         
00081         /**
00082         Reset the wrapper
00083         */
00084         void reset();
00085         
00086         /**
00087         Set the new application key
00088         @param appkey input the new appkey (encrypted) to set
00089         @param appkey_length input the new appkey (encrypted) length
00090         */
00091         virtual void setAppKey(uint8_t *appkey,int appkey_length);
00092         
00093     protected:
00094         uint8_t *m_data;
00095         
00096     private:
00097         bool     m_alloced;
00098         int      m_data_length;
00099         int      m_data_length_max;
00100 };
00101 
00102 #endif // __DATA_WRAPPER_H__