mbed Connector Endpoint interface. This interface permits a mbed endpoint to easily setup MDS resources and emit those resources to an MDS server.

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

Committer:
ansond
Date:
Fri Mar 20 05:32:16 2015 +0000
Revision:
25:1fc958ac14d1
Parent:
24:a6915e19814e
Child:
26:b06a19916f05
updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 24:a6915e19814e 1 /**
ansond 24:a6915e19814e 2 * @file DataWrapper.h
ansond 24:a6915e19814e 3 * @brief mbed CoAP Endpoint Data Wrapper class
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 24:a6915e19814e 33 */
ansond 24:a6915e19814e 34 DataWrapper(uint8_t *data,int data_length);
ansond 24:a6915e19814e 35
ansond 24:a6915e19814e 36 /**
ansond 25:1fc958ac14d1 37 Default constructor (alloc)
ansond 25:1fc958ac14d1 38 */
ansond 25:1fc958ac14d1 39 DataWrapper(int data_length);
ansond 25:1fc958ac14d1 40
ansond 25:1fc958ac14d1 41 /**
ansond 24:a6915e19814e 42 Default copy constructor
ansond 24:a6915e19814e 43 */
ansond 24:a6915e19814e 44 DataWrapper(const DataWrapper &data);
ansond 24:a6915e19814e 45
ansond 24:a6915e19814e 46 /**
ansond 24:a6915e19814e 47 Destructor
ansond 24:a6915e19814e 48 */
ansond 24:a6915e19814e 49 virtual ~DataWrapper();
ansond 24:a6915e19814e 50
ansond 24:a6915e19814e 51 /**
ansond 24:a6915e19814e 52 Wrap the data
ansond 24:a6915e19814e 53 */
ansond 24:a6915e19814e 54 virtual void wrap(uint8_t *data,int data_length);
ansond 24:a6915e19814e 55
ansond 24:a6915e19814e 56 /**
ansond 24:a6915e19814e 57 Unwrap the data
ansond 24:a6915e19814e 58 */
ansond 24:a6915e19814e 59 virtual void unwrap(uint8_t *data,int data_length);
ansond 24:a6915e19814e 60
ansond 24:a6915e19814e 61 /**
ansond 24:a6915e19814e 62 Get the wrap/unwrap result
ansond 24:a6915e19814e 63 @return pointer to the data buffer of DataWrapper containing the wrap/unwrap result
ansond 24:a6915e19814e 64 */
ansond 24:a6915e19814e 65 uint8_t *get() { return this->m_data; }
ansond 24:a6915e19814e 66
ansond 24:a6915e19814e 67 /**
ansond 24:a6915e19814e 68 Get the wrap/unwrap result length
ansond 24:a6915e19814e 69 @return length of the wrap/unwrap data result
ansond 24:a6915e19814e 70 */
ansond 24:a6915e19814e 71 int length() { return this->m_data_length; }
ansond 24:a6915e19814e 72
ansond 24:a6915e19814e 73 /**
ansond 24:a6915e19814e 74 Reset the wrapper
ansond 24:a6915e19814e 75 */
ansond 24:a6915e19814e 76 void reset();
ansond 25:1fc958ac14d1 77 protected:
ansond 25:1fc958ac14d1 78 uint8_t *m_data;
ansond 25:1fc958ac14d1 79
ansond 24:a6915e19814e 80 private:
ansond 25:1fc958ac14d1 81 bool m_alloced;
ansond 24:a6915e19814e 82 int m_data_length;
ansond 25:1fc958ac14d1 83 int m_data_length_max;
ansond 24:a6915e19814e 84 };
ansond 24:a6915e19814e 85
ansond 24:a6915e19814e 86 #endif // __DATA_WRAPPER_H__