Microbug / BLE_API_FOTA

Fork of BLE_API by Bluetooth Low Energy

Committer:
Rohit Grover
Date:
Wed Jun 11 14:14:04 2014 +0100
Revision:
91:311bde45b251
Parent:
90:f245e2d96aa0
Child:
92:3781dc6f8c18
use const reference in constructor for GattService

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ktownsend 27:4a83843f04b0 1 /* mbed Microcontroller Library
ktownsend 27:4a83843f04b0 2 * Copyright (c) 2006-2013 ARM Limited
ktownsend 27:4a83843f04b0 3 *
ktownsend 27:4a83843f04b0 4 * Licensed under the Apache License, Version 2.0 (the "License");
ktownsend 27:4a83843f04b0 5 * you may not use this file except in compliance with the License.
ktownsend 27:4a83843f04b0 6 * You may obtain a copy of the License at
ktownsend 27:4a83843f04b0 7 *
ktownsend 27:4a83843f04b0 8 * http://www.apache.org/licenses/LICENSE-2.0
ktownsend 27:4a83843f04b0 9 *
ktownsend 27:4a83843f04b0 10 * Unless required by applicable law or agreed to in writing, software
ktownsend 27:4a83843f04b0 11 * distributed under the License is distributed on an "AS IS" BASIS,
ktownsend 27:4a83843f04b0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ktownsend 27:4a83843f04b0 13 * See the License for the specific language governing permissions and
ktownsend 27:4a83843f04b0 14 * limitations under the License.
ktownsend 27:4a83843f04b0 15 */
Rohit Grover 34:da2ea8cd6216 16
ktownsend 27:4a83843f04b0 17
ktownsend 2:ffc5216bd2cc 18 #include <stdio.h>
ktownsend 2:ffc5216bd2cc 19 #include <string.h>
ktownsend 2:ffc5216bd2cc 20
ktownsend 2:ffc5216bd2cc 21 #include "GattService.h"
ktownsend 2:ffc5216bd2cc 22
ktownsend 2:ffc5216bd2cc 23 /**************************************************************************/
ktownsend 2:ffc5216bd2cc 24 /*!
ktownsend 2:ffc5216bd2cc 25 @brief Creates a new GattService using the specified 128-bit UUID
Rohit Grover 34:da2ea8cd6216 26
ktownsend 2:ffc5216bd2cc 27 @note The UUID value must be unique on the device
ktownsend 2:ffc5216bd2cc 28
ktownsend 2:ffc5216bd2cc 29 @param[in] uuid
ktownsend 2:ffc5216bd2cc 30 The 16 byte (128-bit) UUID to use for this characteristic
ktownsend 2:ffc5216bd2cc 31
ktownsend 2:ffc5216bd2cc 32 @section EXAMPLE
ktownsend 2:ffc5216bd2cc 33
ktownsend 2:ffc5216bd2cc 34 @code
Rohit Grover 34:da2ea8cd6216 35
ktownsend 2:ffc5216bd2cc 36 @endcode
ktownsend 2:ffc5216bd2cc 37 */
ktownsend 2:ffc5216bd2cc 38 /**************************************************************************/
Rohit Grover 91:311bde45b251 39 GattService::GattService(const UUID &uuid) : primaryServiceID(uuid), characteristicCount(0), characteristics(), handle(0)
ktownsend 2:ffc5216bd2cc 40 {
Rohit Grover 53:a1bec483c8e3 41 /* empty */
ktownsend 2:ffc5216bd2cc 42 }
ktownsend 2:ffc5216bd2cc 43
ktownsend 2:ffc5216bd2cc 44 /**************************************************************************/
ktownsend 2:ffc5216bd2cc 45 /*!
ktownsend 2:ffc5216bd2cc 46 @brief Destructor
ktownsend 2:ffc5216bd2cc 47 */
ktownsend 2:ffc5216bd2cc 48 /**************************************************************************/
ktownsend 2:ffc5216bd2cc 49 GattService::~GattService(void)
ktownsend 2:ffc5216bd2cc 50 {
ktownsend 2:ffc5216bd2cc 51 }
ktownsend 2:ffc5216bd2cc 52
ktownsend 2:ffc5216bd2cc 53 /**************************************************************************/
ktownsend 2:ffc5216bd2cc 54 /*!
ktownsend 23:f19c60478e1b 55 @brief Adds a GattCharacterisic to the service.
Rohit Grover 34:da2ea8cd6216 56
ktownsend 23:f19c60478e1b 57 @note This function will not update the .handle field in the
ktownsend 23:f19c60478e1b 58 GattCharacteristic. This value is updated when the parent
Rohit Grover 34:da2ea8cd6216 59 service is added via the radio driver.
ktownsend 2:ffc5216bd2cc 60
ktownsend 2:ffc5216bd2cc 61 @param[in] characteristic
ktownsend 2:ffc5216bd2cc 62 The GattCharacteristic object describing the characteristic
ktownsend 2:ffc5216bd2cc 63 to add to this service
ktownsend 2:ffc5216bd2cc 64
ktownsend 2:ffc5216bd2cc 65 @returns BLE_ERROR_NONE (0) if everything executed correctly, or an
ktownsend 2:ffc5216bd2cc 66 error code if there was a problem
ktownsend 2:ffc5216bd2cc 67 @retval BLE_ERROR_NONE
ktownsend 2:ffc5216bd2cc 68 Everything executed correctly
ktownsend 2:ffc5216bd2cc 69
ktownsend 2:ffc5216bd2cc 70 @section EXAMPLE
ktownsend 2:ffc5216bd2cc 71
ktownsend 2:ffc5216bd2cc 72 @code
Rohit Grover 34:da2ea8cd6216 73
ktownsend 2:ffc5216bd2cc 74 @endcode
ktownsend 2:ffc5216bd2cc 75 */
ktownsend 2:ffc5216bd2cc 76 /**************************************************************************/
ktownsend 2:ffc5216bd2cc 77 ble_error_t GattService::addCharacteristic(GattCharacteristic & characteristic)
ktownsend 2:ffc5216bd2cc 78 {
ktownsend 2:ffc5216bd2cc 79 /* ToDo: Make sure we don't overflow the array, etc. */
ktownsend 2:ffc5216bd2cc 80 /* ToDo: Make sure this characteristic UUID doesn't already exist */
ktownsend 2:ffc5216bd2cc 81 /* ToDo: Basic validation */
ktownsend 23:f19c60478e1b 82
bogdanm 31:2c94f0501807 83 characteristics[characteristicCount] = &characteristic;
ktownsend 2:ffc5216bd2cc 84 characteristicCount++;
Rohit Grover 34:da2ea8cd6216 85
ktownsend 2:ffc5216bd2cc 86 return BLE_ERROR_NONE;
ktownsend 2:ffc5216bd2cc 87 }