BLE_GAP_SetAdvEnable

C

uint16_t BLE_GAP_SetAdvEnable(bool enable, uint16_t duration);

Description

Starts or stop advertising.

Note

The duration parameter is only applicable when the advertising type is not set to Directed Advertising. Advertising will continue for the specified duration, until stopped by a command, until a connection is established, or until it times out due to high duty cycle Directed Advertising. This API is part of the legacy advertising feature and will be disallowed if any extended advertising feature API has been used. See Categories of advertising APIs and events for details on advertising APIs. The BLE_GAP_AdvInit function must be called prior to using this API. The BLE_GAP_SetAdvParams function should be called before this API to set the advertising parameters. The BLE_GAP_SetAdvData or BLE_GAP_SetScanRspData function should be called before this API to set the advertising or scan response data.

The duration is only valid when advertising type is not set to Directed Advertising. The advertising shall be continuous within the duration or until the disable command is issued or until a connection is created or until the Advertising is timed out due to high duty cycle Directed Advertising. In these cases, advertising is then disabled.

This API belongs to legacy advertising feature. It will be disallowed if any one API belongs extended advertising feature is issued before. Categories of advertising APIs and events for details of advertising APIs.

BLE_GAP_AdvInit is required for this API.

Parameters

ParameterDescription
[in] enableControl flag to start or stop advertising.
[in] durationDuration for advertising in 10 ms units. Set to 0 for continuous advertising.
*

Return values

Return valueDescription
MBA_RES_SUCCESSSuccessfully starts or stops advertising.
MBA_RES_OOMInternal memory allocation failure occurred.
MBA_RES_INVALID_PARAThe parameters provided are invalid.
MBA_RES_COMMAND_DISALLOWEDCommand disallowed when extended advertising feature is in use.