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.
GattService.cpp
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 00018 #include <stdio.h> 00019 #include <string.h> 00020 00021 #include "GattService.h" 00022 00023 /**************************************************************************/ 00024 /*! 00025 @brief Creates a new GattService using the specified 128-bit UUID 00026 00027 @note The UUID value must be unique on the device 00028 00029 @param[in] uuid 00030 The 16 byte (128-bit) UUID to use for this characteristic 00031 00032 @section EXAMPLE 00033 00034 @code 00035 00036 @endcode 00037 */ 00038 /**************************************************************************/ 00039 GattService::GattService(uint8_t base_uuid[16]) 00040 { 00041 primaryServiceID.update(base_uuid); 00042 characteristicCount = 0; 00043 handle = 0; 00044 } 00045 00046 /**************************************************************************/ 00047 /*! 00048 @brief Creates a new GattService using the specified 16-bit BLE UUID 00049 00050 @param[in] ble_uuid 00051 The standardised 16-bit (2 byte) BLE UUID to use for this 00052 characteristic 00053 00054 @section EXAMPLE 00055 00056 @code 00057 00058 @endcode 00059 */ 00060 /**************************************************************************/ 00061 GattService::GattService(uint16_t ble_uuid) 00062 { 00063 primaryServiceID.update( ble_uuid ); 00064 characteristicCount = 0; 00065 handle = 0; 00066 } 00067 00068 /**************************************************************************/ 00069 /*! 00070 @brief Destructor 00071 */ 00072 /**************************************************************************/ 00073 GattService::~GattService(void) 00074 { 00075 } 00076 00077 /**************************************************************************/ 00078 /*! 00079 @brief Adds a GattCharacterisic to the service. 00080 00081 @note This function will not update the .handle field in the 00082 GattCharacteristic. This value is updated when the parent 00083 service is added via the radio driver. 00084 00085 @param[in] characteristic 00086 The GattCharacteristic object describing the characteristic 00087 to add to this service 00088 00089 @returns BLE_ERROR_NONE (0) if everything executed correctly, or an 00090 error code if there was a problem 00091 @retval BLE_ERROR_NONE 00092 Everything executed correctly 00093 00094 @section EXAMPLE 00095 00096 @code 00097 00098 @endcode 00099 */ 00100 /**************************************************************************/ 00101 ble_error_t GattService::addCharacteristic(GattCharacteristic & characteristic) 00102 { 00103 /* ToDo: Make sure we don't overflow the array, etc. */ 00104 /* ToDo: Make sure this characteristic UUID doesn't already exist */ 00105 /* ToDo: Basic validation */ 00106 00107 characteristics[characteristicCount] = &characteristic; 00108 characteristicCount++; 00109 00110 return BLE_ERROR_NONE; 00111 }
Generated on Tue Jul 12 2022 12:14:19 by
