-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BLE API does not handle minimum and maximum intervals as in the specification #133
Comments
ARM Internal Ref: IOTSFW-1368 |
@andresag01 |
@rgrover: Yes, it seems that this is the case. For instance, the documentation for getMinAdvertisingInterval() states:
Which does not mention connectable or non-connectable packets. |
please submit a PR to fix this documentation |
The specification state that advInterval shall be in range [20ms, 10.24s] which means that the standard mandate that the minimum advertising interval is 20ms. The standard also say that for Plus, there is a low duty cycle and high duty cycle advertising rate for To summarize advertising interval:
I think that the current API can be improved:
static const unsigned GAP_ADV_PARAMS_INTERVAL_MIN = 0x0020;
static const unsigned GAP_ADV_PARAMS_INTERVAL_MIN_NONCON = 0x00A0;
static const unsigned GAP_ADV_PARAMS_INTERVAL_MAX = 0x4000;
static const unsigned GAP_ADV_PARAMS_TIMEOUT_MAX = 0x3FFF;
void setAdvertisingInterval(uint16_t interval) {
if (interval == 0) {
stopAdvertising();
} else if (interval < getMinAdvertisingInterval()) {
interval = getMinAdvertisingInterval();
}
_advParams.setInterval(interval);
}
/*
* @note: This API is now *deprecated* and will be dropped in the future.
* You should use the parallel API from Gap directly. A former call to
* ble.setAdvertisingInterval(...) should now be achieved using
* ble.gap().setAdvertisingInterval(...).
*/
This field must be set to 0 if connectionMode is equal to ADV_CONNECTABLE_DIRECTED. |
I've deleted the obsolete comment block from the documentation of |
@pan- I checked the source for both ble and ble-nrf51822 to see what was really going on. Indeed the So far it looks like the API allows setting wrong values for the interval without taking into account the advertising type. However, the actual checks are performed in the implementation of Strictly speaking there is no bug in the API, but perhaps there is room for improvement that could inform the user of a problem with the advertising parameters, before a call to setAdvertisingInterval(20); <--- If we return an error code here, there will be a failure since the defaulf advertising type is ADV_CONNECTABLE_UNDIRECTED.
setAdvertisingType(ADV_NON_CONNECTABLE_UNDIRECTED); |
In the BLE API Gap.h contains the following functions:
getMinAdvertisingInterval()
getMinNonConnectableAdvertisingInterval()
getMaxAdvertising interval()
The Bluetooth v4.2 specification states the following in [Vol 6, Part B] Section 4.4.2.2:
Taking this into account, it is not clear from the BLE API documentation what are the differences between
getMinAdvertisingInterval()
andgetMinNonConnectableAdvertisingInterval()
.The text was updated successfully, but these errors were encountered: