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.
Fork of LinkNode-Test by
GapScanningParams.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_SCANNING_PARAMS_H__ 00018 #define __GAP_SCANNING_PARAMS_H__ 00019 00020 class GapScanningParams { 00021 public: 00022 static const unsigned SCAN_INTERVAL_MIN = 0x0004; /**< Minimum Scan interval in 625us units - 2.5ms. */ 00023 static const unsigned SCAN_INTERVAL_MAX = 0x4000; /**< Maximum Scan interval in 625us units - 10.24s. */ 00024 static const unsigned SCAN_WINDOW_MIN = 0x0004; /**< Minimum Scan window in 625us units - 2.5ms. */ 00025 static const unsigned SCAN_WINDOW_MAX = 0x4000; /**< Maximum Scan window in 625us units - 10.24s. */ 00026 static const unsigned SCAN_TIMEOUT_MIN = 0x0001; /**< Minimum Scan timeout in seconds. */ 00027 static const unsigned SCAN_TIMEOUT_MAX = 0xFFFF; /**< Maximum Scan timeout in seconds. */ 00028 00029 public: 00030 GapScanningParams(uint16_t interval = SCAN_INTERVAL_MAX, 00031 uint16_t window = SCAN_WINDOW_MAX, 00032 uint16_t timeout = 0, 00033 bool activeScanning = false); 00034 00035 static const uint16_t UNIT_0_625_MS = 625; /**< Number of microseconds in 0.625 milliseconds. */ 00036 static uint16_t MSEC_TO_SCAN_DURATION_UNITS(uint32_t durationInMillis) { 00037 return (durationInMillis * 1000) / UNIT_0_625_MS; 00038 } 00039 00040 ble_error_t setInterval(uint16_t newIntervalInMS); 00041 00042 ble_error_t setWindow(uint16_t newWindowInMS); 00043 00044 ble_error_t setTimeout(uint16_t newTimeout); 00045 00046 void setActiveScanning(bool activeScanning); 00047 00048 public: 00049 /* @Note: The following return durations in units of 0.625ms */ 00050 uint16_t getInterval(void) const {return _interval;} 00051 uint16_t getWindow(void) const {return _window; } 00052 00053 uint16_t getTimeout(void) const {return _timeout; } 00054 bool getActiveScanning(void) const {return _activeScanning;} 00055 00056 private: 00057 uint16_t _interval; /**< Scan interval in units of 625us (between 2.5ms and 10.24s). */ 00058 uint16_t _window; /**< Scan window in units of 625us (between 2.5ms and 10.24s). */ 00059 uint16_t _timeout; /**< Scan timeout between 0x0001 and 0xFFFF in seconds; 0x0000 disables timeout. */ 00060 bool _activeScanning; /**< Obtain the peer device's advertising data and (if possible) scanResponse. */ 00061 00062 private: 00063 /* Disallow copy constructor. */ 00064 GapScanningParams(const GapScanningParams &); 00065 GapScanningParams& operator =(const GapScanningParams &in); 00066 }; 00067 00068 #endif // ifndef __GAP_SCANNING_PARAMS_H__
Generated on Tue Jul 12 2022 16:00:20 by
