prova invio BLE

Dependents:   BLE_HeartRate_IDB04A1

Fork of BLE_API by Bluetooth Low Energy

Committer:
vcoubard
Date:
Wed Apr 06 19:13:46 2016 +0100
Revision:
1131:692ddf04fc42
Parent:
1054:f59e5d9a992a
Child:
1132:6362b7c2fdff
Synchronized with git rev 13bf70b6
Author: Rohit Grover
Release 2.1.5
=============

A minor release to separate the concept of minlen and len in
GattCharacteristic. Also contains some improvements to documentation.

Who changed what in which revision?

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