A set of classes for enumerating and interacting with Bluetooth low energy devices on the windows platform.
// The characteristic must have IsReadable set to true or an exception will be thrown
BleGattCharacteristicValue value = characteristic->getValue();
// The characteristic must have IsSignedWritable, IsWritable, IsWritableWithoutResponse set to true or an exception will be thrown
UCHAR values[] = { 'H', 'I', '\r', '\n' };
characteristic->setValue(values, 4);
// The callback for the characteristic notification
void HandleCallback(BleGattNotificationData& data)
{
cout << "Received callback data: " << data.getDataSize() << endl;
}
// Enumerate characteristic descriptors
characteristic->enumerateBleDescriptors();
// Get the list of descriptors
list<BleGattDescriptor *> descriptors = characteristic->getBleDescriptors();
if (descriptors.size() > 0)
{
// Get the characteristic descriptor
BleGattDescriptor *descriptor = descriptors.front();
// The callback function
const std::function<void(BleGattNotificationData&)> callback = HandleCallback;
// Enable notifications for the characteristic IsNotifiable or IsIndicatable must be true for the characteristic or an exception will be thrown
characteristic->enableNotifications(callback);
// Enable the subscription notification for the characteristic
descriptor->setIsSubscribeToNotification();
// Disable the notification
characteristic->disableNotifications();
// Clear the subscription notification
descriptor->clearIsSubscribeToNotification();
}
Windows Bluetooth tracing requires the download of a WPRP file from the Microsoft Git hub repo eere. The readme.md document in the Microsoft Git hub repo describes the steps to enable the tracing.
When this tracing is complete the stop command will write the trace contents to an ETL file that is provided as a parameter to the command.
The generated ETL file is a binary file in order to parse it to a readable form, a tool called BTETLParse.exe is required to convert the ETL. The tool supports a number of different formats of output, namely:
Instructions for the BTETLParse.exe tool can be found Here
The BTETLParse.exe tool can be downloaded from Here
直接打开WinBle.sln即可。
使用CMake编译,需要使用最新版的MSYS2。由于MSYS2的gcc暂时不支持BLE(截至编辑时),故从Windows10 SDK中复制了相应的库及头文件。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。