Created
December 12, 2019 02:23
-
-
Save houwasystemdesign/62a3e97d7124190fb81dac70160d783f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AdvertisementListItem | |
{ | |
public ulong BluetoothAddress; | |
public string AdvertisementData; | |
public AdvertisementListItem(BluetoothLEAdvertisementReceivedEventArgs eventArgs) | |
{ | |
BluetoothAddress = eventArgs.BluetoothAddress; | |
var dataSections = eventArgs.Advertisement.DataSections; | |
foreach (BluetoothLEAdvertisementDataSection dataSection in dataSections) | |
{ | |
//DataTypeが0xFF(メーカー固有のデータ)なら、Dataをシリアルナンバーとアドバタイズデータにして代入 | |
if (dataSection.DataType == 0xFF) | |
{ | |
byte[] datas = dataSection.Data.ToArray(); | |
StringBuilder sb = new StringBuilder(); | |
foreach (byte data in datas) | |
{ | |
sb.Append(data.ToString("X2")); | |
} | |
AdvertisementData = sb.ToString(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment