本文整理汇总了C++中BLEDevice::startScan方法的典型用法代码示例。如果您正苦于以下问题:C++ BLEDevice::startScan方法的具体用法?C++ BLEDevice::startScan怎么用?C++ BLEDevice::startScan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BLEDevice
的用法示例。
在下文中一共展示了BLEDevice::startScan方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
//pc.wait(1);
gatt_characteristics[CHARACTERISTIC_LED] =
new GattCharacteristic(
nRF51_GATT_CHAR_LED,
&gatt_char_value[CHARACTERISTIC_LED], 1, 1,
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ |
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE |
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE);
gatt_service = new GattService(nRF51_GATT_SERVICE, gatt_characteristics, CHARACTERISTIC_COUNT);
//Initialize BLE Device
ble.init();
ble.setDeviceName((uint8_t *)DEVICE_NAME);
// configure our advertising type, payload and interval00
ble.accumulateAdvertisingPayload(
GapAdvertisingData::BREDR_NOT_SUPPORTED |
GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
ble.accumulateAdvertisingPayload(
GapAdvertisingData::COMPLETE_LOCAL_NAME,
(uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME));
ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
ble.setAdvertisingInterval(160); // 100ms
/*
led1.write(1);
led3.write(1);
led2.write(1);
led4.write(1);
*/
for(int i=0; i<10; i++)
pc.printf("Hello World\n");
ble.onConnection((Gap::ConnectionEventCallback_t)connectionCallback);
ble.onDisconnection(disconnectionCallback);
ble.gattServer().onDataWritten(onDataWritten);
ble.addService(*gatt_service);
ble.startAdvertising();
/* Adding below for scanning */
ble.setScanParams(500 /* scan interval */, 200 /* scan window */);
ble.startScan(advertisementCallback);
/**END OF PART FOR SCANNING**/
for (;;)
{
ble.waitForEvent();
}
}