Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
GattAttribute.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef __GATT_ATTRIBUTE_H__ 00018 #define __GATT_ATTRIBUTE_H__ 00019 00020 class GattAttribute { 00021 public: 00022 typedef uint16_t Handle_t; 00023 00024 public: 00025 /** 00026 * @brief Creates a new GattAttribute using the specified 00027 * UUID, value length, and inital value 00028 * 00029 * @param[in] uuid 00030 * The UUID to use for this attribute 00031 * @param[in] valuePtr 00032 * The memory holding the initial value. 00033 * @param[in] initialLen 00034 * The min length in bytes of this characteristic's value 00035 * @param[in] maxLen 00036 * The max length in bytes of this characteristic's value 00037 * 00038 * @section EXAMPLE 00039 * 00040 * @code 00041 * 00042 * // UUID = 0x2A19, Min length 2, Max len = 2, Properties = write 00043 * GattCharacteristic c = GattCharacteristic( 0x2A19, 2, 2, BLE_GATT_CHAR_PROPERTIES_WRITE ); 00044 * 00045 * @endcode 00046 */ 00047 /**************************************************************************/ 00048 GattAttribute(const UUID &uuid, uint8_t *valuePtr = NULL, uint16_t initialLen = 0, uint16_t maxLen = 0) : 00049 _uuid(uuid), _valuePtr(valuePtr), _initialLen(initialLen), _lenMax(maxLen), _len(initialLen), _handle() { 00050 /* empty */ 00051 } 00052 00053 public: 00054 Handle_t getHandle(void) const {return _handle; } 00055 const UUID &getUUID(void) const {return _uuid; } 00056 uint16_t getLength(void) const {return _len; } 00057 uint16_t getInitialLength(void) const {return _initialLen;} 00058 uint16_t getMaxLength(void) const {return _lenMax; } 00059 uint16_t *getLengthPtr(void) {return &_len; } 00060 void setHandle(Handle_t id) {_handle = id; } 00061 uint8_t *getValuePtr(void) {return _valuePtr; } 00062 00063 private: 00064 UUID _uuid; /* Characteristic UUID */ 00065 uint8_t *_valuePtr; 00066 uint16_t _initialLen; /* Initial length of the value */ 00067 uint16_t _lenMax; /* Maximum length of the value */ 00068 uint16_t _len; /* Current length of the value */ 00069 Handle_t _handle; 00070 00071 private: 00072 /* disallow copy and assignment */ 00073 GattAttribute(const GattAttribute &); 00074 GattAttribute& operator=(const GattAttribute &); 00075 }; 00076 00077 #endif // ifndef __GATT_ATTRIBUTE_H__
Generated on Tue Jul 12 2022 18:47:13 by
