Updated
Fork of BLE_API by
Diff: ble/GapScanningParams.h
- Revision:
- 1183:1589830dbdb7
- Parent:
- 1179:4ab722f8dca0
--- a/ble/GapScanningParams.h Wed Apr 06 19:15:34 2016 +0100 +++ b/ble/GapScanningParams.h Wed Apr 06 19:15:36 2016 +0100 @@ -27,31 +27,115 @@ static const unsigned SCAN_TIMEOUT_MAX = 0xFFFF; /**< Maximum Scan timeout in seconds. */ public: + /** + * Construct an instance of GapScanningParams. + * + * @param[in] interval + * The scan interval in milliseconds. Default is + * GapScanningParams::SCAN_INTERVAL_MIN. + * @param[in] window + * The scan window in milliseconds. Default is + * GapScanningParams::SCAN_WINDOW_MAX. + * @param[in] timeout + * The scan timeout in seconds. Default is 0. + * @param[in] activeScanning + * Set to True if active-scanning is required. This is used to + * fetch the scan response from a peer if possible. Default is + * false. + */ GapScanningParams(uint16_t interval = SCAN_INTERVAL_MAX, uint16_t window = SCAN_WINDOW_MAX, uint16_t timeout = 0, bool activeScanning = false); static const uint16_t UNIT_0_625_MS = 625; /**< Number of microseconds in 0.625 milliseconds. */ + /** + * Convert milliseconds to units of 0.625ms. + * + * @param[in] durationInMillis + * The number of milliseconds to convert. + * + * @return The value of @p durationInMillis in units of 0.625ms. + */ static uint16_t MSEC_TO_SCAN_DURATION_UNITS(uint32_t durationInMillis) { return (durationInMillis * 1000) / UNIT_0_625_MS; } + /** + * Set the scan interval. + * + * @param[in] newIntervalInMS + * New scan interval in milliseconds. + * + * @return BLE_ERROR_NONE if the new scan interval was set successfully. + */ ble_error_t setInterval(uint16_t newIntervalInMS); + /** + * Set the scan window. + * + * @param[in] newWindowInMS + * New scan window in milliseconds. + * + * @return BLE_ERROR_NONE if the new scan window was set successfully. + */ ble_error_t setWindow(uint16_t newWindowInMS); + /** + * Set the scan timeout. + * + * @param[in] newTimeout + * New scan timeout in seconds. + * + * @return BLE_ERROR_NONE if the new scan window was set successfully. + */ ble_error_t setTimeout(uint16_t newTimeout); - void setActiveScanning(bool activeScanning); + /** + * Set active scanning. This is used to fetch the scan response from a peer + * if possible. + * + * @param[in] activeScanning + * The new boolean value of active scanning. + */ + void setActiveScanning(bool activeScanning); public: - /* @Note: The following return durations in units of 0.625ms */ - uint16_t getInterval(void) const {return _interval;} - uint16_t getWindow(void) const {return _window; } + /** + * Get the scan interval. + * + * @return the scan interval in units of 0.625ms. + */ + uint16_t getInterval(void) const { + return _interval; + } + + /** + * Get the scan window. + * + * @return the scan window in units of 0.625ms. + */ + uint16_t getWindow(void) const { + return _window; + } - uint16_t getTimeout(void) const {return _timeout; } - bool getActiveScanning(void) const {return _activeScanning;} + /** + * Get the scan timeout. + * + * @return The scan timeout in seconds. + */ + uint16_t getTimeout(void) const { + return _timeout; + } + + /** + * Check whether active scanning is set. + * + * @return True if active scanning is set, false otherwise. + */ + bool getActiveScanning(void) const { + return _activeScanning; + } private: uint16_t _interval; /**< Scan interval in units of 625us (between 2.5ms and 10.24s). */ @@ -65,4 +149,4 @@ GapScanningParams& operator =(const GapScanningParams &in); }; -#endif // ifndef __GAP_SCANNING_PARAMS_H__ \ No newline at end of file +#endif /* ifndef __GAP_SCANNING_PARAMS_H__ */ \ No newline at end of file