本文整理汇总了C++中BLE::getGapState方法的典型用法代码示例。如果您正苦于以下问题:C++ BLE::getGapState方法的具体用法?C++ BLE::getGapState怎么用?C++ BLE::getGapState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BLE
的用法示例。
在下文中一共展示了BLE::getGapState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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));
}
}
示例2: main
int main(void)
{
led1 = 1;
Ticker ticker;
ticker.attach(periodicCallback, 1); // blink LED every second
ble.init();
ble.gap().onDisconnection(disconnectionCallback);
/* Setup primary service. */
uint8_t hrmCounter = 100; // init HRM to 100bps
HeartRateService hrService(ble, hrmCounter, HeartRateService::LOCATION_FINGER);
/* Setup auxiliary service. */
DeviceInformationService deviceInfo(ble, "ARM", "Model1", "SN1", "hw-rev1", "fw-rev1", "soft-rev1");
/* Setup advertising. */
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list));
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_HEART_RATE_SENSOR);
ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
ble.gap().setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble.gap().setAdvertisingInterval(1000); /* 1000ms */
ble.gap().startAdvertising();
// infinite loop
while (1) {
// check for trigger from periodicCallback()
if (triggerSensorPolling && ble.getGapState().connected) {
triggerSensorPolling = false;
// Do blocking calls or whatever is necessary for sensor polling.
// In our case, we simply update the HRM measurement.
hrmCounter++;
// 100 <= HRM bps <=175
if (hrmCounter == 175) {
hrmCounter = 100;
}
// update bps
hrService.updateHeartRate(hrmCounter);
} else {
ble.waitForEvent(); // low power wait for event
}
}
}