1.2.2.1.1.4.37 BLE_GAP_SetAdvEnable
C
uint16_t BLE_GAP_SetAdvEnable(bool enable, uint16_t duration);
Description
Start or stop advertising.
Note
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.
Events generated
BLE_GAP_EVT_CONNECTED Generated when connection established.
BLE_GAP_EVT_ADV_TIMEOUT Generated when adv. enabled and timeout (by duration).
Parameters
Parameter | Description |
---|---|
[in] enable | Advertising control option. |
[in] duration | Duration for advertising. (Unit: 10 ms) Set to 0 to continuously advertise. |
Return values
Return value | Description |
---|---|
MBA_RES_SUCCESS | Successfully start or stop advertising. |
MBA_RES_OOM | Internal memory allocation failure. |
MBA_RES_INVALID_PARA | Invalid parameters. |
MBA_RES_COMMAND_DISALLOWED | Command disallowed when extended Adv. feature is in-use. |