#include <cs_Advertiser.h>
◆ Advertiser() [1/2]
◆ Advertiser() [2/2]
◆ allocateAdvertisementDataBuffers()
bool Advertiser::allocateAdvertisementDataBuffers |
( |
bool |
scanResponse | ) |
|
|
private |
Allocate the advertisement data buffers.
Returns true on success.
◆ configureAdvertisement() [1/2]
void Advertiser::configureAdvertisement |
( |
IBeacon & |
beacon, |
|
|
bool |
asScanResponse = false |
|
) |
| |
Configure the advertisement to hold iBeacon data.
Sets and updates the advertisement data.
- Parameters
-
[in] | beacon | Object with the iBeacon parameters. |
[in] | asScanResponse | Whether to set the iBeacon data in the scan response. |
◆ configureAdvertisement() [2/2]
void Advertiser::configureAdvertisement |
( |
ServiceData & |
serviceData, |
|
|
bool |
asScanResponse = false |
|
) |
| |
Configure the advertisement to hold Crownstone service data.
Sets and updates the advertisement data.
- Parameters
-
[in] | serviceData | The Crownstone service data class. |
[in] | asScanResponse | Whether to set the service data in the scan response. |
◆ configureAdvertisementParameters()
void Advertiser::configureAdvertisementParameters |
( |
| ) |
|
|
private |
Set advertisement parameters from member variables.
◆ getAdvertisementBuffer()
uint8_t * Advertiser::getAdvertisementBuffer |
( |
bool |
scanResponse | ) |
|
|
private |
Gets an advertisement data buffer that's not in use.
- Parameters
-
[in] | scanResponse | Whether to get a scan response data buffer. |
- Returns
- Pointer to the buffer, or a nullptr if no free buffer is found.
◆ getInstance()
Get the static singleton instance.
◆ handleEvent()
void Advertiser::handleEvent |
( |
event_t & |
event | ) |
|
|
virtual |
◆ init()
void Advertiser::init |
( |
| ) |
|
Initialize the advertiser.
Can only be done after the radio has been initialized. It's best to configure the advertiser before initializing.
Starts listening for events.
◆ markAdvertisementBuffer()
void Advertiser::markAdvertisementBuffer |
( |
const uint8_t * |
buffer, |
|
|
bool |
inUse, |
|
|
bool |
scanResponse |
|
) |
| |
|
private |
Mark an advertisement buffer as in use / no longer in use.
- Parameters
-
[in] | buffer | Pointer to the advertisement data buffer. |
[in] | inUse | Whether to mark buffer as in use. |
[in] | scanResponse | Whether the buffer is a scan response data buffer. |
◆ onConnect()
◆ onConnectOutgoing()
void Advertiser::onConnectOutgoing |
( |
| ) |
|
|
private |
◆ onDisconnect()
void Advertiser::onDisconnect |
( |
| ) |
|
|
private |
◆ onTick()
void Advertiser::onTick |
( |
| ) |
|
|
private |
◆ operator=()
◆ printAdvertisement()
void Advertiser::printAdvertisement |
( |
| ) |
|
|
private |
◆ restartAdvertising()
void Advertiser::restartAdvertising |
( |
| ) |
|
|
private |
Stop and start advertising.
This will make sure new advertising parameters are applied.
◆ setAdvertisementData() [1/2]
void Advertiser::setAdvertisementData |
( |
IBeacon & |
beacon, |
|
|
bool |
asScanResponse |
|
) |
| |
|
private |
Sets the advertisement data.
Writes to _config_advdata.
- Parameters
-
[in] | beacon | The iBeacon data. |
[in] | asScanResponse | Whether to set the iBeacon data in the scan response. |
◆ setAdvertisementData() [2/2]
void Advertiser::setAdvertisementData |
( |
ServiceData & |
serviceData, |
|
|
bool |
asScanResponse |
|
) |
| |
|
private |
Sets the advertisement data.
- Parameters
-
[in] | serviceData | The Crownstone service data class. |
[in] | asScanResponse | Whether to set the service data in the scan response. |
◆ setAdvertisingInterval()
void Advertiser::setAdvertisingInterval |
( |
uint16_t |
advertisingInterval | ) |
|
Set the advertising interval in 0.625 ms units.
◆ setConnectable()
void Advertiser::setConnectable |
( |
bool |
connectable | ) |
|
Set whether to advertise being connectable.
- Parameters
-
[in] | connectable | True when connectable. |
◆ setConnectableAdvParams()
void Advertiser::setConnectableAdvParams |
( |
| ) |
|
|
private |
Sets advertisement parameters to be connectable.
◆ setDeviceName()
void Advertiser::setDeviceName |
( |
const std::string & |
deviceName | ) |
|
◆ setLowTxPower()
void Advertiser::setLowTxPower |
( |
| ) |
|
Sets TX power to low TX power as stored in State.
◆ setNonConnectableAdvParams()
void Advertiser::setNonConnectableAdvParams |
( |
| ) |
|
|
private |
Sets advertisement parameters to be non-connectable.
◆ setNormalTxPower()
void Advertiser::setNormalTxPower |
( |
| ) |
|
Sets TX power to normal TX power as stored in State.
◆ setTxPower()
void Advertiser::setTxPower |
( |
int8_t |
power | ) |
|
Set the radio transmit power.
- Parameters
-
[in] | power | Power in dBm. Accepted values are -40, -20, -16, -12, -8, -4, 0, and 4. |
◆ startAdvertising()
void Advertiser::startAdvertising |
( |
| ) |
|
Start advertising.
Make sure you configured an advertisement before starting to advertise.
◆ stopAdvertising()
void Advertiser::stopAdvertising |
( |
| ) |
|
◆ updateAdvertisementData()
void Advertiser::updateAdvertisementData |
( |
| ) |
|
|
private |
Sets and updates advertisement data.
Sets _advData, and sets it at softdevice if there's a valid handle. Uses a different buffer than previous time.
◆ updateAdvertisementParams()
void Advertiser::updateAdvertisementParams |
( |
| ) |
|
|
private |
Updates the advertisement parameters.
When parameters are changed, advertising will be stopped and started again. Else, only the service data is updated.
◆ updateTxPower()
void Advertiser::updateTxPower |
( |
| ) |
|
|
private |
Set the cached TX power at the softdevice.
Can only be done once the advHandle is set.
◆ _advData
ble_gap_adv_data_t Advertiser::_advData |
|
private |
◆ _advertisementDataBufferCount
const uint8_t Advertiser::_advertisementDataBufferCount = 2 |
|
staticprivate |
◆ _advertisementDataBuffers
◆ _advertisementDataBuffersInUse
◆ _advertisementDataBufferSize
const uint8_t Advertiser::_advertisementDataBufferSize = BLE_GAP_ADV_SET_DATA_SIZE_MAX |
|
staticprivate |
◆ _advertising
bool Advertiser::_advertising = false |
|
private |
◆ _advertisingInterval
uint16_t Advertiser::_advertisingInterval = g_ADVERTISEMENT_INTERVAL |
|
private |
◆ _advHandle
uint8_t Advertiser::_advHandle = BLE_GAP_ADV_SET_HANDLE_NOT_SET |
|
private |
◆ _advParams
ble_gap_adv_params_t Advertiser::_advParams |
|
private |
◆ _advParamsChanged
bool Advertiser::_advParamsChanged = false |
|
private |
◆ _configAdvertisementData
ble_advdata_t Advertiser::_configAdvertisementData |
|
private |
Advertisement data config, filled by one or more advertisement data fields.
In between step to be encoded into an advertisement data buffer.
◆ _configScanResponse
ble_advdata_t Advertiser::_configScanResponse |
|
private |
Scan response data config, filled by one or more advertisement data fields.
In between step to be encoded into a scan response data buffer.
◆ _crownstoneServiceData
ble_advdata_service_data_t Advertiser::_crownstoneServiceData |
|
private |
◆ _deviceName
std::string Advertiser::_deviceName = "none" |
|
private |
◆ _ibeaconManufData
ble_advdata_manuf_data_t Advertiser::_ibeaconManufData |
|
private |
◆ _includeAdvertisementData
bool Advertiser::_includeAdvertisementData = false |
|
private |
Whether the advertisement data config has been filled.
When true, the advertisement data buffers are also allocated.
◆ _includeScanResponseData
bool Advertiser::_includeScanResponseData = false |
|
private |
Whether the scan response data config has been filled.
When true, the scan response data buffers are also allocated.
◆ _isConnectable
bool Advertiser::_isConnectable = false |
|
private |
◆ _isInitialized
bool Advertiser::_isInitialized = false |
|
private |
◆ _serviceData
◆ _stack
Stack* Advertiser::_stack = nullptr |
|
private |
◆ _startOnNextTick
bool Advertiser::_startOnNextTick = false |
|
private |
◆ _txPower
int8_t Advertiser::_txPower = 0 |
|
private |
◆ _wantAdvertising
bool Advertiser::_wantAdvertising = false |
|
private |
◆ _wantConnectable
bool Advertiser::_wantConnectable = true |
|
private |
The documentation for this class was generated from the following file: