14
14
* limitations under the License.
15
15
*/
16
16
17
- #ifndef __GAP_SCANNING_PARAMS_H__
18
- #define __GAP_SCANNING_PARAMS_H__
17
+ #ifndef MBED_GAP_SCANNING_PARAMS_H__
18
+ #define MBED_GAP_SCANNING_PARAMS_H__
19
19
20
+ /* *
21
+ * @addtogroup ble
22
+ * @{
23
+ * @addtogroup gap
24
+ * @{
25
+ */
26
+
27
+ /* *
28
+ * Parameters defining the scan process.
29
+ *
30
+ * The scan procedure is defined by four distinct parameters:
31
+ * - Scan window: Period during which the scanner listen to advertising
32
+ * channels. That value shall be in the 2.5ms to 10.24s. this value can be
33
+ * set at construction time, updated by calling setWindow() and retrieved
34
+ * by invoking getWindow().
35
+ *
36
+ * - Scan interval: interval between the start of two consecutive scan window.
37
+ * That value shall be greater or equal to the scan window value. The
38
+ * maximum allowed value is 10.24ms. The scan interval value can be set at
39
+ * construction time, updated with a call to setInterval() and queried by a
40
+ * call to getInterval().
41
+ *
42
+ * - Timeout: The duration of the scan procedure if any. It can be set at
43
+ * construction time, updated with setTimeout() and obtained from
44
+ * getTimeout().
45
+ *
46
+ * - Active scanning: If set then the scanner sends scan requests to scanable
47
+ * or connectable advertiser. Advertisers may respond to the scan request
48
+ * by a scan response containing the scan response payload. If not set then
49
+ * the scanner does not send any request. This flag is set at construction
50
+ * time, may be updated with the help of setActiveScanning() and get by
51
+ * getActiveScanning().
52
+ *
53
+ * @note If the scan windows duration is equal to the scan interval then the
54
+ * device should listen continuously during the scan procedure.
55
+ */
20
56
class GapScanningParams {
21
57
public:
22
- static const unsigned SCAN_INTERVAL_MIN = 0x0004 ; /* *< Minimum Scan interval in 625us units - 2.5ms. */
23
- static const unsigned SCAN_INTERVAL_MAX = 0x4000 ; /* *< Maximum Scan interval in 625us units - 10.24s. */
24
- static const unsigned SCAN_WINDOW_MIN = 0x0004 ; /* *< Minimum Scan window in 625us units - 2.5ms. */
25
- static const unsigned SCAN_WINDOW_MAX = 0x4000 ; /* *< Maximum Scan window in 625us units - 10.24s. */
26
- static const unsigned SCAN_TIMEOUT_MIN = 0x0001 ; /* *< Minimum Scan timeout in seconds. */
27
- static const unsigned SCAN_TIMEOUT_MAX = 0xFFFF ; /* *< Maximum Scan timeout in seconds. */
58
+ /* *
59
+ * Minimum Scan interval in 625us units - 2.5ms.
60
+ */
61
+ static const unsigned SCAN_INTERVAL_MIN = 0x0004 ;
62
+
63
+ /* *
64
+ * Maximum Scan interval in 625us units - 10.24s.
65
+ */
66
+ static const unsigned SCAN_INTERVAL_MAX = 0x4000 ;
67
+
68
+ /* *
69
+ * Minimum Scan window in 625us units - 2.5ms.
70
+ */
71
+ static const unsigned SCAN_WINDOW_MIN = 0x0004 ;
72
+
73
+ /* *
74
+ * Maximum Scan window in 625us units - 10.24s.
75
+ */
76
+ static const unsigned SCAN_WINDOW_MAX = 0x4000 ;
77
+
78
+ /* *
79
+ * Minimum Scan duration in seconds.
80
+ */
81
+ static const unsigned SCAN_TIMEOUT_MIN = 0x0001 ;
82
+
83
+ /* *
84
+ * Maximum Scan duration in seconds.
85
+ */
86
+ static const unsigned SCAN_TIMEOUT_MAX = 0xFFFF ;
28
87
29
88
public:
30
89
/* *
31
90
* Construct an instance of GapScanningParams.
32
91
*
33
- * @param[in] interval
34
- * The scan interval in milliseconds. Default is
35
- * GapScanningParams::SCAN_INTERVAL_MIN.
36
- * @param[in] window
37
- * The scan window in milliseconds. Default is
38
- * GapScanningParams::SCAN_WINDOW_MAX.
39
- * @param[in] timeout
40
- * The scan timeout in seconds. Default is 0.
41
- * @param[in] activeScanning
42
- * Set to True if active-scanning is required. This is used to
43
- * fetch the scan response from a peer if possible. Default is
44
- * false.
45
- */
46
- GapScanningParams (uint16_t interval = SCAN_INTERVAL_MAX,
47
- uint16_t window = SCAN_WINDOW_MAX,
48
- uint16_t timeout = 0 ,
49
- bool activeScanning = false );
50
-
51
- static const uint16_t UNIT_0_625_MS = 625 ; /* *< Number of microseconds in 0.625 milliseconds. */
92
+ * @param[in] interval Milliseconds interval between the start of two
93
+ * consecutive scan window. The value passed shall be between the scan
94
+ * window value and 10.24 seconds.
95
+ *
96
+ * @param[in] window Milliseconds period during which the device should
97
+ * listen to advertising channels. The value of the scan window shall be in
98
+ * the range 2.5ms to 10.24s.
99
+ *
100
+ * @param[in] timeout Duration in seconds of the scan procedure. The special
101
+ * value 0 may be used when the scan procedure is not time bounded.
102
+ *
103
+ * @param[in] activeScanning If true then the scanner sends scan requests to
104
+ * to scanable or connectable advertiser. Advertisers may respond to the
105
+ * scan request by a scan response containing the scan response payload. If
106
+ * false, the scanner does not send any request.
107
+ *
108
+ * @note If interval is equal to window
109
+ */
110
+ GapScanningParams (
111
+ uint16_t interval = SCAN_INTERVAL_MAX,
112
+ uint16_t window = SCAN_WINDOW_MAX,
113
+ uint16_t timeout = 0 ,
114
+ bool activeScanning = false
115
+ );
116
+
117
+ /* *
118
+ * Number of microseconds in 0.625 milliseconds.
119
+ */
120
+ static const uint16_t UNIT_0_625_MS = 625 ;
121
+
52
122
/* *
53
123
* Convert milliseconds to units of 0.625ms.
54
124
*
55
- * @param[in] durationInMillis
56
- * The number of milliseconds to convert.
125
+ * @param[in] durationInMillis Milliseconds to convert.
57
126
*
58
127
* @return The value of @p durationInMillis in units of 0.625ms.
59
128
*/
60
- static uint16_t MSEC_TO_SCAN_DURATION_UNITS (uint32_t durationInMillis) {
129
+ static uint16_t MSEC_TO_SCAN_DURATION_UNITS (uint32_t durationInMillis)
130
+ {
61
131
return (durationInMillis * 1000 ) / UNIT_0_625_MS;
62
132
}
63
133
64
134
/* *
65
- * Set the scan interval.
135
+ * Update the scan interval.
66
136
*
67
- * @param[in] newIntervalInMS
68
- * New scan interval in milliseconds.
137
+ * @param[in] newIntervalInMS New scan interval in milliseconds.
69
138
*
70
139
* @return BLE_ERROR_NONE if the new scan interval was set successfully.
71
140
*/
72
141
ble_error_t setInterval (uint16_t newIntervalInMS);
73
142
74
143
/* *
75
- * Set the scan window.
144
+ * Update the scan window.
76
145
*
77
- * @param[in] newWindowInMS
78
- * New scan window in milliseconds.
146
+ * @param[in] newWindowInMS New scan window in milliseconds.
79
147
*
80
148
* @return BLE_ERROR_NONE if the new scan window was set successfully.
81
149
*/
82
150
ble_error_t setWindow (uint16_t newWindowInMS);
83
151
84
152
/* *
85
- * Set the scan timeout.
153
+ * Update the scan timeout.
86
154
*
87
- * @param[in] newTimeout
88
- * New scan timeout in seconds.
155
+ * @param[in] newTimeout New scan timeout in seconds.
89
156
*
90
157
* @return BLE_ERROR_NONE if the new scan window was set successfully.
91
158
*/
92
159
ble_error_t setTimeout (uint16_t newTimeout);
93
160
94
161
/* *
95
- * Set active scanning. This is used to fetch the scan response from a peer
96
- * if possible.
162
+ * Update the active scanning flag.
97
163
*
98
- * @param[in] activeScanning
99
- * The new boolean value of active scanning.
164
+ * @param[in] activeScanning Mew boolean value of active scanning.
100
165
*/
101
166
void setActiveScanning (bool activeScanning);
102
167
@@ -106,7 +171,8 @@ class GapScanningParams {
106
171
*
107
172
* @return the scan interval in units of 0.625ms.
108
173
*/
109
- uint16_t getInterval (void ) const {
174
+ uint16_t getInterval (void ) const
175
+ {
110
176
return _interval;
111
177
}
112
178
@@ -115,7 +181,8 @@ class GapScanningParams {
115
181
*
116
182
* @return the scan window in units of 0.625ms.
117
183
*/
118
- uint16_t getWindow (void ) const {
184
+ uint16_t getWindow (void ) const
185
+ {
119
186
return _window;
120
187
}
121
188
@@ -124,7 +191,8 @@ class GapScanningParams {
124
191
*
125
192
* @return The scan timeout in seconds.
126
193
*/
127
- uint16_t getTimeout (void ) const {
194
+ uint16_t getTimeout (void ) const
195
+ {
128
196
return _timeout;
129
197
}
130
198
@@ -133,20 +201,41 @@ class GapScanningParams {
133
201
*
134
202
* @return True if active scanning is set, false otherwise.
135
203
*/
136
- bool getActiveScanning (void ) const {
204
+ bool getActiveScanning (void ) const
205
+ {
137
206
return _activeScanning;
138
207
}
139
208
140
209
private:
141
- uint16_t _interval; /* *< Scan interval in units of 625us (between 2.5ms and 10.24s). */
142
- uint16_t _window; /* *< Scan window in units of 625us (between 2.5ms and 10.24s). */
143
- uint16_t _timeout; /* *< Scan timeout between 0x0001 and 0xFFFF in seconds; 0x0000 disables timeout. */
144
- bool _activeScanning; /* *< Obtain the peer device's advertising data and (if possible) scanResponse. */
210
+ /* *
211
+ * Scan interval in units of 625us (between 2.5ms and 10.24s).
212
+ */
213
+ uint16_t _interval;
214
+
215
+ /* *
216
+ * Scan window in units of 625us (between 2.5ms and 10.24s).
217
+ */
218
+ uint16_t _window;
219
+
220
+ /* *
221
+ * Scan timeout between 0x0001 and 0xFFFF in seconds; 0x0000 disables timeout.
222
+ */
223
+ uint16_t _timeout;
224
+
225
+ /* *
226
+ * Obtain the peer device's advertising data and (if possible) scanResponse.
227
+ */
228
+ bool _activeScanning;
145
229
146
230
private:
147
231
/* Disallow copy constructor. */
148
232
GapScanningParams (const GapScanningParams &);
149
233
GapScanningParams& operator =(const GapScanningParams &in);
150
234
};
151
235
152
- #endif /* ifndef __GAP_SCANNING_PARAMS_H__ */
236
+ /* *
237
+ * @}
238
+ * @}
239
+ */
240
+
241
+ #endif /* ifndef MBED_GAP_SCANNING_PARAMS_H__ */
0 commit comments