Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Committer:
elmbed
Date:
Wed Apr 27 08:41:13 2016 +0000
Revision:
77:0a860f76e9e6
Parent:
16:3c873f2c8a27
stupid

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AntonLS 16:3c873f2c8a27 1 /* mbed Microcontroller Library
AntonLS 16:3c873f2c8a27 2 * Copyright (c) 2006-2013 ARM Limited
AntonLS 16:3c873f2c8a27 3 *
AntonLS 16:3c873f2c8a27 4 * Licensed under the Apache License, Version 2.0 (the "License");
AntonLS 16:3c873f2c8a27 5 * you may not use this file except in compliance with the License.
AntonLS 16:3c873f2c8a27 6 * You may obtain a copy of the License at
AntonLS 16:3c873f2c8a27 7 *
AntonLS 16:3c873f2c8a27 8 * http://www.apache.org/licenses/LICENSE-2.0
AntonLS 16:3c873f2c8a27 9 *
AntonLS 16:3c873f2c8a27 10 * Unless required by applicable law or agreed to in writing, software
AntonLS 16:3c873f2c8a27 11 * distributed under the License is distributed on an "AS IS" BASIS,
AntonLS 16:3c873f2c8a27 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AntonLS 16:3c873f2c8a27 13 * See the License for the specific language governing permissions and
AntonLS 16:3c873f2c8a27 14 * limitations under the License.
AntonLS 16:3c873f2c8a27 15 */
AntonLS 16:3c873f2c8a27 16
AntonLS 16:3c873f2c8a27 17 #include <stdio.h>
AntonLS 16:3c873f2c8a27 18 #include <string.h>
AntonLS 16:3c873f2c8a27 19
AntonLS 16:3c873f2c8a27 20 #include "blecommon.h"
AntonLS 16:3c873f2c8a27 21 #include "GapAdvertisingParams.h"
AntonLS 16:3c873f2c8a27 22
AntonLS 16:3c873f2c8a27 23 /**************************************************************************/
AntonLS 16:3c873f2c8a27 24 /*!
AntonLS 16:3c873f2c8a27 25 \brief
AntonLS 16:3c873f2c8a27 26 Instantiates a new GapAdvertisingParams instance
AntonLS 16:3c873f2c8a27 27
AntonLS 16:3c873f2c8a27 28 \param[in] advType
AntonLS 16:3c873f2c8a27 29 The GAP advertising mode to use for this device. Valid
AntonLS 16:3c873f2c8a27 30 values are defined in AdvertisingType:
AntonLS 16:3c873f2c8a27 31
AntonLS 16:3c873f2c8a27 32 \par ADV_NON_CONNECTABLE_UNDIRECTED
AntonLS 16:3c873f2c8a27 33 All connections to the peripheral device will be refused.
AntonLS 16:3c873f2c8a27 34
AntonLS 16:3c873f2c8a27 35 \par ADV_CONNECTABLE_DIRECTED
AntonLS 16:3c873f2c8a27 36 Only connections from a pre-defined central device will be
AntonLS 16:3c873f2c8a27 37 accepted.
AntonLS 16:3c873f2c8a27 38
AntonLS 16:3c873f2c8a27 39 \par ADV_CONNECTABLE_UNDIRECTED
AntonLS 16:3c873f2c8a27 40 Any central device can connect to this peripheral.
AntonLS 16:3c873f2c8a27 41
AntonLS 16:3c873f2c8a27 42 \par ADV_SCANNABLE_UNDIRECTED
AntonLS 16:3c873f2c8a27 43 Any central device can connect to this peripheral, and
AntonLS 16:3c873f2c8a27 44 the secondary Scan Response payload will be included or
AntonLS 16:3c873f2c8a27 45 available to central devices.
AntonLS 16:3c873f2c8a27 46
AntonLS 16:3c873f2c8a27 47 \par
AntonLS 16:3c873f2c8a27 48 See Bluetooth Core Specification 4.0 (Vol. 3), Part C,
AntonLS 16:3c873f2c8a27 49 Section 9.3 and Core Specification 4.0 (Vol. 6), Part B,
AntonLS 16:3c873f2c8a27 50 Section 2.3.1 for further information on GAP connection
AntonLS 16:3c873f2c8a27 51 modes
AntonLS 16:3c873f2c8a27 52
AntonLS 16:3c873f2c8a27 53 \param[in] interval
AntonLS 16:3c873f2c8a27 54 Advertising interval between 0x0020 and 0x4000 in 0.625ms units
AntonLS 16:3c873f2c8a27 55 (20ms to 10.24s). If using non-connectable mode
AntonLS 16:3c873f2c8a27 56 (ADV_NON_CONNECTABLE_UNDIRECTED) this min value is 0x00A0
AntonLS 16:3c873f2c8a27 57 (100ms). To reduce the likelihood of collisions, the link layer
AntonLS 16:3c873f2c8a27 58 perturbs this interval by a pseudo-random delay with a range of
AntonLS 16:3c873f2c8a27 59 0 ms to 10 ms for each advertising event.
AntonLS 16:3c873f2c8a27 60
AntonLS 16:3c873f2c8a27 61 \par
AntonLS 16:3c873f2c8a27 62 Decreasing this value will allow central devices to detect
AntonLS 16:3c873f2c8a27 63 your peripheral faster at the expense of more power being
AntonLS 16:3c873f2c8a27 64 used by the radio due to the higher data transmit rate.
AntonLS 16:3c873f2c8a27 65
AntonLS 16:3c873f2c8a27 66 \par
AntonLS 16:3c873f2c8a27 67 This field must be set to 0 if connectionMode is equal
AntonLS 16:3c873f2c8a27 68 to ADV_CONNECTABLE_DIRECTED
AntonLS 16:3c873f2c8a27 69
AntonLS 16:3c873f2c8a27 70 \par
AntonLS 16:3c873f2c8a27 71 See Bluetooth Core Specification, Vol 3., Part C,
AntonLS 16:3c873f2c8a27 72 Appendix A for suggested advertising intervals.
AntonLS 16:3c873f2c8a27 73
AntonLS 16:3c873f2c8a27 74 \param[in] timeout
AntonLS 16:3c873f2c8a27 75 Advertising timeout between 0x1 and 0x3FFF (1 and 16383)
AntonLS 16:3c873f2c8a27 76 in seconds. Enter 0 to disable the advertising timeout.
AntonLS 16:3c873f2c8a27 77
AntonLS 16:3c873f2c8a27 78 \par EXAMPLE
AntonLS 16:3c873f2c8a27 79
AntonLS 16:3c873f2c8a27 80 \code
AntonLS 16:3c873f2c8a27 81
AntonLS 16:3c873f2c8a27 82 \endcode
AntonLS 16:3c873f2c8a27 83 */
AntonLS 16:3c873f2c8a27 84 /**************************************************************************/
AntonLS 16:3c873f2c8a27 85 GapAdvertisingParams::GapAdvertisingParams(AdvertisingType advType, uint16_t interval, uint16_t timeout)
AntonLS 16:3c873f2c8a27 86 {
AntonLS 16:3c873f2c8a27 87 _advType = advType;
AntonLS 16:3c873f2c8a27 88 _interval = interval;
AntonLS 16:3c873f2c8a27 89 _timeout = timeout;
AntonLS 16:3c873f2c8a27 90
AntonLS 16:3c873f2c8a27 91 /* Interval checks */
AntonLS 16:3c873f2c8a27 92 if (_advType == ADV_CONNECTABLE_DIRECTED) {
AntonLS 16:3c873f2c8a27 93 /* Interval must be 0 in directed connectable mode */
AntonLS 16:3c873f2c8a27 94 _interval = 0;
AntonLS 16:3c873f2c8a27 95 } else if (_advType == ADV_NON_CONNECTABLE_UNDIRECTED) {
AntonLS 16:3c873f2c8a27 96 /* Min interval is slightly larger than in other modes */
AntonLS 16:3c873f2c8a27 97 if (_interval < GAP_ADV_PARAMS_INTERVAL_MIN_NONCON) {
AntonLS 16:3c873f2c8a27 98 _interval = GAP_ADV_PARAMS_INTERVAL_MIN_NONCON;
AntonLS 16:3c873f2c8a27 99 }
AntonLS 16:3c873f2c8a27 100 if (_interval > GAP_ADV_PARAMS_INTERVAL_MAX) {
AntonLS 16:3c873f2c8a27 101 _interval = GAP_ADV_PARAMS_INTERVAL_MAX;
AntonLS 16:3c873f2c8a27 102 }
AntonLS 16:3c873f2c8a27 103 } else {
AntonLS 16:3c873f2c8a27 104 /* Stay within interval limits */
AntonLS 16:3c873f2c8a27 105 if (_interval < GAP_ADV_PARAMS_INTERVAL_MIN) {
AntonLS 16:3c873f2c8a27 106 _interval = GAP_ADV_PARAMS_INTERVAL_MIN;
AntonLS 16:3c873f2c8a27 107 }
AntonLS 16:3c873f2c8a27 108 if (_interval > GAP_ADV_PARAMS_INTERVAL_MAX) {
AntonLS 16:3c873f2c8a27 109 _interval = GAP_ADV_PARAMS_INTERVAL_MAX;
AntonLS 16:3c873f2c8a27 110 }
AntonLS 16:3c873f2c8a27 111 }
AntonLS 16:3c873f2c8a27 112
AntonLS 16:3c873f2c8a27 113 /* Timeout checks */
AntonLS 16:3c873f2c8a27 114 if (timeout) {
AntonLS 16:3c873f2c8a27 115 /* Stay within timeout limits */
AntonLS 16:3c873f2c8a27 116 if (_timeout > GAP_ADV_PARAMS_TIMEOUT_MAX) {
AntonLS 16:3c873f2c8a27 117 _timeout = GAP_ADV_PARAMS_TIMEOUT_MAX;
AntonLS 16:3c873f2c8a27 118 }
AntonLS 16:3c873f2c8a27 119 }
AntonLS 16:3c873f2c8a27 120 }
AntonLS 16:3c873f2c8a27 121
AntonLS 16:3c873f2c8a27 122 /**************************************************************************/
AntonLS 16:3c873f2c8a27 123 /*!
AntonLS 16:3c873f2c8a27 124 Destructor
AntonLS 16:3c873f2c8a27 125 */
AntonLS 16:3c873f2c8a27 126 /**************************************************************************/
AntonLS 16:3c873f2c8a27 127 GapAdvertisingParams::~GapAdvertisingParams(void)
AntonLS 16:3c873f2c8a27 128 {
AntonLS 16:3c873f2c8a27 129 }