@@ -123,16 +123,20 @@ class AdvertisingParameters {
123
123
* @param[in] minInterval, maxInterval Time interval between two advertisement.
124
124
* A range is provided to the LE subsystem, so it can adjust the advertising
125
125
* interval with other transmission happening on the BLE radio.
126
+ * @param[in] useLegacyPDU If true legacy PDU shall be used for advertising.
126
127
*
127
128
* @note If CONNECTABLE_UNDIRECTED or CONNECTABLE_DIRECTED advertising is used
128
129
* you must use legacy PDU.
129
130
*
130
131
* @note If values in input are out of range, they will be normalized.
132
+ *
133
+ * @note If type selected is incompatible with non legacy PDU, legacy PDU will be used.
131
134
*/
132
135
AdvertisingParameters (
133
136
advertising_type_t advType = advertising_type_t ::CONNECTABLE_UNDIRECTED,
134
137
adv_interval_t minInterval = adv_interval_t (DEFAULT_ADVERTISING_INTERVAL_MIN),
135
- adv_interval_t maxInterval = adv_interval_t (DEFAULT_ADVERTISING_INTERVAL_MAX)
138
+ adv_interval_t maxInterval = adv_interval_t (DEFAULT_ADVERTISING_INTERVAL_MAX),
139
+ bool useLegacyPDU = true
136
140
) :
137
141
_advType (advType),
138
142
_minInterval (minInterval),
@@ -150,14 +154,47 @@ class AdvertisingParameters {
150
154
_channel39 (true ),
151
155
_anonymous (false ),
152
156
_notifyOnScan (false ),
153
- _legacyPDU (true ),
157
+ _legacyPDU (useLegacyPDU ),
154
158
_includeHeaderTxPower (false )
155
159
{
156
- /* Min interval is slightly larger than in other modes. */
157
- if (_advType == advertising_type_t ::NON_CONNECTABLE_UNDIRECTED) {
158
- _minInterval = adv_interval_t (std::max (_minInterval.value (), GAP_ADV_PARAMS_INTERVAL_MIN_NONCON));
159
- _maxInterval = adv_interval_t (std::max (_maxInterval.value (), GAP_ADV_PARAMS_INTERVAL_MIN_NONCON));
160
- }
160
+ normalize ();
161
+ }
162
+
163
+ /* *
164
+ * Construct an instance of GapAdvertisingParams.
165
+ *
166
+ * @param[in] advType Type of advertising.
167
+ * @param[in] useLegacyPDU If true legacy PDU shall be used for advertising.
168
+ *
169
+ * @note If CONNECTABLE_UNDIRECTED or CONNECTABLE_DIRECTED advertising is used
170
+ * you must use legacy PDU.
171
+ *
172
+ * @note If type selected is incompatible with non legacy PDU, legacy PDU will be used.
173
+ */
174
+ AdvertisingParameters (
175
+ advertising_type_t advType,
176
+ bool useLegacyPDU
177
+ ) :
178
+ _advType (advType),
179
+ _minInterval (adv_interval_t (DEFAULT_ADVERTISING_INTERVAL_MIN)),
180
+ _maxInterval (adv_interval_t (DEFAULT_ADVERTISING_INTERVAL_MAX)),
181
+ _peerAddressType (target_peer_address_type_t ::PUBLIC),
182
+ _ownAddressType (own_address_type_t ::RANDOM),
183
+ _policy (advertising_filter_policy_t ::NO_FILTER),
184
+ _primaryPhy (phy_t ::LE_1M),
185
+ _secondaryPhy (phy_t ::LE_1M),
186
+ _peerAddress (),
187
+ _txPower (127 ),
188
+ _maxSkip (0 ),
189
+ _channel37 (true ),
190
+ _channel38 (true ),
191
+ _channel39 (true ),
192
+ _anonymous (false ),
193
+ _notifyOnScan (false ),
194
+ _legacyPDU (useLegacyPDU),
195
+ _includeHeaderTxPower (false )
196
+ {
197
+ normalize ();
161
198
}
162
199
163
200
public:
@@ -552,6 +589,23 @@ class AdvertisingParameters {
552
589
return _anonymous;
553
590
}
554
591
592
+ private:
593
+ /* *
594
+ * Enforce limits on parameters.
595
+ */
596
+ void normalize ()
597
+ {
598
+ /* Min interval is slightly larger than in other modes. */
599
+ if (_advType == advertising_type_t ::NON_CONNECTABLE_UNDIRECTED) {
600
+ _minInterval = adv_interval_t (std::max (_minInterval.value (), GAP_ADV_PARAMS_INTERVAL_MIN_NONCON));
601
+ _maxInterval = adv_interval_t (std::max (_maxInterval.value (), GAP_ADV_PARAMS_INTERVAL_MIN_NONCON));
602
+ }
603
+ if (_advType == advertising_type_t ::CONNECTABLE_DIRECTED ||
604
+ _advType == advertising_type_t ::CONNECTABLE_UNDIRECTED) {
605
+ _legacyPDU = true ;
606
+ }
607
+ }
608
+
555
609
private:
556
610
advertising_type_t _advType;
557
611
/* The advertising interval in ADV duration units (in other words, 0.625ms). */
0 commit comments