누군가가 이미 C++ 데스크톱 응용 프로그램에 BLE 탐지 장치를 가져 오는 방법을 알아 냈습니까?C++에서 BLE 탐지 장치 가져 오기 Windows 10 데스크톱 응용 프로그램
가 나는 C#에서 끝내야 다음 웹 사이트에서 일부 코드가 있습니다 :
msdn sozial site
및
codefest.at post. 죄송합니다, 그것은 독일어에있어하지만 코드는 코드
하지만 that'for C# 및되지는 C++
나는 방법도 지금은 일이 들어 WinRL
를 사용하는 MS (msdn.microsoft.com/en-us/library/hh973459.aspx)의 예를 전자 다음 코드를
#include "stdafx.h"
#include <iostream>
#include <Windows.Foundation.h>
#include <wrl\wrappers\corewrappers.h>
#include <wrl\client.h>
#include <stdio.h>
#include <../winrt/windows.devices.bluetooth.h>
#include <../winrt/windows.devices.bluetooth.advertisement.h>
using namespace std;
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Devices::Bluetooth::Advertisement;
/* http://www.codefest.at/post/2015/09/07/Bluetooth-Beacons-Windows-10.aspx
private async void WatcherOnReceived(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs eventArgs)
{
_beaconManager.ReceivedAdvertisement(eventArgs);
}
var watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active };
watcher.Received += WatcherOnReceived;
watcher.Stopped += WatcherOnStopped;
watcher.Start();
*/
// Prints an error string for the provided source code line and HRESULT
// value and returns the HRESULT value as an int.
int PrintError(unsigned int line, HRESULT hr)
{
wprintf_s(L"ERROR: Line:%d HRESULT: 0x%X\n", line, hr);
return hr;
}
EventRegistrationToken watcherToken;
int main()
{
// Initialize the Windows Runtime.
RoInitializeWrapper initialize(RO_INIT_MULTITHREADED);
if (FAILED(initialize))
{
return PrintError(__LINE__, initialize);
}
// Get the activation factory for the IBluetoothLEAdvertisementWatcherFactory interface.
ComPtr<IBluetoothLEAdvertisementWatcherFactory> bleAdvWatcherFactory;
HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_Devices_Bluetooth_Advertisement_BluetoothLEAdvertisementWatcher).Get(), &bleAdvWatcherFactory);
if (FAILED(hr))
{
return PrintError(__LINE__, hr);
}
IBluetoothLEAdvertisementWatcher* bleWatcher;
IBluetoothLEAdvertisementFilter* bleFilter;
hr = bleAdvWatcherFactory->Create(bleFilter, &bleWatcher);
if (bleWatcher == NULL)
{
cout << "bleWatcher is NULL, err is " << hex << hr;
}
else
{
bleWatcher->Start();
while (1)
Sleep(1000);
}
return 0;
}
내 문제는 감시자 공장 변수 중 하나가 유효하지 않음 (HR = E_INVALIDARG "하나 개 이상의 인수가 유효하지 않습니다"가 0x80070057)에 불만이 있기 때문에 (I 필터를 의심한다는 것입니다 유효한 내용 없음).
심각도가 같더라도 들어오는 신호에 이벤트 처리기를 등록하는 방법을 알지 못합니다.
msdn.microsoft.com/en-us/library/windows/apps/windows.devices.bluetooth.advertisement.bluetoothleadvertisementwatcher.received?cs-save-lang=1 & CS-LANG = CPP 나에게 뭔가를 말하고있다 Received 이벤트에 대해. 하지만 VS에서 자동 완성 기능을 사용하지 않고 수동으로 헤더 파일을 조사하지도 않습니다. 내가 가지고있는 차선책은 "add_Received"이지만 사용 방법에 대한 문서를 찾을 수 없습니다. 헤더 파일에서 그다지 현명하지 않습니다.
미리 감사 드리며 유용한 해결책을 알려 주셔서 감사합니다.
마커스
을 나는 또한 여기에 같은 일을 구축하고있다. 내 문제는 지금 실행할 때, 나는 : "실패 -2147221164"오류가 "클래스가 등록되지 않았습니다"때 팩터 리 개체를 만들려고합니다. 저는 MSVC 커뮤니티 에디션 "14.11.25503"으로 컴파일하고 win10 SDK "10.0.16299.0"과 링크하고 있습니다. DLL 클래스를 등록하려면 아무 것도해야합니까? – peterk