テスト用です。

Dependencies:   mbed

Committer:
jksoft
Date:
Tue Oct 11 11:09:42 2016 +0000
Revision:
0:8468a4403fea
SB??ver;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:8468a4403fea 1 /* mbed Microcontroller Library
jksoft 0:8468a4403fea 2 * Copyright (c) 2006-2013 ARM Limited
jksoft 0:8468a4403fea 3 *
jksoft 0:8468a4403fea 4 * Licensed under the Apache License, Version 2.0 (the "License");
jksoft 0:8468a4403fea 5 * you may not use this file except in compliance with the License.
jksoft 0:8468a4403fea 6 * You may obtain a copy of the License at
jksoft 0:8468a4403fea 7 *
jksoft 0:8468a4403fea 8 * http://www.apache.org/licenses/LICENSE-2.0
jksoft 0:8468a4403fea 9 *
jksoft 0:8468a4403fea 10 * Unless required by applicable law or agreed to in writing, software
jksoft 0:8468a4403fea 11 * distributed under the License is distributed on an "AS IS" BASIS,
jksoft 0:8468a4403fea 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jksoft 0:8468a4403fea 13 * See the License for the specific language governing permissions and
jksoft 0:8468a4403fea 14 * limitations under the License.
jksoft 0:8468a4403fea 15 */
jksoft 0:8468a4403fea 16
jksoft 0:8468a4403fea 17 #ifndef __GATT_ATTRIBUTE_H__
jksoft 0:8468a4403fea 18 #define __GATT_ATTRIBUTE_H__
jksoft 0:8468a4403fea 19
jksoft 0:8468a4403fea 20 class GattAttribute {
jksoft 0:8468a4403fea 21 public:
jksoft 0:8468a4403fea 22 typedef uint16_t Handle_t;
jksoft 0:8468a4403fea 23
jksoft 0:8468a4403fea 24 public:
jksoft 0:8468a4403fea 25 /**
jksoft 0:8468a4403fea 26 * @brief Creates a new GattAttribute using the specified
jksoft 0:8468a4403fea 27 * UUID, value length, and inital value
jksoft 0:8468a4403fea 28 *
jksoft 0:8468a4403fea 29 * @param[in] uuid
jksoft 0:8468a4403fea 30 * The UUID to use for this attribute
jksoft 0:8468a4403fea 31 * @param[in] valuePtr
jksoft 0:8468a4403fea 32 * The memory holding the initial value.
jksoft 0:8468a4403fea 33 * @param[in] initialLen
jksoft 0:8468a4403fea 34 * The min length in bytes of this characteristic's value
jksoft 0:8468a4403fea 35 * @param[in] maxLen
jksoft 0:8468a4403fea 36 * The max length in bytes of this characteristic's value
jksoft 0:8468a4403fea 37 *
jksoft 0:8468a4403fea 38 * @section EXAMPLE
jksoft 0:8468a4403fea 39 *
jksoft 0:8468a4403fea 40 * @code
jksoft 0:8468a4403fea 41 *
jksoft 0:8468a4403fea 42 * // UUID = 0x2A19, Min length 2, Max len = 2, Properties = write
jksoft 0:8468a4403fea 43 * GattCharacteristic c = GattCharacteristic( 0x2A19, 2, 2, BLE_GATT_CHAR_PROPERTIES_WRITE );
jksoft 0:8468a4403fea 44 *
jksoft 0:8468a4403fea 45 * @endcode
jksoft 0:8468a4403fea 46 */
jksoft 0:8468a4403fea 47 /**************************************************************************/
jksoft 0:8468a4403fea 48 GattAttribute(const UUID &uuid, uint8_t *valuePtr = NULL, uint16_t initialLen = 0, uint16_t maxLen = 0) :
jksoft 0:8468a4403fea 49 _uuid(uuid), _valuePtr(valuePtr), _initialLen(initialLen), _lenMax(maxLen), _handle() {
jksoft 0:8468a4403fea 50 /* empty */
jksoft 0:8468a4403fea 51 }
jksoft 0:8468a4403fea 52
jksoft 0:8468a4403fea 53 public:
jksoft 0:8468a4403fea 54 Handle_t getHandle(void) const {return _handle; }
jksoft 0:8468a4403fea 55 const UUID &getUUID(void) const {return _uuid; }
jksoft 0:8468a4403fea 56 uint16_t getInitialLength(void) const {return _initialLen;}
jksoft 0:8468a4403fea 57 uint16_t getMaxLength(void) const {return _lenMax; }
jksoft 0:8468a4403fea 58 void setHandle(Handle_t id) {_handle = id; }
jksoft 0:8468a4403fea 59 uint8_t *getValuePtr(void) {return _valuePtr; }
jksoft 0:8468a4403fea 60
jksoft 0:8468a4403fea 61 private:
jksoft 0:8468a4403fea 62 UUID _uuid; /* Characteristic UUID */
jksoft 0:8468a4403fea 63 uint8_t *_valuePtr;
jksoft 0:8468a4403fea 64 uint16_t _initialLen; /* Initial length of the value */
jksoft 0:8468a4403fea 65 uint16_t _lenMax; /* Maximum length of the value */
jksoft 0:8468a4403fea 66 Handle_t _handle;
jksoft 0:8468a4403fea 67
jksoft 0:8468a4403fea 68 private:
jksoft 0:8468a4403fea 69 /* disallow copy and assignment */
jksoft 0:8468a4403fea 70 GattAttribute(const GattAttribute &);
jksoft 0:8468a4403fea 71 GattAttribute& operator=(const GattAttribute &);
jksoft 0:8468a4403fea 72 };
jksoft 0:8468a4403fea 73
jksoft 0:8468a4403fea 74 #endif // ifndef __GATT_ATTRIBUTE_H__