本文整理汇总了C++中BLE::waitForEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ BLE::waitForEvent方法的具体用法?C++ BLE::waitForEvent怎么用?C++ BLE::waitForEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BLE
的用法示例。
在下文中一共展示了BLE::waitForEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
示例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
}
}
}
示例3: main
int main(void)
{
app_start(0, NULL);
for(;;)
{
// send notification outside of interrupt context
if (sendHello)
{
ble_error_t result = bts->updateCharacteristicValue((const uint8_t*)"hello", 5);
if (result == BLE_ERROR_NONE)
{
sendHello = false;
}
}
ble.waitForEvent();
}
}