Changed the device name.

Dependents:   BLE_Health_Thermometer_HeartRateMonitor

Fork of BLE_API_Native_IRC by Yoshihiro TSUBOI

Committer:
ghz2000
Date:
Mon Jun 16 15:06:48 2014 +0000
Revision:
20:a58a51c92075
Parent:
0:4c3097c65247
Add HeartRateMonitor

Who changed what in which revision?

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