File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -161,6 +161,29 @@ class AdvertisingParameters {
161
161
}
162
162
163
163
public:
164
+ /* *
165
+ * Update the advertising type and whether to use legacy PDU.
166
+ *
167
+ * @note If legacy PDU is not used then you cannot use
168
+ * CONNECTABLE_UNDIRECTED nor CONNECTABLE_DIRECTED.
169
+ *
170
+ * @param[in] newAdvType The new advertising type.
171
+ *
172
+ * @param[in] legacy If true, legacy PDU will be used.
173
+ *
174
+ * @return reference to this object.
175
+ */
176
+ AdvertisingParameters &setType (advertising_type_t newAdvType, bool legacy)
177
+ {
178
+ if (newAdvType == advertising_type_t ::CONNECTABLE_UNDIRECTED ||
179
+ newAdvType == advertising_type_t ::CONNECTABLE_DIRECTED) {
180
+ /* these types can only be used with legacy PDUs */
181
+ MBED_ASSERT (legacy);
182
+ }
183
+ _advType = newAdvType;
184
+ _legacyPDU = legacy;
185
+ return *this ;
186
+ }
164
187
165
188
/* *
166
189
* Update the advertising type.
Original file line number Diff line number Diff line change @@ -2150,6 +2150,14 @@ ble_error_t GenericGap::setExtendedAdvertisingParameters(
2150
2150
return BLE_ERROR_OPERATION_NOT_PERMITTED;
2151
2151
}
2152
2152
2153
+ /* check for illegal parameter combination */
2154
+ if ((params.getType () == advertising_type_t ::CONNECTABLE_UNDIRECTED ||
2155
+ params.getType () == advertising_type_t ::CONNECTABLE_DIRECTED) &&
2156
+ params.getUseLegacyPDU () == false ) {
2157
+ /* these types can only be used with legacy PDUs */
2158
+ return BLE_ERROR_INVALID_PARAM;
2159
+ }
2160
+
2153
2161
pal::advertising_event_properties_t event_properties (params.getType ());
2154
2162
event_properties.include_tx_power = params.getTxPowerInHeader ();
2155
2163
event_properties.omit_advertiser_address = params.getAnonymousAdvertising ();
You can’t perform that action at this time.
0 commit comments