I am trying to analyze the data contained in a bluetooth low energy advertisement, this is my code so far.
HRESULT BLEWatcher::OnAdvertisementReceived(IBluetoothLEAdvertisementWatcher* watcher, IBluetoothLEAdvertisementReceivedEventArgs* args)
{
IBluetoothLEAdvertisement** advertisement;
args->get_Advertisement(advertisement);
__FIVector_1_Windows__CDevices__CBluetooth__CAdvertisement__CBluetoothLEAdvertisementDataSection** dataSections;
(*advertisement)->get_DataSections(dataSections);
IBluetoothLEAdvertisementDataSection** dataSection;
(*dataSections)->GetAt(2, dataSection);
ABI::Windows::Storage::Streams::IBuffer** buffer;
(*dataSection)->get_Data(buffer);
ComPtr<ABI::Windows::Storage::Streams::IDataReader> reader;
UINT32 *length;
(*buffer)->get_Length(length);
return S_OK;
}
I cannot find how to extract the data from the IBuffer, preferably as byte array. If there is a better way to extract the data, or anyone knows how to convert the IBuffer to byte array your help would be greatly appreciated.
Also, I have no way of checking that my code thus far is correct, so if any mistakes were made please feel free to let me know.