High level Bluetooth Low Energy API and radio abstraction layer

Dependencies:   nRF51822

Dependents:   LinkNode_LIS3DH

Fork of BLE_API by Bluetooth Low Energy

Committer:
rgrover1
Date:
Fri Jun 19 15:52:07 2015 +0100
Revision:
531:bdcd44b03974
Parent:
527:493185cebc03
Child:
567:e4b38e43de7c
Synchronized with git rev e74eb3b4
Author: Rohit Grover
moved GAP related members out of BLE and into GAP

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rgrover1 379:b379d350aaab 1 /* mbed Microcontroller Library
rgrover1 379:b379d350aaab 2 * Copyright (c) 2006-2013 ARM Limited
rgrover1 379:b379d350aaab 3 *
rgrover1 379:b379d350aaab 4 * Licensed under the Apache License, Version 2.0 (the "License");
rgrover1 379:b379d350aaab 5 * you may not use this file except in compliance with the License.
rgrover1 379:b379d350aaab 6 * You may obtain a copy of the License at
rgrover1 379:b379d350aaab 7 *
rgrover1 379:b379d350aaab 8 * http://www.apache.org/licenses/LICENSE-2.0
rgrover1 379:b379d350aaab 9 *
rgrover1 379:b379d350aaab 10 * Unless required by applicable law or agreed to in writing, software
rgrover1 379:b379d350aaab 11 * distributed under the License is distributed on an "AS IS" BASIS,
rgrover1 379:b379d350aaab 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rgrover1 379:b379d350aaab 13 * See the License for the specific language governing permissions and
rgrover1 379:b379d350aaab 14 * limitations under the License.
rgrover1 379:b379d350aaab 15 */
rgrover1 379:b379d350aaab 16
rgrover1 379:b379d350aaab 17 #ifndef __GAP_SCANNING_PARAMS_H__
rgrover1 379:b379d350aaab 18 #define __GAP_SCANNING_PARAMS_H__
rgrover1 379:b379d350aaab 19
rgrover1 379:b379d350aaab 20 class GapScanningParams {
rgrover1 379:b379d350aaab 21 public:
rgrover1 379:b379d350aaab 22 static const unsigned SCAN_INTERVAL_MIN = 0x0004; /**< Minimum Scan interval in 625 us units, i.e. 2.5 ms. */
rgrover1 379:b379d350aaab 23 static const unsigned SCAN_INTERVAL_MAX = 0x4000; /**< Maximum Scan interval in 625 us units, i.e. 10.24 s. */
rgrover1 379:b379d350aaab 24 static const unsigned SCAN_WINDOW_MIN = 0x0004; /**< Minimum Scan window in 625 us units, i.e. 2.5 ms. */
rgrover1 379:b379d350aaab 25 static const unsigned SCAN_WINDOW_MAX = 0x4000; /**< Maximum Scan window in 625 us units, i.e. 10.24 s. */
rgrover1 379:b379d350aaab 26 static const unsigned SCAN_TIMEOUT_MIN = 0x0001; /**< Minimum Scan timeout in seconds. */
rgrover1 379:b379d350aaab 27 static const unsigned SCAN_TIMEOUT_MAX = 0xFFFF; /**< Maximum Scan timeout in seconds. */
rgrover1 379:b379d350aaab 28
rgrover1 379:b379d350aaab 29 public:
rgrover1 531:bdcd44b03974 30 GapScanningParams(uint16_t interval = SCAN_INTERVAL_MAX,
rgrover1 531:bdcd44b03974 31 uint16_t window = SCAN_WINDOW_MAX,
rgrover1 531:bdcd44b03974 32 uint16_t timeout = 0,
rgrover1 531:bdcd44b03974 33 bool activeScanning = false);
rgrover1 379:b379d350aaab 34
rgrover1 531:bdcd44b03974 35 ble_error_t setInterval(uint16_t newIntervalInMS);
rgrover1 386:d30591c3d39c 36
rgrover1 531:bdcd44b03974 37 ble_error_t setWindow(uint16_t newWindowInMS);
rgrover1 386:d30591c3d39c 38
rgrover1 531:bdcd44b03974 39 ble_error_t setTimeout(uint16_t newTimeout);
rgrover1 386:d30591c3d39c 40
rgrover1 531:bdcd44b03974 41 void setActiveScanning(bool activeScanning);
rgrover1 393:77d0399da8aa 42
rgrover1 527:493185cebc03 43 public:
rgrover1 400:868801af787c 44 /* @Note: The following return durations in units of 0.625 ms */
rgrover1 379:b379d350aaab 45 uint16_t getInterval(void) const {return _interval;}
rgrover1 379:b379d350aaab 46 uint16_t getWindow(void) const {return _window; }
rgrover1 400:868801af787c 47
rgrover1 379:b379d350aaab 48 uint16_t getTimeout(void) const {return _timeout; }
rgrover1 393:77d0399da8aa 49 bool getActiveScanning(void) const {return _activeScanning;}
rgrover1 379:b379d350aaab 50
rgrover1 379:b379d350aaab 51 private:
rgrover1 400:868801af787c 52 uint16_t _interval; /**< Scan interval in units of 625us (between 2.5ms to 10.24s). */
rgrover1 400:868801af787c 53 uint16_t _window; /**< Scan window in units of 625us (between 2.5ms to 10.24s). */
rgrover1 379:b379d350aaab 54 uint16_t _timeout; /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
rgrover1 393:77d0399da8aa 55 bool _activeScanning; /**< obtain not only the advertising data from the peer device, but also their scanResponse if possible. */
rgrover1 379:b379d350aaab 56
rgrover1 379:b379d350aaab 57 private:
rgrover1 379:b379d350aaab 58 /* disallow copy constructor */
rgrover1 379:b379d350aaab 59 GapScanningParams(const GapScanningParams &);
rgrover1 379:b379d350aaab 60 GapScanningParams& operator =(const GapScanningParams &in);
rgrover1 379:b379d350aaab 61 };
rgrover1 379:b379d350aaab 62
rgrover1 379:b379d350aaab 63 #endif // ifndef __GAP_SCANNING_PARAMS_H__