Hello Everyone
I am working on nRF52840 DK, SDK V-15.0.
How we can stop advertising? Which API is used to stop advertising?
Quick help will be appreciated.
Regards
Raj
Hello Everyone
I am working on nRF52840 DK, SDK V-15.0.
How we can stop advertising? Which API is used to stop advertising?
Quick help will be appreciated.
Regards
Raj
Hi Raj,
Update: Take a look at the sd_ble_gap_adv_stop
() function in the softdevice (ble_gap.h file). This devzone case could also be useful.
/**@brief Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). * * @mscs * @mmsc{@ref BLE_GAP_ADV_MSC} * @mmsc{@ref BLE_GAP_WL_SHARE_MSC} * @endmscs * * @param[in] adv_handle The advertising handle that should stop advertising. * * @retval ::NRF_SUCCESS The BLE stack has stopped advertising. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Invalid advertising handle. * @retval ::NRF_ERROR_INVALID_STATE The advertising handle is not advertising. */ SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(uint8_t adv_handle));
Normally, you will advertise for 180 seconds & then advertising will turn off by itself until you press button 1 on the dev kit to turn it back on (works for most examples). See this line in main.c of the ble_app_uart peripheral example (or most other BLE examples):
#define APP_ADV_DURATION 18000 /**< The advertising duration (180 seconds) in units of 10 milliseconds. */
Also take a look at the ble_adv_modes_config_t struct in ble_advertising.h:
typedef struct { bool ble_adv_on_disconnect_disabled; /**< Enable or disable automatic return to advertising upon disconnecting.*/ bool ble_adv_whitelist_enabled; /**< Enable or disable use of the whitelist. */ bool ble_adv_directed_high_duty_enabled; /**< Enable or disable direct advertising mode. can only be used if ble_adv_legacy_enabled is true. */ bool ble_adv_directed_enabled; /**< Enable or disable direct advertising mode. */ bool ble_adv_fast_enabled; /**< Enable or disable fast advertising mode. */ bool ble_adv_slow_enabled; /**< Enable or disable slow advertising mode. */ uint32_t ble_adv_directed_interval; /**< Advertising interval for directed advertising. */ uint32_t ble_adv_directed_timeout; /**< Time-out (number of tries) for direct advertising. */ uint32_t ble_adv_fast_interval; /**< Advertising interval for fast advertising. */ uint32_t ble_adv_fast_timeout; /**< Time-out (in seconds) for fast advertising. */ uint32_t ble_adv_slow_interval; /**< Advertising interval for slow advertising. */ uint32_t ble_adv_slow_timeout; /**< Time-out (in seconds) for slow advertising. */ bool ble_adv_extended_enabled; /**< Enable or disable extended advertising. */ uint32_t ble_adv_secondary_phy; /**< PHY for the secondary (extended) advertising @ref BLE_GAP_PHYS (BLE_GAP_PHY_1MBPS, BLE_GAP_PHY_2MBPS or BLE_GAP_PHY_CODED). */ uint32_t ble_adv_primary_phy; /**< PHY for the primary advertising. @ref BLE_GAP_PHYS (BLE_GAP_PHY_1MBPS, BLE_GAP_PHY_2MBPS or BLE_GAP_PHY_CODED). */ } ble_adv_modes_config_t;
There, you can see a timeout for fast advertising & slow advertising (you will only need to worry about fast advertising most likely). The advertising timeout is set in advertising_init().
Kind Regards,
Bjørn
So there's no way to stop advertising once it's started?
You just have to wait for it to time-out?
I have updated the post. My bad for misreading the question.
Hi Bjørn Could you please tell me how to disable softdevice for nRF52840 device? I tried with following APIs to disable softdevice but it's not working:
1. nrf_sdh_disable_request()
2. sd_softdevice_disable();
Thanks
Hi Bjørn Could you please tell me how to disable softdevice for nRF52840 device? I tried with following APIs to disable softdevice but it's not working:
1. nrf_sdh_disable_request()
2. sd_softdevice_disable();
Thanks