ble

Dependencies:   HC_SR04_Ultrasonic_Library Servo mbed

Fork of FIP_REV1 by Robotique FIP

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GapAdvertisingParams.h Source File

GapAdvertisingParams.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 __GAP_ADVERTISING_PARAMS_H__
00018 #define __GAP_ADVERTISING_PARAMS_H__
00019 
00020 #include "blecommon.h"
00021 
00022 #define GAP_ADV_PARAMS_INTERVAL_MIN        (0x0020)
00023 #define GAP_ADV_PARAMS_INTERVAL_MIN_NONCON (0x00A0)
00024 #define GAP_ADV_PARAMS_INTERVAL_MAX        (0x1000)
00025 #define GAP_ADV_PARAMS_TIMEOUT_MAX         (0x3FFF)
00026 
00027 /**************************************************************************/
00028 /*!
00029     \brief
00030     This class provides a wrapper for the core advertising parameters,
00031     including the advertising type (Connectable Undirected,
00032     Non Connectable Undirected, etc.), as well as the advertising and
00033     timeout intervals.
00034 
00035     \par
00036     See the following for more information on advertising types:
00037 
00038     \li \c Bluetooth Core Specification 4.0 (Vol. 6), Part B, Section 2.3.1
00039     \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 9.3
00040 
00041     \par EXAMPLE
00042 
00043     \code
00044 
00045     // ToDo
00046 
00047     \endcode
00048 */
00049 /**************************************************************************/
00050 class GapAdvertisingParams
00051 {
00052 public:
00053     /**************************************************************************/
00054     /*!
00055         \brief
00056         Encapsulates the peripheral advertising modes, which determine how
00057         the device appears to other central devices in hearing range
00058 
00059         \par
00060         See the following for more information on advertising types:
00061 
00062         \li \c Bluetooth Core Specification 4.0 (Vol. 6), Part B, Section 2.3.1
00063         \li \c Bluetooth Core Specification 4.0 (Vol. 3), Part C, Section 9.3
00064     */
00065     /**************************************************************************/
00066     enum AdvertisingType
00067     {
00068         ADV_CONNECTABLE_UNDIRECTED,     /**< Vol 3, Part C, Section 9.3.4 and
00069                                          *Vol 6, Part B, Section 2.3.1.1 */
00070         ADV_CONNECTABLE_DIRECTED,       /**< Vol 3, Part C, Section 9.3.3 and
00071                                          *Vol 6, Part B, Section 2.3.1.2 */
00072         ADV_SCANNABLE_UNDIRECTED,       /**< Include support for Scan Response
00073                                          *payloads, see Vol 6, Part B, Section
00074                                          *2.3.1.4 */
00075         ADV_NON_CONNECTABLE_UNDIRECTED  /**< Vol 3, Part C, Section 9.3.2 and
00076                                          *Vol 6, Part B, Section 2.3.1.3 */
00077     };
00078 
00079     GapAdvertisingParams(AdvertisingType advType  =
00080                              GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED,
00081                          uint16_t        interval =
00082                              GAP_ADV_PARAMS_INTERVAL_MIN_NONCON,
00083                          uint16_t        timeout  = 0);
00084     virtual ~GapAdvertisingParams (void);
00085 
00086     void setAdvertisingType(AdvertisingType newAdvType);
00087     void setInterval(uint16_t newInterval);
00088     void setTimeout(uint16_t  newTimeout);
00089 
00090     virtual AdvertisingType getAdvertisingType(void) const;
00091     virtual uint16_t        getInterval(void) const;
00092     virtual uint16_t        getTimeout(void) const;
00093 
00094 private:
00095     AdvertisingType _advType;
00096     uint16_t        _interval;
00097     uint16_t        _timeout;
00098 };
00099 
00100 inline void
00101 GapAdvertisingParams::setAdvertisingType(AdvertisingType newAdvType) {
00102     _advType = newAdvType;
00103 }
00104 
00105 inline void
00106 GapAdvertisingParams::setInterval(uint16_t newInterval) {
00107     _interval = newInterval;
00108 }
00109 
00110 inline void
00111 GapAdvertisingParams::setTimeout(uint16_t  newTimeout) {
00112     _timeout = newTimeout;
00113 }
00114 
00115 
00116 /**************************************************************************/
00117 /*!
00118     \brief returns the current Advertising Type value
00119 */
00120 /**************************************************************************/
00121 inline GapAdvertisingParams::AdvertisingType
00122 GapAdvertisingParams::getAdvertisingType(void) const
00123 {
00124     return _advType;
00125 }
00126 
00127 /**************************************************************************/
00128 /*!
00129     \brief returns the current Advertising Delay (in units of 0.625ms)
00130 */
00131 /**************************************************************************/
00132 inline uint16_t
00133 GapAdvertisingParams::getInterval(void) const
00134 {
00135     return _interval;
00136 }
00137 
00138 /**************************************************************************/
00139 /*!
00140     \brief returns the current Advertising Timeout (in seconds)
00141 */
00142 /**************************************************************************/
00143 inline uint16_t
00144 GapAdvertisingParams::getTimeout(void) const
00145 {
00146     return _timeout;
00147 }
00148 
00149 
00150 #endif // ifndef __GAP_ADVERTISING_PARAMS_H__