Updated

Fork of BLE_API by Bluetooth Low Energy

Committer:
vcoubard
Date:
Wed Apr 06 19:15:19 2016 +0100
Revision:
1173:56507890f134
Parent:
1048:efb29faf12fc
Child:
1179:4ab722f8dca0
Synchronized with git rev 17a0b0b6
Author: Andres Amaya Garcia
Add missing docs and fix doxy warnings in GapScanningParams.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 1173:56507890f134 1 /* mbed Microcontroller Library
vcoubard 1173:56507890f134 2 * Copyright (c) 2006-2013 ARM Limited
vcoubard 1173:56507890f134 3 *
vcoubard 1173:56507890f134 4 * Licensed under the Apache License, Version 2.0 (the "License");
vcoubard 1173:56507890f134 5 * you may not use this file except in compliance with the License.
vcoubard 1173:56507890f134 6 * You may obtain a copy of the License at
vcoubard 1173:56507890f134 7 *
vcoubard 1173:56507890f134 8 * http://www.apache.org/licenses/LICENSE-2.0
vcoubard 1173:56507890f134 9 *
vcoubard 1173:56507890f134 10 * Unless required by applicable law or agreed to in writing, software
vcoubard 1173:56507890f134 11 * distributed under the License is distributed on an "AS IS" BASIS,
vcoubard 1173:56507890f134 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
vcoubard 1173:56507890f134 13 * See the License for the specific language governing permissions and
vcoubard 1173:56507890f134 14 * limitations under the License.
vcoubard 1173:56507890f134 15 */
vcoubard 1173:56507890f134 16
vcoubard 1173:56507890f134 17 #ifndef __GAP_SCANNING_PARAMS_H__
vcoubard 1173:56507890f134 18 #define __GAP_SCANNING_PARAMS_H__
vcoubard 1173:56507890f134 19
vcoubard 1173:56507890f134 20 class GapScanningParams {
vcoubard 1173:56507890f134 21 public:
vcoubard 1173:56507890f134 22 static const unsigned SCAN_INTERVAL_MIN = 0x0004; /**< Minimum Scan interval in 625us units - 2.5ms. */
vcoubard 1173:56507890f134 23 static const unsigned SCAN_INTERVAL_MAX = 0x4000; /**< Maximum Scan interval in 625us units - 10.24s. */
vcoubard 1173:56507890f134 24 static const unsigned SCAN_WINDOW_MIN = 0x0004; /**< Minimum Scan window in 625us units - 2.5ms. */
vcoubard 1173:56507890f134 25 static const unsigned SCAN_WINDOW_MAX = 0x4000; /**< Maximum Scan window in 625us units - 10.24s. */
vcoubard 1173:56507890f134 26 static const unsigned SCAN_TIMEOUT_MIN = 0x0001; /**< Minimum Scan timeout in seconds. */
vcoubard 1173:56507890f134 27 static const unsigned SCAN_TIMEOUT_MAX = 0xFFFF; /**< Maximum Scan timeout in seconds. */
vcoubard 1173:56507890f134 28
vcoubard 1173:56507890f134 29 public:
vcoubard 1173:56507890f134 30 /**
vcoubard 1173:56507890f134 31 * Construct an instance of GapScanningParams.
vcoubard 1173:56507890f134 32 *
vcoubard 1173:56507890f134 33 * @param[in] interval
vcoubard 1173:56507890f134 34 * The scan interval in milliseconds. Default is
vcoubard 1173:56507890f134 35 * GapScanningParams::SCAN_INTERVAL_MIN.
vcoubard 1173:56507890f134 36 * @param[in] window
vcoubard 1173:56507890f134 37 * The scan window in milliseconds. Default is
vcoubard 1173:56507890f134 38 * GapScanningParams::SCAN_WINDOW_MAX.
vcoubard 1173:56507890f134 39 * @param[in] timeout
vcoubard 1173:56507890f134 40 * The scan timeout in seconds. Default is 0.
vcoubard 1173:56507890f134 41 * @param[in] activeScanning
vcoubard 1173:56507890f134 42 * Set to True if active-scanning is required. This is used to
vcoubard 1173:56507890f134 43 * fetch the scan response from a peer if possible. Default is
vcoubard 1173:56507890f134 44 * false.
vcoubard 1173:56507890f134 45 */
vcoubard 1173:56507890f134 46 GapScanningParams(uint16_t interval = SCAN_INTERVAL_MAX,
vcoubard 1173:56507890f134 47 uint16_t window = SCAN_WINDOW_MAX,
vcoubard 1173:56507890f134 48 uint16_t timeout = 0,
vcoubard 1173:56507890f134 49 bool activeScanning = false);
vcoubard 1173:56507890f134 50
vcoubard 1173:56507890f134 51 static const uint16_t UNIT_0_625_MS = 625; /**< Number of microseconds in 0.625 milliseconds. */
vcoubard 1173:56507890f134 52 /**
vcoubard 1173:56507890f134 53 * Convert milliseconds to units of 0.625ms.
vcoubard 1173:56507890f134 54 *
vcoubard 1173:56507890f134 55 * @param[in] durationInMillis
vcoubard 1173:56507890f134 56 * The number of milliseconds to convert.
vcoubard 1173:56507890f134 57 *
vcoubard 1173:56507890f134 58 * @return The value of @p durationInMillis in units of 0.625ms.
vcoubard 1173:56507890f134 59 */
vcoubard 1173:56507890f134 60 static uint16_t MSEC_TO_SCAN_DURATION_UNITS(uint32_t durationInMillis) {
vcoubard 1173:56507890f134 61 return (durationInMillis * 1000) / UNIT_0_625_MS;
vcoubard 1173:56507890f134 62 }
vcoubard 1173:56507890f134 63
vcoubard 1173:56507890f134 64 /**
vcoubard 1173:56507890f134 65 * Set the scan interval.
vcoubard 1173:56507890f134 66 *
vcoubard 1173:56507890f134 67 * @param[in] newIntervalInMS
vcoubard 1173:56507890f134 68 * New scan interval in milliseconds.
vcoubard 1173:56507890f134 69 *
vcoubard 1173:56507890f134 70 * @return BLE_ERROR_NONE if the new scan interval was set successfully.
vcoubard 1173:56507890f134 71 */
vcoubard 1173:56507890f134 72 ble_error_t setInterval(uint16_t newIntervalInMS);
vcoubard 1173:56507890f134 73
vcoubard 1173:56507890f134 74 /**
vcoubard 1173:56507890f134 75 * Set the scan window.
vcoubard 1173:56507890f134 76 *
vcoubard 1173:56507890f134 77 * @param[in] newWindowInMS
vcoubard 1173:56507890f134 78 * New scan window in milliseconds.
vcoubard 1173:56507890f134 79 *
vcoubard 1173:56507890f134 80 * @return BLE_ERROR_NONE if the new scan window was set successfully.
vcoubard 1173:56507890f134 81 */
vcoubard 1173:56507890f134 82 ble_error_t setWindow(uint16_t newWindowInMS);
vcoubard 1173:56507890f134 83
vcoubard 1173:56507890f134 84 /**
vcoubard 1173:56507890f134 85 * Set the scan timeout.
vcoubard 1173:56507890f134 86 *
vcoubard 1173:56507890f134 87 * @param[in] newTimeout
vcoubard 1173:56507890f134 88 * New scan timeout in seconds.
vcoubard 1173:56507890f134 89 *
vcoubard 1173:56507890f134 90 * @return BLE_ERROR_NONE if the new scan window was set successfully.
vcoubard 1173:56507890f134 91 */
vcoubard 1173:56507890f134 92 ble_error_t setTimeout(uint16_t newTimeout);
vcoubard 1173:56507890f134 93
vcoubard 1173:56507890f134 94 /**
vcoubard 1173:56507890f134 95 * Set active scanning. This is used to fetch the scan response from a peer
vcoubard 1173:56507890f134 96 * if possible.
vcoubard 1173:56507890f134 97 *
vcoubard 1173:56507890f134 98 * @param[in] activeScanning
vcoubard 1173:56507890f134 99 * The new boolean value of active scanning.
vcoubard 1173:56507890f134 100 */
vcoubard 1173:56507890f134 101 void setActiveScanning(bool activeScanning);
vcoubard 1173:56507890f134 102
vcoubard 1173:56507890f134 103 public:
vcoubard 1173:56507890f134 104 /**
vcoubard 1173:56507890f134 105 * Get the scan interval.
vcoubard 1173:56507890f134 106 *
vcoubard 1173:56507890f134 107 * @return the scan interval in units of 0.625ms.
vcoubard 1173:56507890f134 108 */
vcoubard 1173:56507890f134 109 uint16_t getInterval(void) const {
vcoubard 1173:56507890f134 110 return _interval;
vcoubard 1173:56507890f134 111 }
vcoubard 1173:56507890f134 112
vcoubard 1173:56507890f134 113 /**
vcoubard 1173:56507890f134 114 * Get the scan window.
vcoubard 1173:56507890f134 115 *
vcoubard 1173:56507890f134 116 * @return the scan window in units of 0.625ms.
vcoubard 1173:56507890f134 117 */
vcoubard 1173:56507890f134 118 uint16_t getWindow(void) const {
vcoubard 1173:56507890f134 119 return _window;
vcoubard 1173:56507890f134 120 }
vcoubard 1173:56507890f134 121
vcoubard 1173:56507890f134 122 /**
vcoubard 1173:56507890f134 123 * Get the scan timeout.
vcoubard 1173:56507890f134 124 *
vcoubard 1173:56507890f134 125 * @return The scan timeout in seconds.
vcoubard 1173:56507890f134 126 */
vcoubard 1173:56507890f134 127 uint16_t getTimeout(void) const {
vcoubard 1173:56507890f134 128 return _timeout;
vcoubard 1173:56507890f134 129 }
vcoubard 1173:56507890f134 130
vcoubard 1173:56507890f134 131 /**
vcoubard 1173:56507890f134 132 * Check whether active scanning is set.
vcoubard 1173:56507890f134 133 *
vcoubard 1173:56507890f134 134 * @return True if active scanning is set, false otherwise.
vcoubard 1173:56507890f134 135 */
vcoubard 1173:56507890f134 136 bool getActiveScanning(void) const {
vcoubard 1173:56507890f134 137 return _activeScanning;
vcoubard 1173:56507890f134 138 }
vcoubard 1173:56507890f134 139
vcoubard 1173:56507890f134 140 private:
vcoubard 1173:56507890f134 141 uint16_t _interval; /**< Scan interval in units of 625us (between 2.5ms and 10.24s). */
vcoubard 1173:56507890f134 142 uint16_t _window; /**< Scan window in units of 625us (between 2.5ms and 10.24s). */
vcoubard 1173:56507890f134 143 uint16_t _timeout; /**< Scan timeout between 0x0001 and 0xFFFF in seconds; 0x0000 disables timeout. */
vcoubard 1173:56507890f134 144 bool _activeScanning; /**< Obtain the peer device's advertising data and (if possible) scanResponse. */
vcoubard 1173:56507890f134 145
vcoubard 1173:56507890f134 146 private:
vcoubard 1173:56507890f134 147 /* Disallow copy constructor. */
vcoubard 1173:56507890f134 148 GapScanningParams(const GapScanningParams &);
vcoubard 1173:56507890f134 149 GapScanningParams& operator =(const GapScanningParams &in);
vcoubard 1173:56507890f134 150 };
vcoubard 1173:56507890f134 151
vcoubard 1173:56507890f134 152 #endif /* ifndef __GAP_SCANNING_PARAMS_H__ */