use TCP to connect to mbed connector

Fork of mbedConnectorInterfaceWithDM by Doug Anson

Committer:
ansond
Date:
Fri Feb 19 17:32:14 2016 +0000
Revision:
0:1f1f55e73248
Child:
33:1d0b855df5a5
initial checkin

Who changed what in which revision?

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