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 #include "UUID.h" 00021 00022 class GattAttribute { 00023 public: 00024 typedef uint16_t Handle_t; 00025 static const Handle_t INVALID_HANDLE = 0x0000; 00026 00027 public: 00028 /** 00029 * @brief Creates a new GattAttribute using the specified 00030 * UUID, value length, and inital value 00031 * 00032 * @param[in] uuid 00033 * The UUID to use for this attribute 00034 * @param[in] valuePtr 00035 * The memory holding the initial value. 00036 * @param[in] initialLen 00037 * The min length in bytes of this attribute's value 00038 * @param[in] maxLen 00039 * The max length in bytes of this attribute's value 00040 * 00041 * @section EXAMPLE 00042 * 00043 * @code 00044 * 00045 * // UUID = 0x2A19, Min length 2, Max len = 2 00046 * GattAttribute attr = GattAttribute(0x2A19, &someValue, 2, 2); 00047 * 00048 * @endcode 00049 */ 00050 GattAttribute(const UUID &uuid, uint8_t *valuePtr = NULL, uint16_t initialLen = 0, uint16_t maxLen = 0) : 00051 _uuid(uuid), _valuePtr(valuePtr), _initialLen(initialLen), _lenMax(maxLen), _len(initialLen), _handle() { 00052 /* empty */ 00053 } 00054 00055 public: 00056 Handle_t getHandle(void) const {return _handle; } 00057 const UUID &getUUID(void) const {return _uuid; } 00058 uint16_t getLength(void) const {return _len; } 00059 uint16_t getInitialLength(void) const {return _initialLen;} 00060 uint16_t getMaxLength(void) const {return _lenMax; } 00061 uint16_t *getLengthPtr(void) {return &_len; } 00062 void setHandle(Handle_t id) {_handle = id; } 00063 uint8_t *getValuePtr(void) {return _valuePtr; } 00064 00065 private: 00066 UUID _uuid; /* Characteristic UUID */ 00067 uint8_t *_valuePtr; 00068 uint16_t _initialLen; /* Initial length of the value */ 00069 uint16_t _lenMax; /* Maximum length of the value */ 00070 uint16_t _len; /* Current length of the value */ 00071 Handle_t _handle; 00072 00073 private: 00074 /* disallow copy and assignment */ 00075 GattAttribute(const GattAttribute &); 00076 GattAttribute& operator=(const GattAttribute &); 00077 }; 00078 00079 #endif // ifndef __GATT_ATTRIBUTE_H__
Generated on Wed Jul 13 2022 03:06:59 by
1.7.2
