本文整理汇总了C++中BLE::startAdvertising方法的典型用法代码示例。如果您正苦于以下问题:C++ BLE::startAdvertising方法的具体用法?C++ BLE::startAdvertising怎么用?C++ BLE::startAdvertising使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BLE
的用法示例。
在下文中一共展示了BLE::startAdvertising方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: app_start
void app_start(int, char *[])
{
ble.init();
ble.onDisconnection(disconnectionCallback);
/*
* Load parameters from (platform specific) persistent storage. Parameters
* can be set to non-default values while the URIBeacon is in configuration
* mode (within the first 60 seconds of power-up). Thereafter, parameters
* get copied out to persistent storage before switching to normal URIBeacon
* operation.
*/
bool fetchedFromPersistentStorage = loadURIBeaconConfigParams(¶ms);
/* Initialize a URIBeaconConfig service providing config params, default URI, and power levels. */
static URIBeaconConfigService::PowerLevels_t defaultAdvPowerLevels = {-20, -4, 0, 10}; // Values for ADV packets related to firmware levels
uriBeaconConfig = new URIBeaconConfigService(ble, params, !fetchedFromPersistentStorage, "http://uribeacon.org", defaultAdvPowerLevels);
if (!uriBeaconConfig->configuredSuccessfully()) {
error("failed to accommodate URI");
}
// Setup auxiliary services to allow over-the-air firmware updates, etc
DFUService *dfu = new DFUService(ble);
DeviceInformationService *deviceInfo = new DeviceInformationService(ble, "ARM", "UriBeacon", "SN1", "hw-rev1", "fw-rev1", "soft-rev1");
ble.startAdvertising(); /* Set the whole thing in motion. After this call a GAP central can scan the URIBeaconConfig
* service. This can then be switched to the normal URIBeacon functionality after a timeout. */
/* Post a timeout callback to be invoked in ADVERTISEMENT_TIMEOUT_SECONDS to affect the switch to beacon mode. */
minar::Scheduler::postCallback(timeout).delay(minar::milliseconds(CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS * 1000));
}
示例2: main
int main(void)
{
ble.init();
ble.onDisconnection(disconnectionCallback);
ble.onDataWritten(WrittenHandler);
// setup advertising
ble.accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_PHONE);
ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME, (const uint8_t *)NAME, sizeof(NAME) - 1);
ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (const uint8_t *)uart_base_uuid_rev, sizeof(uart_base_uuid));
ble.setAdvertisingPayload();
ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble.setActiveScan(false);
ble.setAdvertisingInterval(100);
ble.addService(uartService);
ble.startAdvertising();
while(1)
{
ble.waitForEvent();
}
}
示例3: timeout
/**
* Stop advertising the UriBeaconConfig Service after a delay; and switch to normal URIBeacon.
*/
void timeout(void)
{
Gap::GapState_t state;
state = ble.getGapState();
if (!state.connected) { /* don't switch if we're in a connected state. */
uriBeaconConfig->setupURIBeaconAdvertisements();
ble.startAdvertising();
} else {
minar::Scheduler::postCallback(timeout).delay(minar::milliseconds(CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS * 1000));
}
}
示例4: disconnectionCallback
/**
* Callback triggered upon a disconnection event. Needs to re-enable advertisements.
*/
void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *)
{
ble.startAdvertising();
}